Skip to content

fix: answer -32602 when a prompt is requested without a required argument - #390

Merged
punkpeye merged 1 commit into
punkpeye:mainfrom
fadiroot:fix/prompt-missing-argument-code
Sep 24, 2026
Merged

punkpeye merged 1 commit into
punkpeye:mainfrom
fadiroot:fix/prompt-missing-argument-code

Conversation

@fadiroot

Copy link
Copy Markdown
Contributor

Problem

prompts/get for a prompt that declares a required argument, called without that argument, rejects with -32600 Invalid request:

server.addPrompt({
  name: "git-commit",
  arguments: [{ name: "changes", required: true }],
  load: async ({ changes }) => `Commit: ${changes}`,
});
await client.getPrompt({ name: "git-commit" }); // McpError code -32600

The MCP specification's error handling section for prompts says:

Missing required arguments: -32602 (Invalid params)

The request is well-formed; its params are what's wrong. tools/call already answers ErrorCode.InvalidParams for argument validation, so this also makes the two consistent.

Fix

Use ErrorCode.InvalidParams for the missing-required-argument check in the prompts/get handler. The message is unchanged.

Tests

src/FastMCP.prompt-arguments.test.ts (in-memory transport): asserts the error code and message for the missing argument, and that the same prompt still loads when the argument is present. It fails on main and passes with this change. prettier, eslint and tsc --noEmit are clean.

…ment

The MCP specification's error handling section for prompts lists
"Missing required arguments: -32602 (Invalid params)". `prompts/get`
answered `-32600 Invalid request` instead. The request itself is
well-formed; it is the params that are wrong, and `tools/call` already
uses `ErrorCode.InvalidParams` for argument validation.
@fadiroot

Copy link
Copy Markdown
Contributor Author

The OpenAPI (network) failure here is the Stripe spec hash drift (stripe.json does not match its pinned hash), not this change; #391 re-pins it. The Test job passes.

@punkpeye
punkpeye merged commit 25046a2 into punkpeye:main Sep 24, 2026
1 of 2 checks passed
@github-actions

Copy link
Copy Markdown

🎉 This PR is included in version 4.20.17 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants