From 6f51715462f87f14e85264c71456e23a1448ab46 Mon Sep 17 00:00:00 2001 From: aditya Date: Fri, 22 May 2026 03:09:24 +0530 Subject: [PATCH] fix(initialize scenario): return 202 No Content for notifications (closes #274) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- src/scenarios/client/initialize.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/scenarios/client/initialize.ts b/src/scenarios/client/initialize.ts index b5e2aef2..e26878e9 100644 --- a/src/scenarios/client/initialize.ts +++ b/src/scenarios/client/initialize.ts @@ -78,6 +78,12 @@ export class InitializeScenario implements Scenario { this.handleInitialize(request, res); } else if (request.method === 'tools/list') { this.handleToolsList(request, res); + } else if (request.method === 'notifications/initialized') { + // Per MCP spec 2025-11-25 section 2.1 (Sending Messages to the Server), + // point 4: "If the input is a JSON-RPC response or notification ... + // the server MUST return HTTP status code 202 Accepted with no body." + res.writeHead(202); + res.end(); } else { res.writeHead(200, { 'Content-Type': 'application/json' }); res.end(