Skip to content

mcp lifecycle: initialization phase is not completely followed #225

@aryannr97

Description

@aryannr97

Issue

  • MCP server is responding to tools/list request, even before receiving initialized message.
  • As per the MCP specification

The server SHOULD NOT send requests other than pings and logging before receiving the initialized notification.

To Reproduce
Steps to reproduce the behavior:

  1. Start MCP server
  2. Send initialize message from client to server
  3. Send tools/list message from client to server

Expected behavior
The tools/list call should result in error citing initialization phase is not fully complete

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","id":2,"method":"tools/list"}
read: {"jsonrpc":"2.0","id":2,"method":"tools/list"}
{"jsonrpc":"2.0","id":2,"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":2,"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":{}}}}]}}

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions