Skip to content

mcp: add param check for CompleteResult - #1080

Merged
guglielmo-san merged 2 commits into
mainfrom
fix/complete-required-params
Jul 13, 2026
Merged

guglielmo-san merged 2 commits into
mainfrom
fix/complete-required-params

Conversation

@guglielmo-san

Copy link
Copy Markdown
Contributor

Fixes #1071

@guglielmo-san
guglielmo-san enabled auto-merge (squash) July 13, 2026 12:13
@guglielmo-san
guglielmo-san merged commit c79a30a into main Jul 13, 2026
9 of 10 checks passed
@guglielmo-san
guglielmo-san deleted the fix/complete-required-params branch July 13, 2026 12:14
guglielmo-san pushed a commit that referenced this pull request Sep 28, 2026
Fixes #1296.

`Server.getPrompt` now returns `-32602` when an argument the prompt
declares as required is missing from the request, before calling the
handler. The spec asks for this (server/prompts, "Error Handling":
missing required arguments, `-32602`, in 2025-11-25 and 2026-07-28), and
it saves every handler from repeating the check. A required argument
that is present but empty still reaches the handler, and a nil entry in
`Prompt.Arguments` is skipped as before. The `AddPrompt` doc comment now
says that `Required` is enforced.

As #1080 did for `completion/complete`,
`MCPGODEBUG=disablepromptargsvalidation=1` restores the old behavior. It
is documented in the 1.9.0 section of `docs/mcpgodebug.md`; `go
generate` updated it.

`TestGetPromptRequiresDeclaredArguments` covers these cases:

- a missing required argument, which fails without the change;
- an empty required argument;
- a missing optional argument;
- a nil entry in `Prompt.Arguments`;
- the MCPGODEBUG opt-out, set the way the other switches' tests set
theirs.

The conformance server suites give the same results as on main. On
2025-11-25 every scenario passes. On 2026-07-28 only the tasks scenarios
fail, which this SDK does not implement yet.
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.

Several request handlers accept params objects with missing required fields

2 participants