Skip to content

Commit 6f51715

Browse files
committed
fix(initialize scenario): return 202 No Content for notifications (closes #274)
The transport spec (2025-11-25 § 2.1, point 4) requires that a server reply to a JSON-RPC notification with 202 Accepted and no body. The fall-through branch in the initialize scenario test server returned 200 with `{"jsonrpc":"2.0","id":null,"result":{}}` for all non-initialize, non-tools/list requests - including `notifications/initialized`. Branch on `request.id == null` (notification) and emit 202 with no body in that case. Non-notification requests still get the prior placeholder 200-response behavior. Closes #274.
1 parent c57795e commit 6f51715

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

src/scenarios/client/initialize.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,12 @@ export class InitializeScenario implements Scenario {
7878
this.handleInitialize(request, res);
7979
} else if (request.method === 'tools/list') {
8080
this.handleToolsList(request, res);
81+
} else if (request.method === 'notifications/initialized') {
82+
// Per MCP spec 2025-11-25 section 2.1 (Sending Messages to the Server),
83+
// point 4: "If the input is a JSON-RPC response or notification ...
84+
// the server MUST return HTTP status code 202 Accepted with no body."
85+
res.writeHead(202);
86+
res.end();
8187
} else {
8288
res.writeHead(200, { 'Content-Type': 'application/json' });
8389
res.end(

0 commit comments

Comments
 (0)