fix(initialize scenario): return 202 No Content for notifications (closes #274) (#299)

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 <aditya@rapidcircuitry.com>
Co-authored-by: Paul Carleton <paulcarletonjr@gmail.com>
This commit is contained in:
Aditya Chilka 2026-09-07 02:25:37 +05:30 • committed by GitHub
commit 0e1235d352
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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(