Skip to content

fix: silently ignore JSON-RPC notifications per spec#1

Open
mh0pe wants to merge 1 commit into
frishtik:mainfrom
mh0pe:fix/ignore-jsonrpc-notifications
Open

fix: silently ignore JSON-RPC notifications per spec#1
mh0pe wants to merge 1 commit into
frishtik:mainfrom
mh0pe:fix/ignore-jsonrpc-notifications

Conversation

@mh0pe

@mh0pe mh0pe commented Mar 9, 2026

Copy link
Copy Markdown

Summary

  • Server now silently ignores JSON-RPC 2.0 notifications (messages with no id) instead of returning a -32601 Method not found error

Problem

The MCP protocol sends notifications/initialized after the initialize handshake. Per JSON-RPC 2.0 spec, notifications have no id field and must not receive a response.

The server was returning an error response for these notifications:

{"jsonrpc": "2.0", "id": null, "error": {"code": -32601, "message": "Method not found: notifications/initialized"}}

This caused MCP clients (e.g., Forge) to interpret the error as a connection failure, preventing tools/list from succeeding.

Fix

Check for request_id is None before dispatching, and continue to skip notifications silently. This matches the JSON-RPC 2.0 spec: "The Server MUST NOT reply to a Notification."

Test plan

  • Verified notifications/initialized is silently ignored (no error response)
  • Verified tools/list returns all 7 tools successfully after notification
  • Verified normal requests with id still work as expected

The MCP protocol sends `notifications/initialized` after the initialize
handshake. Per JSON-RPC 2.0, notifications have no `id` field and must
not receive a response.

Previously, the server returned a -32601 "Method not found" error for
any unrecognized method, including notifications. This caused MCP clients
like Forge to interpret the error response as a connection failure,
preventing tools/list from succeeding.

The fix checks for `request_id is None` (indicating a notification) and
silently skips it via `continue`, matching the JSON-RPC 2.0 spec:
"The Server MUST NOT reply to a Notification."

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant