Skip to content

Commit 7fb140a

Browse files
author
Your Name
committed
Fix modelcontextprotocol#3267: Add DISABLE_SSE_RESUMABILITY option to work around empty SSE event parsing issues
When connecting with protocol version 2025-11-25+, the everything server sends an empty SSE priming event as required by SEP-1699 for resumability support. However, some clients (like the Java MCP client) don't properly handle empty SSE data events per the SSE specification, causing deserialization failures. This commit adds a DISABLE_SSE_RESUMABILITY environment variable that allows users to disable the eventStore, preventing the priming event from being sent. This is a workaround for clients that don't properly handle empty SSE events. Users can now disable resumability with: DISABLE_SSE_RESUMABILITY=true npx @modelcontextprotocol/server-everything streamableHttp Changes: - Modified streamableHttp.ts to check DISABLE_SSE_RESUMABILITY env var - Only create eventStore if resumability is enabled - Updated README.md with documentation and usage examples The proper fix is still to update affected clients to handle empty SSE events correctly per the SSE standard.
1 parent a83b145 commit 7fb140a

2 files changed

Lines changed: 41 additions & 2 deletions

File tree

‎src/everything/README.md‎

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,3 +104,32 @@ npx @modelcontextprotocol/server-everything sse
104104
npx @modelcontextprotocol/server-everything streamableHttp
105105
```
106106

107+
## Environment Variables
108+
109+
### DISABLE_SSE_RESUMABILITY
110+
111+
Set to `true` to disable SSE resumability (eventStore). This prevents the server from sending the priming event (empty SSE event with an ID) that is required by [SEP-1699](https://modelcontextprotocol.io/community/seps/1699-support-sse-polling-via-server-side-disconnect) for protocol version 2025-11-25+.
112+
113+
**Note**: This is a workaround for clients that don't properly handle empty SSE data events as specified by the [SSE standard](https://html.spec.whatwg.org/multipage/server-sent-events.html). The proper fix is to update the client to handle empty SSE events correctly.
114+
115+
When resumability is disabled:
116+
- SSE streams cannot be resumed after network failures
117+
- Server cannot use polling mode (must keep connections open)
118+
- Event replay is not available
119+
120+
```shell
121+
# Disable SSE resumability
122+
DISABLE_SSE_RESUMABILITY=true npx @modelcontextprotocol/server-everything streamableHttp
123+
124+
# Or with Docker
125+
docker run -e DISABLE_SSE_RESUMABILITY=true -p 3001:3001 mcp/everything streamableHttp
126+
```
127+
128+
### PORT
129+
130+
Set the port for the HTTP servers (SSE and Streamable HTTP). Default: `3001`
131+
132+
```shell
133+
PORT=8080 npx @modelcontextprotocol/server-everything streamableHttp
134+
```
135+

‎src/everything/transports/streamableHttp.ts‎

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,13 @@ class InMemoryEventStore implements EventStore {
3838

3939
console.log("Starting Streamable HTTP server...");
4040

41+
// Check if SSE resumability should be disabled (workaround for clients that don't handle empty SSE events)
42+
const DISABLE_SSE_RESUMABILITY = process.env.DISABLE_SSE_RESUMABILITY === 'true';
43+
if (DISABLE_SSE_RESUMABILITY) {
44+
console.log("SSE resumability is DISABLED - eventStore will not be used");
45+
console.log("This is a workaround for clients that don't properly handle empty SSE data events");
46+
}
47+
4148
// Express app with permissive CORS for testing with Inspector direct connect mode
4249
const app = express();
4350
app.use(
@@ -72,10 +79,13 @@ app.post("/mcp", async (req: Request, res: Response) => {
7279
const { server, cleanup } = createServer();
7380

7481
// New initialization request
75-
const eventStore = new InMemoryEventStore();
82+
// Only enable eventStore if resumability is not disabled
83+
// Note: Disabling resumability is a workaround for clients that don't properly
84+
// handle empty SSE data events (required by SEP-1699 for protocol >= 2025-11-25)
85+
const eventStore = DISABLE_SSE_RESUMABILITY ? undefined : new InMemoryEventStore();
7686
transport = new StreamableHTTPServerTransport({
7787
sessionIdGenerator: () => randomUUID(),
78-
eventStore, // Enable resumability
88+
eventStore, // Enable resumability (unless disabled)
7989
onsessioninitialized: (sessionId: string) => {
8090
// Store the transport by session ID when a session is initialized
8191
// This avoids race conditions where requests might come in before the session is stored

0 commit comments

Comments
 (0)