go-sdk/mcp/testdata/conformance/server/resources.txtar
Jonathan Amsterdam 2b9c6bff50 internal/mcp: handle synthetic responses in conformance test
Modify the conformance test driver to support outgoing responses.
They are returned for incoming requests in order.

Add a test that returns a file resource, which involves the server
sending a roots/list request to the client.

Change-Id: Ie7eb69a8c99ccbf11721518cfffb21244c03e532
Reviewed-on: https://go-review.googlesource.com/c/tools/+/677475
Commit-Queue: Jonathan Amsterdam <jba@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Findley <rfindley@google.com>
2025-05-30 08:16:23 -07:00

120 lines
1.8 KiB
Text

Check behavior of a server with just resources.
Fixed bugs:
- A resource result holds a slice of contents, not just one.
-- resources --
info
info.txt
-- 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": "resources/list" }
{
"jsonrpc": "2.0", "id": 3,
"method": "resources/read",
"params": {
"uri": "embedded:info"
}
}
{
"jsonrpc": "2.0", "id": 3,
"method": "resources/read",
"params": {
"uri": "file:///info.txt"
}
}
{
"jsonrpc": "2.0", "id": 0,
"result": {
"roots": []
}
}
-- server --
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"_meta": {},
"capabilities": {
"completions": {},
"logging": {},
"prompts": {
"listChanged": true
},
"resources": {
"listChanged": true
},
"tools": {
"listChanged": true
}
},
"protocolVersion": "2024-11-05",
"serverInfo": {
"name": "testServer",
"version": "v1.0.0"
}
}
}
{
"jsonrpc": "2.0",
"id": 2,
"result": {
"_meta": {},
"resources": [
{
"mimeType": "text/plain",
"name": "info",
"uri": "embedded:info"
},
{
"mimeType": "text/plain",
"name": "public",
"uri": "file:///info.txt"
}
]
}
}
{
"jsonrpc": "2.0",
"id": 3,
"result": {
"_meta": {},
"contents": [
{
"uri": "embedded:info",
"mimeType": "text/plain",
"text": "This is the MCP test server."
}
]
}
}
{
"jsonrpc": "2.0",
"id": 1,
"method": "roots/list",
"params": null
}
{
"jsonrpc": "2.0",
"id": 3,
"result": {
"_meta": {},
"contents": [
{
"uri": "file:///info.txt",
"mimeType": "text/plain",
"blob": "Q29udGVudHMK"
}
]
}
}