Repository navigation
Reallocate rate-limit error code to 429 - #6120
Merged
Merged
Conversation
The MCP 2026-07-28 revision, published today, partitions the JSON-RPC implementation-defined range: -32020..-32099 is now reserved exclusively for spec-defined codes, making ToolHive's CodeRateLimited (-32029) non-conformant. The same revision directs application codes outside the JSON-RPC reserved range (-32768..-32000), where they are equally legal under 2025-11-25 and earlier (plain JSON-RPC 2.0), so one code stays conformant across every revision without version branching. 429 mirrors HTTP Too Many Requests, matching the existing precedent of JSONRPCCodeDenied (403). Wire-visible change: clients pattern-matching -32029 must switch to 429; data.retryAfterSeconds is unchanged. Closes #6101 Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01W1kKpsGZTfSgKBi8GdTZXR
JAORMX
requested review from
ChrisJBurns,
amirejaz,
aponcedeleonch,
blkt,
jerm-dro,
jhrozek,
rdimitrov,
reyortiz3 and
tgrunnagle
as code owners
July 28, 2026 16:33
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #6120 +/- ##
==========================================
- Coverage 72.48% 72.42% -0.06%
==========================================
Files 733 733
Lines 75842 75856 +14
==========================================
- Hits 54971 54939 -32
- Misses 16960 17027 +67
+ Partials 3911 3890 -21 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
aponcedeleonch
approved these changes
Jul 28, 2026
1 task
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
The MCP 2026-07-28 revision published today and partitions the JSON-RPC implementation-defined server-error range (Error Codes, verified live):
-32020..-32099is reserved exclusively for spec-defined codes (only-32020HeaderMismatch,-32021MissingRequiredClientCapability,-32022UnsupportedProtocolVersion are defined), and implementations MUST NOT emit undefined codes from that band. ToolHive'sCodeRateLimited = -32029is therefore non-conformant; it was chosen (RFC THV-0057) when-32000..-32099was uniformly implementation-defined.The reallocation keeps ToolHive conformant with both eras with a single code and no version branching:
-32768..-32000) —429complies.-32768..-32000application-defined —429is equally legal, and no earlier revision ever defined a rate-limit code, so old-era clients have no spec-based expectation of-32029. (Version branching would also be impossible in the HTTP middleware, which runs before protocol parsing.)What changed:
CodeRateLimitedis now429, mirroring HTTP Too Many Requests — the same pattern as the existingJSONRPCCodeDenied = 403(pkg/mcp/errors.go), which is positive-code precedent already shipped in production.data.retryAfterSecondsis unchanged (errordata"MAY include a data member with additional information of any type" in every revision).Also audited every other custom code ToolHive emits against the new partition:
-32001(SessionNotFound) and the streamable proxy's-32000fallback sit in-32000..-32019, which 2026-07-28 explicitly grandfathers as legacy — and both are legacy-transport-only paths (the new revision removes sessions entirely), so they are conformant as-is.-32020/-32021/-32022are used with their spec meanings.Closes #6101
Type of change
Test plan
task test) —pkg/ratelimitandpkg/vmcp/serverpass; the only failures are two pre-existingpkg/apitests requiring a container runtime unavailable in the sandboxtask test-e2e)task lint-fix) — 0 issuesDoes this introduce a user-facing change?
Yes. The JSON-RPC error code for rate-limited requests changes from
-32029to429on every surface that carries it: the HTTP 429 response body from the ratelimit middleware, the vMCP Modern dispatch path's JSON-RPC error object, and the Legacy path'sIsErrortool-resultstructuredContent. Clients pattern-matching-32029must switch to429;data.retryAfterSecondsand theRetry-Afterheader are unchanged.Special notes for reviewers
429allocation.pkg/mcp/revision.gocomments still say "draft MCP spec" throughout — the revision shipped today as2026-07-28, and the wording could be updated.Generated with Claude Code
🤖 Generated with Claude Code
https://claude.ai/code/session_01W1kKpsGZTfSgKBi8GdTZXR