-
Notifications
You must be signed in to change notification settings - Fork 32
Open
Description
Description
The STDIO transport crashes with a BadMapError when processing any incoming JSON-RPC message.
Steps to Reproduce
- Start an MCP server with stdio transport
- Send any valid JSON-RPC message via stdin (e.g., an initialize request)
- Server crashes with
BadMapError
Example:
echo '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2024-11-05","capabilities":{},"clientInfo":{"name":"test","version":"1.0"}}}' | mix mcp.serverExpected Behavior
The server should process the message and return a valid JSON-RPC response.
Actual Behavior
** (BadMapError) expected a map, got:
[
%{
"id" => 1,
"jsonrpc" => "2.0",
"method" => "initialize",
...
}
]
Root Cause
In lib/hermes/server/transport/stdio.ex, the handle_incoming_data/2 function calls Message.decode/1 which returns {:ok, messages} where messages is a list of decoded messages. However, this list is passed directly to process_message/2 which expects a single message map.
# Current code (line 241-243):
case Message.decode(data) do
{:ok, messages} ->
process_message(messages, state) # Bug: messages is a list, not a map
Proposed Fix
Iterate over the messages list before calling process_message/2:
case Message.decode(data) do
{:ok, messages} ->
Enum.each(messages, &process_message(&1, state))
Environment
- hermes_mcp version: 0.14.1
- Elixir version: 1.15+
- OS: macOS/Linux
Metadata
Metadata
Assignees
Labels
No labels