-
Notifications
You must be signed in to change notification settings - Fork 362
Closed
Labels
good first issueGood for newcomersGood for newcomershelp wantedContributions welcome from those familiar with codebase. Comment first to say you're working on itContributions welcome from those familiar with codebase. Comment first to say you're working on it
Milestone
Description
You can make MCP server log error, send response and then abruptly exit, with a json input malformed at the end
To Reproduce
Steps to reproduce the behavior:
- Start the MCP server
$ go run github.com/modelcontextprotocol/go-sdk/examples/hello
- Send
initialize
{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2024-11-05","capabilities":{"roots":{"listChanged":true},"sampling":{},"elicitation":{}},"clientInfo":{"name":"ExampleClient","title":"Example Client Display Name","version":"1.0.0"}}}
- Send
notifications/initialized
{"jsonrpc":"2.0","method":"notifications/initialized"}
- Now send
tools/listby malforming it at the end
{"jsonrpc":"2.0","id":2,"method":"tools/list"},
Expected behavior
Server should handle invalid json input and report it as an error without sending the valid tool/list response and exiting
Logs
$ go run github.com/modelcontextprotocol/go-sdk/examples/hello
{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2024-11-05","capabilities":{"roots":{"listChanged":true},"sampling":{},"elicitation":{}},"clientInfo":{"name":"ExampleClient","title":"Example Client Display Name","version":"1.0.0"}}}
read: {"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2024-11-05","capabilities":{"roots":{"listChanged":true},"sampling":{},"elicitation":{}},"clientInfo":{"name":"ExampleClient","title":"Example Client Display Name","version":"1.0.0"}}}
{"jsonrpc":"2.0","id":1,"result":{"capabilities":{"completions":{},"logging":{},"prompts":{"listChanged":true},"resources":{"listChanged":true},"tools":{"listChanged":true}},"protocolVersion":"2024-11-05","serverInfo":{"name":"greeter","version":""}}}
write: {"jsonrpc":"2.0","id":1,"result":{"capabilities":{"completions":{},"logging":{},"prompts":{"listChanged":true},"resources":{"listChanged":true},"tools":{"listChanged":true}},"protocolVersion":"2024-11-05","serverInfo":{"name":"greeter","version":""}}}
{"jsonrpc":"2.0","method":"notifications/initialized"}
read: {"jsonrpc":"2.0","method":"notifications/initialized"}
{"jsonrpc":"2.0","id":2,"method":"tools/list"},
read: {"jsonrpc":"2.0","id":1,"method":"tools/list"}
read error: invalid character ',' looking for beginning of value{"jsonrpc":"2.0","id":1,"result":{"tools":[{"description":"say hi","inputSchema":{"type":"object","required":["name"],"properties":{"name":{"type":"string","description":"the name to say hi to"}},"additionalProperties":{"not":{}}},"name":"greet","outputSchema":{"type":"object","additionalProperties":{"not":{}}}}]}}
write: {"jsonrpc":"2.0","id":1,"result":{"tools":[{"description":"say hi","inputSchema":{"type":"object","required":["name"],"properties":{"name":{"type":"string","description":"the name to say hi to"}},"additionalProperties":{"not":{}}},"name":"greet","outputSchema":{"type":"object","additionalProperties":{"not":{}}}}]}}
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
good first issueGood for newcomersGood for newcomershelp wantedContributions welcome from those familiar with codebase. Comment first to say you're working on itContributions welcome from those familiar with codebase. Comment first to say you're working on it