Skip to content

Commit ab4f604

Browse files
committed
add a comment explaining the workaround
1 parent 8445e3b commit ab4f604

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/server.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@ export class Server {
3434
this.registerTools();
3535
this.registerResources();
3636

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.
3743
const existingHandler = this.mcpServer.server["_requestHandlers"].get(CallToolRequestSchema.shape.method.value);
3844
this.mcpServer.server.setRequestHandler(CallToolRequestSchema, (request, extra): Promise<CallToolResult> => {
3945
if (!request.params.arguments) {

0 commit comments

Comments
 (0)