File tree Expand file tree Collapse file tree 1 file changed +6
-0
lines changed Expand file tree Collapse file tree 1 file changed +6
-0
lines changed Original file line number Diff line number Diff line change @@ -34,6 +34,12 @@ export class Server {
34
34
this . registerTools ( ) ;
35
35
this . registerResources ( ) ;
36
36
37
+ // This is a workaround for an issue we've seen with some models, where they'll see that everything in the `arguments`
38
+ // object is optional, and then not pass it at all. However, the MCP server expects the `arguments` object to be if
39
+ // the tool accepts any arguments, even if they're all optional.
40
+ //
41
+ // see: https://github.com/modelcontextprotocol/typescript-sdk/blob/131776764536b5fdca642df51230a3746fb4ade0/src/server/mcp.ts#L705
42
+ // Since paramsSchema here is not undefined, the server will create a non-optional z.object from it.
37
43
const existingHandler = this . mcpServer . server [ "_requestHandlers" ] . get ( CallToolRequestSchema . shape . method . value ) ;
38
44
this . mcpServer . server . setRequestHandler ( CallToolRequestSchema , ( request , extra ) : Promise < CallToolResult > => {
39
45
if ( ! request . params . arguments ) {
You can’t perform that action at this time.
0 commit comments