Upon a closer reading of the spec, it is OK for the server to response to client requests before it has received notifications/initialized (as long as it has received initialize). This effectively rolls back the fix from #225. Some hooks are left for enforcing strictness around server->client requests prior to initialized. These will be revisited in subsequent CLs. For #395
65 lines
1.2 KiB
Text
65 lines
1.2 KiB
Text
This test checks that the server obeys the rules for initialization lifecycle,
|
|
and rejects non-ping requests until 'initialized' is received.
|
|
|
|
See also modelcontextprotocol/go-sdk#225.
|
|
|
|
-- client --
|
|
{ "jsonrpc":"2.0", "method": "notifications/initialized" }
|
|
{ "jsonrpc": "2.0", "id": 2, "method": "tools/list" }
|
|
{
|
|
"jsonrpc": "2.0",
|
|
"id": 1,
|
|
"method": "initialize",
|
|
"params": {
|
|
"protocolVersion": "2024-11-05",
|
|
"capabilities": {},
|
|
"clientInfo": { "name": "ExampleClient", "version": "1.0.0" }
|
|
}
|
|
}
|
|
{ "jsonrpc":"2.0", "id": 1, "method":"ping" }
|
|
{ "jsonrpc": "2.0", "id": 2, "method": "tools/list" }
|
|
{ "jsonrpc":"2.0", "method": "notifications/initialized" }
|
|
{ "jsonrpc": "2.0", "id": 3, "method": "tools/list" }
|
|
|
|
-- server --
|
|
{
|
|
"jsonrpc": "2.0",
|
|
"id": 2,
|
|
"error": {
|
|
"code": 0,
|
|
"message": "method \"tools/list\" is invalid during session initialization"
|
|
}
|
|
}
|
|
{
|
|
"jsonrpc": "2.0",
|
|
"id": 1,
|
|
"result": {
|
|
"capabilities": {
|
|
"logging": {}
|
|
},
|
|
"protocolVersion": "2024-11-05",
|
|
"serverInfo": {
|
|
"name": "testServer",
|
|
"version": "v1.0.0"
|
|
}
|
|
}
|
|
}
|
|
{
|
|
"jsonrpc": "2.0",
|
|
"id": 1,
|
|
"result": {}
|
|
}
|
|
{
|
|
"jsonrpc": "2.0",
|
|
"id": 2,
|
|
"result": {
|
|
"tools": []
|
|
}
|
|
}
|
|
{
|
|
"jsonrpc": "2.0",
|
|
"id": 3,
|
|
"result": {
|
|
"tools": []
|
|
}
|
|
}
|