Skip to content

MCP server incorrectly returns errors for JSON-RPC notifications #1252

@rickhull

Description

@rickhull
$ cat .mise.toml
[tools]
erlang = "28"
elixir = "1.19-otp-28"
elixir-ls = "0.30.0"

The ElixirLS MCP server returns error -32600 "Invalid request" for JSON-RPC notifications (messages without an id field). According to the JSON-RPC 2.0 spec and MCP spec, notifications should be silently ignored if not supported, not return error responses.

This breaks compatibility with MCP clients like Codex that send the required initialized notification after the initialize request.

Reproduction:

(echo '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2024-11-05","capabilities":{},"clientInfo":{"name":"test","version":"1.0"}}}'; echo '{"jsonrpc":"2.0","method":"initialized"}'; sleep 0.5) | elixir /path/to/tcp_to_stdio_bridge.exs 3798

Expected: Only the initialize response
Actual: Initialize response + {"error":{"code":-32600,"message":"Invalid request"},"id":null,"jsonrpc":"2.0"}

Impact: MCP clients that send the initialized notification (per spec) fail to connect. This includes the codex CLI from OpenAI.

Full repro:

$ (echo '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2024-11-05","capabilities":{},"clientInfo":{"name":"test","version":"1.0"}}}'; echo '{"jsonrpc":"2.0","method":"initialized"}'; sleep 0.5) | elixir /home/rwh/.local/share/mise/installs/elixir-ls/0.30.0/tcp_to_stdio_bridge.exs 3798
{"id":1,"jsonrpc":"2.0","result":{"capabilities":{"tools":{}},"protocolVersion":"2024-11-05","serverInfo":{"name":"ElixirLS MCP Server","version":"1.0.0"}}}
{"error":{"code":-32600,"message":"Invalid request"},"id":null,"jsonrpc":"2.0"}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions