After some experience with the flattened version of Content, we see that it can easily lead to incorrect usage and is a harder API to read. Therefore, this CL changes back to a design similar to what we had prior to https://go.dev/cl/672415, though opting to promote content unmarshalling to the protocol types that use it, which leads to an overall simpler api.
115 lines
1.7 KiB
Text
115 lines
1.7 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": {
|
|
"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": {
|
|
"resources": [
|
|
{
|
|
"mimeType": "text/plain",
|
|
"name": "info",
|
|
"uri": "embedded:info"
|
|
},
|
|
{
|
|
"mimeType": "text/plain",
|
|
"name": "public",
|
|
"uri": "file:///info.txt"
|
|
}
|
|
]
|
|
}
|
|
}
|
|
{
|
|
"jsonrpc": "2.0",
|
|
"id": 3,
|
|
"result": {
|
|
"contents": [
|
|
{
|
|
"uri": "embedded:info",
|
|
"mimeType": "text/plain",
|
|
"text": "This is the MCP test server."
|
|
}
|
|
]
|
|
}
|
|
}
|
|
{
|
|
"jsonrpc": "2.0",
|
|
"id": 1,
|
|
"method": "roots/list"
|
|
}
|
|
{
|
|
"jsonrpc": "2.0",
|
|
"id": 3,
|
|
"result": {
|
|
"contents": [
|
|
{
|
|
"uri": "file:///info.txt",
|
|
"mimeType": "text/plain",
|
|
"blob": "Q29udGVudHMK"
|
|
}
|
|
]
|
|
}
|
|
}
|