Skip to content

fix: accept omitted prompt arguments#2107

Open
pragnyanramtha wants to merge 1 commit into
modelcontextprotocol:mainfrom
pragnyanramtha:codex/fix-omitted-prompt-arguments
Open

fix: accept omitted prompt arguments#2107
pragnyanramtha wants to merge 1 commit into
modelcontextprotocol:mainfrom
pragnyanramtha:codex/fix-omitted-prompt-arguments

Conversation

@pragnyanramtha
Copy link
Copy Markdown

@pragnyanramtha pragnyanramtha commented May 16, 2026

Summary

  • default omitted prompts/get arguments to {} before prompt argument schema validation
  • add a regression test for a prompt whose schema fields are all optional
  • add a server patch changeset

Root cause

prompts/get passes request.params.arguments through to the registered prompt handler. When arguments is omitted, createPromptHandler validated undefined against the prompt's object schema, so all-optional object schemas still failed at the top level. The tools path already normalizes omitted arguments with args ?? {}; this applies the same behavior to prompts.

Addresses the main-branch prompt portion of #1869. I did not include v1.x backport changes in this PR.

Related prior work: this revives the same main-branch behavior targeted by closed, unmerged #1921.

Validation

  • Added regression test and verified it failed before the handler fix.
  • pnpm --dir test/integration exec vitest run test/server/mcp.test.ts -t "should accept omitted prompt arguments"
  • pnpm --dir test/integration exec vitest run test/server/mcp.test.ts
  • pnpm --filter @modelcontextprotocol/server typecheck
  • pnpm --filter @modelcontextprotocol/server lint
  • pnpm --filter @modelcontextprotocol/test-integration lint
  • Full pre-push hook: typecheck passed; repo-wide lint/build did not complete due unrelated existing issues:
    • @modelcontextprotocol/test-helpers lint reports existing vitest extraneous dependency errors in test/helpers/src/helpers/http.ts and test/helpers/src/helpers/oauth.ts.
    • @modelcontextprotocol/node build OOMs with the default Node heap, but passes with NODE_OPTIONS=--max-old-space-size=4096 pnpm --filter @modelcontextprotocol/node build.

CI note: Node 20 test (20) currently fails in unrelated test/server/cloudflareWorkers.test.ts with a Miniflare Network connection lost; the changed test/server/mcp.test.ts suite passed in that same run. I do not have permission to rerun the failed job.

Copilot AI review requested due to automatic review settings May 16, 2026 07:15
@pragnyanramtha pragnyanramtha requested a review from a team as a code owner May 16, 2026 07:15
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 16, 2026

🦋 Changeset detected

Latest commit: a1dba81

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 16, 2026

Open in StackBlitz

@modelcontextprotocol/client

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

@modelcontextprotocol/server

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

@modelcontextprotocol/express

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

@modelcontextprotocol/fastify

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

@modelcontextprotocol/hono

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

@modelcontextprotocol/node

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

commit: a1dba81

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

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.

2 participants