mcp: move to 2025-06-18 schema (#8)
* mcp: move to 2025-06-18 schema Add types and fields for the latest MCP schema. The main challenge here was dealing with the presence of _meta fields on many types, like Tool, Prompt and Resource. - Distinguish between the _meta field of a request's params, which includes a progress token, from the _meta field on other types, which is simply a map. - Redefine GetMeta to return a pointer to the map. We wanted to avoid that, but I don't see a clean way to do so. An alternative would be to have GetMeta return a map, and SetMeta to set it. - Provide GetProgressToken for requests only (not notifications or other types). - Still to do: deal with the meta and annotation fields of ContentBlock, which are currently duplicated for Resource and ResourceContents. * Meta and progress token redesign
This commit is contained in:
parent
735ad517ed
commit
3da831b0c9
1 changed files with 372 additions and 249 deletions
|
|
@ -14,7 +14,7 @@ import (
|
|||
|
||||
func TestContent(t *testing.T) {
|
||||
tests := []struct {
|
||||
in *mcp.Content
|
||||
in *mcp.ContentBlock
|
||||
want string // json serialization
|
||||
}{
|
||||
{mcp.NewTextContent("hello"), `{"type":"text","text":"hello"}`},
|
||||
|
|
@ -27,13 +27,13 @@ func TestContent(t *testing.T) {
|
|||
`{"type":"audio","mimeType":"audio/wav","data":"YTFiMmMz"}`,
|
||||
},
|
||||
{
|
||||
mcp.NewResourceContent(
|
||||
mcp.NewResourceContents(
|
||||
mcp.NewTextResourceContents("file://foo", "text", "abc"),
|
||||
),
|
||||
`{"type":"resource","resource":{"uri":"file://foo","mimeType":"text","text":"abc"}}`,
|
||||
},
|
||||
{
|
||||
mcp.NewResourceContent(
|
||||
mcp.NewResourceContents(
|
||||
mcp.NewBlobResourceContents("file://foo", "image/png", []byte("a1b2c3")),
|
||||
),
|
||||
`{"type":"resource","resource":{"uri":"file://foo","mimeType":"image/png","blob":"YTFiMmMz"}}`,
|
||||
|
|
@ -48,7 +48,7 @@ func TestContent(t *testing.T) {
|
|||
if diff := cmp.Diff(test.want, string(got)); diff != "" {
|
||||
t.Errorf("json.Marshal(%v) mismatch (-want +got):\n%s", test.in, diff)
|
||||
}
|
||||
var out *mcp.Content
|
||||
var out *mcp.ContentBlock
|
||||
if err := json.Unmarshal(got, &out); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue