From 0e1235d352be75d29e4c4cd13e55ee17293a990f Mon Sep 17 00:00:00 2001 From: Aditya Chilka <80785619+adityachilka1@users.noreply.github.com> Date: Mon, 7 Sep 2026 02:25:37 +0530 Subject: [PATCH] fix(initialize scenario): return 202 No Content for notifications (closes #274) (#299) 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. Co-authored-by: aditya Co-authored-by: Paul Carleton --- 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 be8d708..9906622 100644 --- a/src/scenarios/client/initialize.ts +++ b/src/scenarios/client/initialize.ts @@ -83,6 +83,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(