go-sdk/examples/server/toolschemas/main_test.go
Jonathan Amsterdam 33ff851ef3
mcp: update to jsonschema that does not validate structs (#511)
Update to the latest jsonschema commit, which removes the ability to
validate structs and changes the type of ForOptions.TypeSchemas.
2025-09-22 15:28:04 -04:00

31 lines
672 B
Go

// Copyright 2025 The Go MCP SDK Authors. All rights reserved.
// Use of this source code is governed by an MIT-style
// license that can be found in the LICENSE file.
package main
import (
"context"
"encoding/json"
"testing"
"github.com/modelcontextprotocol/go-sdk/mcp"
)
func TestGreet(t *testing.T) {
manual, err := newManualGreeter()
if err != nil {
t.Fatal(err)
}
res, err := manual.greet(context.Background(), &mcp.CallToolRequest{
Params: &mcp.CallToolParamsRaw{
Arguments: json.RawMessage(`{"name": "Bob"}`),
},
})
if err != nil {
t.Fatal(err)
}
if res.IsError {
t.Fatalf("tool error: %q", res.Content[0].(*mcp.TextContent).Text)
}
}