Skip to content

A policy denial is not a request to prompt the user and try again - #90

Merged
blakebauman merged 1 commit into
mainfrom
fix/error-codes-outside-reserved-range
Aug 26, 2026
Merged

blakebauman merged 1 commit into
mainfrom
fix/error-codes-outside-reserved-range

Conversation

@blakebauman

Copy link
Copy Markdown
Member

Found by running /spec-drift against 2026-07-28 — the first time it has been run. This is the top finding of that sweep; the rest are summarised at the bottom.

The protocol reserved the range fold's codes were in

-32020 to -32099 — reserved for the MCP specification. Implementations MUST NOT emit any code from this sub-range that is not defined by this specification

-32000 to -32019 — legacy. New codes MUST NOT be allocated in this sub-range

fold minted five codes in the middle of the reserved band (-32040–-32044) and one in the legacy band (-32002). The specification's own instruction is to allocate outside the JSON-RPC reserved range entirely, so that is where they went. Only the thousands digit moved, which keeps the migration mechanical:

Was Now Meaning
-32040 -31040 Per-upstream rate limit exceeded
-32041 -31041 Upstream unavailable
-32042 -31042 Policy denied the invocation
-32043 -31043 Unknown namespace
-32044 -31044 Consumption budget exhausted
-32002 -31045 Task id owned by no upstream

-32042 is why this could not wait for a major version

The specification has already given that number a meaning — URL elicitation required — and the SDK fold links against acts on it. Verified in [email protected]:

  • mcp/shared.go:398 — CodeURLElicitationRequired = -32042
  • mcp/client.go:780 — middleware matching that code, which parses error.data.elicitations, invokes the client's ElicitationHandler, and retries the request

So a fold policy denial reaching such a client is not surfaced as a denial. Its user is prompted for an out-of-band interaction that does not exist, and the call fold refused is tried again. A deny-by-default gateway whose refusals become prompts and retries is not a cosmetic conformance gap.

Contained today only by an accident of Go: urlElicitationMiddleware is unexported, with a TODO: Consider exporting this sitting next to it, and no other language's SDK is bound by Go's export rules.

-32002 was wrong more quietly — the revision defines it as "resource not found" and tells clients to keep honouring it from older servers, so an unowned task id read as a missing resource from a legacy server.

This breaks the v1 contract, deliberately

Minted error codes are frozen by API stability. This changes them in a minor release.

It is the same trade v1.9.0 took and for the reason that release wrote down: there are no users to protect yet, and taking the break now rather than after launch is the honest choice. Confirmed with the maintainer before making it. README records the break beside that precedent rather than leaving the contract looking unbroken.

Nothing else about the errors moved — same messages, same data (including missingScopes), same audit outcomes. Changelog entries for released versions keep the codes they shipped with, because they describe what those releases did; only the Unreleased section was updated, since it ships alongside this.

Verification

  • go test -race ./... green; lint 0 issues; gofmt / vet / tidy clean
  • conformance 40/40; bench 0.193 ms added p50
  • 78 references across 28 files, all updated except the four in released changelog sections

The rest of the sweep — not in this PR

Recorded here so it is not lost; I would take them in this order:

  1. fold drops inputResponses and requestState when forwarding (router.go:329, :406, :545). The spec: clients MUST echo requestState exactly. Stripping it makes the upstream re-prompt, spinning to the SDK's 10-retry ceiling — ten round trips and ten human prompts per call. Three lines.
  2. The bridged-session apparatus is a legacy-era compatibility layer. MRTR removed server-initiated requests — not deprecated, removed. Sampling and roots are deprecated to 2027-07-28; elicitation survives only via MRTR. Roadmap item 13's premise moved: the governance point is no longer a handler on a bridged session but an inspection of inputRequests in a relayed result. docs/design-server-initiated.md §8 needs rewriting before that item is built.
  3. The modern era is reachable through fold today via per-request _meta, so 1 and 2 are live rather than hypothetical — and the existing canary in listen_test.go looks like it covers this and does not. A canary is needed.
  4. Mcp-Param-* headers are not forwarded, which the spec requires of intermediaries by name.
  5. Docs: upstream ttlMs is discarded, extensions unadvertised, two federated task methods the extension deleted, and the deprecation windows — none of which docs/roadmap.md mentions.

🤖 Generated with Claude Code

The 2026-07-28 revision partitioned the JSON-RPC server-error space.
-32020..-32099 is "reserved for the MCP specification", which
implementations "MUST NOT emit ... [any code] that is not defined by
this specification", and -32000..-32019 is legacy, where "new codes MUST
NOT be allocated". fold minted five codes in the middle of the reserved
band and one in the legacy band, so the whole set had to move; the
specification's own instruction is to allocate outside the reserved
range entirely.

Only the thousands digit changed, which keeps the migration mechanical:
-32040 -> -31040, -32041 -> -31041, -32042 -> -31042, -32043 -> -31043,
-32044 -> -31044, and -32002 -> -31045.

-32042 is why this could not wait for a major version. The
specification has already given that number a meaning — URL elicitation
required — and the SDK fold links against acts on it: mcp/client.go
matches CodeURLElicitationRequired, parses elicitations out of the error
data, calls the client's elicitation handler, and retries the request.
A fold policy denial arriving at such a client is therefore not read as
a denial. Its user is prompted for an out-of-band interaction that does
not exist, and the call fold refused is tried again. A deny-by-default
gateway whose refusals become prompts and retries is not a cosmetic
conformance gap. The middleware is unexported in the SDK today and one
TODO away from not being, and no other language's SDK is bound by Go's
export rules.

-32002 was wrong more quietly. The revision defines it as "resource not
found" and tells clients to keep honouring it from servers on older
versions, so fold answering it for a task id no upstream owns read as a
missing resource from a legacy server rather than as what it was.

Minted error codes are frozen by the v1 contract and this breaks that
freeze in a minor release. It is the same trade v1.9.0 took, for the
same reason it wrote down: there are no users to protect yet, and taking
the break now rather than after launch is the honest choice. README
records it beside that precedent rather than leaving the contract
looking unbroken.

Nothing else about the errors moved — same messages, same data, same
audit outcomes. Changelog entries for released versions keep the codes
they shipped with, because they are describing what those releases did.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@blakebauman
blakebauman merged commit 20ad0ef into main Aug 26, 2026
8 checks passed
@blakebauman
blakebauman deleted the fix/error-codes-outside-reserved-range branch August 26, 2026 01:45
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.

1 participant