You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
When registering a tool with a schema, consisting of all optional fields, some models will try calling the tool without supplying arguments in the request. This, however, fails validation because the zod object being created is non-optional:
Not sure if this is an issue with the server itself or the agent calling it, but would be nice if there was a way to give a hint to the model that the argument field is required for that particular tool.
To Reproduce
Unfortunately, this doesn't reproduce with all models/agents, but we've seen it happen somewhat consistently with Windsurf.
Steps to reproduce the behavior:
Register a tool with an all-optional schema:
server.tool("fetch-records","Fetches database records",{limit: z.number().optional().describe("The number of records to fetch. Default is 20.")},({ limit })=>{return{content: [{type: "text",text: `Fetched ${limit??20} records`}],};});
Ask the agent to call the tool.
Observe the agent receiving MCP error -32602: Invalid arguments for tool [...] "expected": "object", "received": "undefined", "path": []
Expected behavior
I guess I would expect the protocol to be more explicit about when fields are required vs when they're not, or alternatively, we could fallback to an empty object when arguments is not provided in the request, but expected due to the tool schema.
The text was updated successfully, but these errors were encountered:
Describe the bug
When registering a tool with a schema, consisting of all optional fields, some models will try calling the tool without supplying
arguments
in the request. This, however, fails validation because the zod object being created is non-optional:typescript-sdk/src/server/mcp.ts
Line 705 in 1317767
Not sure if this is an issue with the server itself or the agent calling it, but would be nice if there was a way to give a hint to the model that the argument field is required for that particular tool.
To Reproduce
Unfortunately, this doesn't reproduce with all models/agents, but we've seen it happen somewhat consistently with Windsurf.
Steps to reproduce the behavior:
MCP error -32602: Invalid arguments for tool [...] "expected": "object", "received": "undefined", "path": []
Expected behavior
I guess I would expect the protocol to be more explicit about when fields are required vs when they're not, or alternatively, we could fallback to an empty object when
arguments
is not provided in the request, but expected due to the tool schema.The text was updated successfully, but these errors were encountered: