Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/fix-register-tool-task-args.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@modelcontextprotocol/server': patch
---

Fix `registerToolTask` to pass empty args object to `createTask` handler when no `inputSchema` is provided, allowing two-argument `(args, ctx)` handler signatures to work correctly.
6 changes: 3 additions & 3 deletions packages/server/src/server/mcp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1042,10 +1042,10 @@ function createToolExecutor(inputSchema: AnySchema | undefined, handler: AnyTool
throw new Error('No task store provided.');
}
const taskCtx: CreateTaskServerContext = { ...ctx, task: { store: ctx.task.store, requestedTtl: ctx.task?.requestedTtl } };
if (inputSchema) {
return taskHandler.createTask(args, taskCtx);
if (inputSchema || taskHandler.createTask.length > 1) {
return taskHandler.createTask(inputSchema ? args : {}, taskCtx);
}
// When no inputSchema, call with just ctx (the handler expects (ctx) signature)
// When no inputSchema and handler expects single arg, call with just ctx
return (taskHandler.createTask as (ctx: CreateTaskServerContext) => CreateTaskResult | Promise<CreateTaskResult>)(taskCtx);
};
}
Expand Down
Loading