-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Description
Describe the bug
MCP protocol does not require the server to response to notifications/initialized.
So MCP server may return HTTP 204 "No Content".
This caused a TypeError exception in udici (see logs below)
To Reproduce
Steps to reproduce the behavior:
- Receive an HTTP 204 status code
Expected behavior
No error message
Logs
Received POST message for sessionId de957f71-c7c3-4add-8f74-77017f866ffc
Error from MCP server: TypeError: Response constructor: Invalid response status code 204
at webidl.errors.exception (node:internal/deps/undici/undici:4282:14)
at initializeResponse (node:internal/deps/undici/undici:10234:31)
at new Response (node:internal/deps/undici/undici:9974:9)
at file:///C:/Users/zyliu/AppData/Local/npm-cache/_npx/5a9d879542beca3a/node_modules/@modelcontextprotocol/inspector/server/build/index.js:255:20
at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
at async StreamableHTTPClientTransport.send (file:///C:/Users/zyliu/AppData/Local/npm-cache/_npx/5a9d879542beca3a/node_modules/@modelcontextprotocol/sdk/dist/esm/client/streamableHttp.js:315:30)
Additional context
It seems typescript-client expects an HTTP 202 response
// If the response is 202 Accepted, there's no body to process
if (response.status === 202) {
await response.body?.cancel();
// if the accepted notification is initialized, we start the SSE stream
// if it's supported by the server
if (isInitializedNotification(message)) {
// Start without a lastEventId since this is a fresh connection
this._startOrAuthSse({ resumptionToken: undefined }).catch(err => this.onerror?.(err));
}
return;
}