-
Notifications
You must be signed in to change notification settings - Fork 334
Closed
google/jsonschema-go
#9Description
Describe the bug
After updating from v0.2.0 to v0.3.0 of this library I noticed that arguments of type array now get a description for their items which was not the case before. However, I am not setting that description on purpose. It seems to be taken from the description of the first argument in this example which is an issue as the field is completely unrelated to the array and confuses the LLM that reads those descriptions.
I would expect either:
- the description not to be set for array items as before
- an option to define a correct description for array items
If this should rather go to github.com/google/jsonschema-go, please let me know.
To Reproduce
Minimal example:
package main
import (
"context"
"flag"
"log"
"net/http"
"os"
"github.com/modelcontextprotocol/go-sdk/mcp"
)
var httpAddr = flag.String("http", "", "if set, use streamable HTTP at this address, instead of stdin/stdout")
func main() {
flag.Parse()
server := mcp.NewServer(&mcp.Implementation{Name: "everything"}, nil)
mcp.AddTool(server, &mcp.Tool{Name: "greet", Description: "say hi"}, contentTool)
if *httpAddr != "" {
handler := mcp.NewStreamableHTTPHandler(
func(*http.Request) *mcp.Server {
return server
}, nil,
)
log.Printf("MCP handler listening at %s", *httpAddr)
http.ListenAndServe(*httpAddr, handler)
} else {
t := &mcp.LoggingTransport{Transport: &mcp.StdioTransport{}, Writer: os.Stderr}
if err := server.Run(context.Background(), t); err != nil {
log.Printf("Server failed: %v", err)
}
}
}
type args struct {
SomeString string `json:"someString" jsonschema:"A random string"`
SomeArray []string `json:"someArray" jsonschema:"An array of strings"`
SomeOtherString string `json:"someOtherString" jsonschema:"Another random string"`
SomeOtherArray []string `json:"someOtherArray" jsonschema:"Another array of strings"`
SomeDifferentString string `json:"someDifferentString" jsonschema:"A different random string"`
}
func contentTool(ctx context.Context, req *mcp.CallToolRequest, args args) (*mcp.CallToolResult, any, error) {
return &mcp.CallToolResult{
Content: []mcp.Content{
&mcp.TextContent{Text: "Something"},
},
}, nil, nil
}Steps to reproduce the behavior:
- Run the example above
- Perform
tools/listcall - Look at the inputSchema -> there is a description set for the array items
Expected behavior
No description for the array items should be set.
Additional context
I am using the latest release v0.3.0 of this library.
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working