When an MCP client sends the notifications/initialized notification (part of the standard MCP initialization handshake), the server responds with:
{"jsonrpc":"2.0","error":{"code":-32601,"message":"Method not found: notifications/initialized","data":null}}
This is incorrect behavior. notifications/initialized is a JSON-RPC notification (no id field). Per the JSON-RPC spec, notifications must not receive a response, including error responses. Unknown notifications should be silently ignored.
Any MCP client that strictly follows the spec will receive this unexpected error response and close the transport. The server then detects the broken pipe and shuts down, making it appear that the server exits immediately after initialization.
Reproduction:
printf '{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"capabilities":{},"clientInfo":{"name":"test","version":"1.0"},"protocolVersion":"2024-11-05"}}\n{"jsonrpc":"2.0","method":"notifications/initialized"}\n' \
| rust-analyzer-mcp /path/to/workspace
The expected behavior is that the server silently ignores notifications/initialized (or handles it) and continues running, waiting for tool calls.
Fix: Before dispatching an incoming message to the method router, check whether it has an id field. If it does not, treat it as a notification and do not send any response, even on method-not-found.
When an MCP client sends the
notifications/initializednotification (part of the standard MCP initialization handshake), the server responds with:{"jsonrpc":"2.0","error":{"code":-32601,"message":"Method not found: notifications/initialized","data":null}}This is incorrect behavior.
notifications/initializedis a JSON-RPC notification (noidfield). Per the JSON-RPC spec, notifications must not receive a response, including error responses. Unknown notifications should be silently ignored.Any MCP client that strictly follows the spec will receive this unexpected error response and close the transport. The server then detects the broken pipe and shuts down, making it appear that the server exits immediately after initialization.
Reproduction:
The expected behavior is that the server silently ignores
notifications/initialized(or handles it) and continues running, waiting for tool calls.Fix: Before dispatching an incoming message to the method router, check whether it has an
idfield. If it does not, treat it as a notification and do not send any response, even on method-not-found.