go-sdk/mcp/testdata/conformance/server/prompts.txtar
Robert Findley b34ba2149d
mcp: handle bad or missing params (#210)
Audit all cases where params must not be null, and enforce this using
methodInfo via a new methodFlags bitfield that parameterizes method
requirements. Write extensive conformance tests catching all the
(server-side) crashes that were possible.

We should go further and validate schema against the spec, but that is
more indirect, more complicated, and potentially slower. For now we
adopt this more explicit approach.

Still TODO in a subsequent CL: verify the client side of this with
client conformance tests.

Additionally, improve some error messages that were redundant or leaked
internal implementation details.

Fixes #195
2025-07-31 10:57:59 -04:00

75 lines
1.2 KiB
Text

Check behavior of a server with just prompts.
Fixed bugs:
- Empty tools lists should not be returned as 'null'.
- No params in 'prompts/get' should not panic.
-- prompts --
code_review
-- client --
{
"jsonrpc": "2.0",
"id": 1,
"method": "initialize",
"params": {
"protocolVersion": "2024-11-05",
"capabilities": {},
"clientInfo": { "name": "ExampleClient", "version": "1.0.0" }
}
}
{ "jsonrpc": "2.0", "id": 2, "method": "tools/list" }
{ "jsonrpc": "2.0", "id": 4, "method": "prompts/list" }
{ "jsonrpc": "2.0", "id": 5, "method": "prompts/get" }
-- server --
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"capabilities": {
"completions": {},
"logging": {},
"prompts": {
"listChanged": true
}
},
"protocolVersion": "2024-11-05",
"serverInfo": {
"name": "testServer",
"version": "v1.0.0"
}
}
}
{
"jsonrpc": "2.0",
"id": 2,
"result": {
"tools": []
}
}
{
"jsonrpc": "2.0",
"id": 4,
"result": {
"prompts": [
{
"arguments": [
{
"name": "Code",
"required": true
}
],
"description": "do a code review",
"name": "code_review"
}
]
}
}
{
"jsonrpc": "2.0",
"id": 5,
"error": {
"code": -32600,
"message": "invalid request: missing required \"params\""
}
}