Repository navigation
fix: pass empty args to registerToolTask handler when no inputSchema - #1509
corvid-agent wants to merge 1 commit into
Conversation
🦋 Changeset detectedLatest commit: 16ff78a The changes in this PR will be included in the next version bump. This PR includes changesets to release 4 packages
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 |
@modelcontextprotocol/client
@modelcontextprotocol/server
@modelcontextprotocol/express
@modelcontextprotocol/hono
@modelcontextprotocol/node
commit: |
…nputSchema
When registerToolTask is used without inputSchema, the createTask handler
should receive an empty object as its first argument when the handler
expects two arguments (args, ctx). This fixes the case where users define
a two-argument handler but omit inputSchema - previously the second
argument (ctx) would be passed as the first argument instead.
Uses Function.length to detect handler arity: single-arg handlers
continue to receive just ctx, while two-arg handlers get ({}, ctx).
Closes modelcontextprotocol#1471
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
f144732 to
16ff78a
Compare
felixweinberger
left a comment
There was a problem hiding this comment.
Thanks for this find - we shouldn't use Function.length to determine what state we're in, if we want to cleanly support this we should overload registerToolTask such that when inputSchema is absent it only accepts (ctx).
Want to refactor that instead of the runtime length check? Would also be great to have a test.
|
@claude review |
This comment was marked as abuse.
This comment was marked as abuse.
|
Thanks for the PR. v2 removed |
Summary
registerToolTaskto correctly pass({}, ctx)tocreateTaskhandlers that use a two-argument(args, ctx)signature when noinputSchemais providedFunction.lengthto detect handler arity: single-arg(ctx)handlers continue working as before, while two-arg(args, ctx)handlers receive an empty object as the first argumentCloses #1471
Test plan
registerToolTasktests with both single-arg and two-arg patterns)pnpm build:all)🤖 Generated with Claude Code