-
Notifications
You must be signed in to change notification settings - Fork 273
Closed
Description
It's unclear if CallToolResult.StructuredContent should ever be used vs just returning the generic type.
For example, the following code works fine:
(1)
type SessionsResult struct {
Sessions []Session `json:"sessions"`
}
func ListSessions(ctx context.Context, _ *mcp.CallToolRequest, _ any) (*mcp.CallToolResult, SessionsResult, error) {
return nil, SessionsResult{Sessions: sessions()}, nil
}The following used to work in the previous version of the code, but now causes an error in Cursor when testing:
(2)
type SessionsResult struct {
Sessions []Session `json:"sessions"`
}
func ListSessions(ctx context.Context, _ *mcp.CallToolRequest, _ any) (*mcp.CallToolResult, SessionsResult, error) {
return &mcp.CallToolResult{
StructuredContent: SessionsResult{Sessions: sessions()},
}, SessionsResult{}, nil
}which yields the following error message:
"error":"MCP error -32602: Structured content does not match the tool's output schema: data.sessions should be array"
I think (1) is pretty clear, but with the latest version, v0.3.1, I'm not sure if there's a use case for StructuredContent anymore. I don't see any examples in this repo which show when it would be needed either. Should StructuredContent just be removed as a return field?
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working