fix: accept omitted prompt arguments#2107
Open
pragnyanramtha wants to merge 1 commit into
Open
Conversation
🦋 Changeset detectedLatest commit: a1dba81 The changes in this PR will be included in the next version bump. This PR includes changesets to release 5 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/fastify
@modelcontextprotocol/hono
@modelcontextprotocol/node
commit: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
prompts/getarguments to{}before prompt argument schema validationRoot cause
prompts/getpassesrequest.params.argumentsthrough to the registered prompt handler. Whenargumentsis omitted,createPromptHandlervalidatedundefinedagainst the prompt's object schema, so all-optional object schemas still failed at the top level. The tools path already normalizes omitted arguments withargs ?? {}; this applies the same behavior to prompts.Addresses the main-branch prompt portion of #1869. I did not include
v1.xbackport changes in this PR.Related prior work: this revives the same main-branch behavior targeted by closed, unmerged #1921.
Validation
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.tspnpm --filter @modelcontextprotocol/server typecheckpnpm --filter @modelcontextprotocol/server lintpnpm --filter @modelcontextprotocol/test-integration lint@modelcontextprotocol/test-helperslint reports existingvitestextraneous dependency errors intest/helpers/src/helpers/http.tsandtest/helpers/src/helpers/oauth.ts.@modelcontextprotocol/nodebuild OOMs with the default Node heap, but passes withNODE_OPTIONS=--max-old-space-size=4096 pnpm --filter @modelcontextprotocol/node build.CI note: Node 20
test (20)currently fails in unrelatedtest/server/cloudflareWorkers.test.tswith a MiniflareNetwork connection lost; the changedtest/server/mcp.test.tssuite passed in that same run. I do not have permission to rerun the failed job.