-
Notifications
You must be signed in to change notification settings - Fork 1.8k
registerToolTask handlers receive wrong arguments when inputSchema is omitted #1471
Copy link
Copy link
Open
Open
Copy link
Labels
P2Moderate issues affecting some users, edge cases, potentially valuable featureModerate issues affecting some users, edge cases, potentially valuable featurebugSomething isn't workingSomething isn't workingfix proposedBot has a verified fix diff in the commentBot has a verified fix diff in the commentready for workEnough information for someone to start working onEnough information for someone to start working onv2Ideas, requests and plans for v2 of the SDK which will incorporate major changes and fixesIdeas, requests and plans for v2 of the SDK which will incorporate major changes and fixes
Metadata
Metadata
Assignees
Labels
P2Moderate issues affecting some users, edge cases, potentially valuable featureModerate issues affecting some users, edge cases, potentially valuable featurebugSomething isn't workingSomething isn't workingfix proposedBot has a verified fix diff in the commentBot has a verified fix diff in the commentready for workEnough information for someone to start working onEnough information for someone to start working onv2Ideas, requests and plans for v2 of the SDK which will incorporate major changes and fixesIdeas, requests and plans for v2 of the SDK which will incorporate major changes and fixes
Summary
When using
registerToolTaskwithout providing aninputSchema, handlers that expect two arguments(args, extra)receiveextraas undefined because the executor only passes one argument.Reproduction
Root Cause
In
createToolExecutor(packages/server/src/server/mcp.ts), wheninputSchemais undefined, the executor calls the handler with only one argument:When a handler is defined as
async createTask(_args, extra), JavaScript will:handler(extra):_args = extra,extra = undefinedhandler(parsedArgs, extra):_args = parsedArgs,extra = extra✓Workaround
Always provide
inputSchema: z.object({})even for tools that don't require arguments:Potential Solutions
handler({}, extra)when inputSchema is undefinedinputSchemamust be provided when using two-argument handler signaturesEnvironment
registerToolTaskin experimental tasks API