Skip to content

fix(server): support two-arg no-schema task handlers#2009

Open
Genmin wants to merge 2 commits intomodelcontextprotocol:mainfrom
Genmin:fix/register-tool-task-args
Open

fix(server): support two-arg no-schema task handlers#2009
Genmin wants to merge 2 commits intomodelcontextprotocol:mainfrom
Genmin:fix/register-tool-task-args

Conversation

@Genmin
Copy link
Copy Markdown

@Genmin Genmin commented May 1, 2026

What changed

Fixes #1471 by allowing no-input-schema task handlers to receive task context as the second argument when they are written in the common (_args, ctx) form.

The executor still preserves the existing context-only (ctx) path for no-schema handlers, so current TypeScript users are not forced into a breaking runtime change. The public task handler types now accept either no-schema shape, while schema-backed handlers remain (args, ctx) as before.

Why

registerToolTask currently calls no-schema createTask handlers with a single context argument. JavaScript users, or users bypassing types, can naturally write async createTask(_args, ctx), which previously received ctx as undefined and failed before creating a task.

Validation

  • pnpm --filter @modelcontextprotocol/server exec vitest run test/server/mcp.tasks.test.ts
  • pnpm --filter @modelcontextprotocol/server typecheck
  • pnpm --filter @modelcontextprotocol/server lint
  • pre-push hook: pnpm -r typecheck, pnpm -r build, pnpm sync:snippets --check, pnpm -r lint

@Genmin Genmin requested a review from a team as a code owner May 1, 2026 18:33
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 1, 2026

🦋 Changeset detected

Latest commit: 4411b7e

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 5 packages
Name Type
@modelcontextprotocol/server Patch
@modelcontextprotocol/express Patch
@modelcontextprotocol/fastify Patch
@modelcontextprotocol/hono Patch
@modelcontextprotocol/node Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented May 1, 2026

Open in StackBlitz

@modelcontextprotocol/client

npm i https://pkg.pr.new/@modelcontextprotocol/client@2009

@modelcontextprotocol/server

npm i https://pkg.pr.new/@modelcontextprotocol/server@2009

@modelcontextprotocol/express

npm i https://pkg.pr.new/@modelcontextprotocol/express@2009

@modelcontextprotocol/fastify

npm i https://pkg.pr.new/@modelcontextprotocol/fastify@2009

@modelcontextprotocol/hono

npm i https://pkg.pr.new/@modelcontextprotocol/hono@2009

@modelcontextprotocol/node

npm i https://pkg.pr.new/@modelcontextprotocol/node@2009

commit: 4411b7e

@Genmin
Copy link
Copy Markdown
Author

Genmin commented May 1, 2026

Pushed a focused follow-up for the build failure. The no-schema task callback helper is now inlined into the exported handler aliases so TypeDoc no longer sees a private referenced type.

Validation:

  • pnpm run docs:check
  • pnpm --filter @modelcontextprotocol/server typecheck
  • pnpm --filter @modelcontextprotocol/server lint
  • pnpm --filter @modelcontextprotocol/server test -- --run packages/server/test/server/mcp.tasks.test.ts
  • pre-push hook: build, lint, typecheck all passed

@Genmin
Copy link
Copy Markdown
Author

Genmin commented May 1, 2026

Checked the remaining failing job. The Deno runtime check is failing before repo install/test execution while denoland/setup-deno downloads Deno v2.7.14 from GitHub releases:

Unexpected HTTP response: 500

All repo build/typecheck/lint/test jobs are green after the follow-up commit, so this looks transient/infrastructure rather than a code failure.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

registerToolTask handlers receive wrong arguments when inputSchema is omitted

1 participant