Repository navigation
Description
Bug description
In ToolHive v0.41.0, the MCP revision classifier hard-rejects any non-initialize request that simultaneously (a) carries at least one reserved _meta signal key (io.modelcontextprotocol/protocolVersion, io.modelcontextprotocol/clientInfo, or io.modelcontextprotocol/clientCapabilities), (b) does not carry a non-empty string _meta["io.modelcontextprotocol/protocolVersion"], and (c) arrives with a non-empty MCP-Protocol-Version header. The rejection is JSON-RPC error -32020 rendered as HTTP 400 before the backend is ever contacted.
Mechanism, verified at tag v0.41.0 (commit d722304):
pkg/mcp/revision.go:modernSignalMetaKeys(lines 129-133) lists the three reserved keys, andhasModernSignal(lines 575-585) treats the mere presence of any of them as a Modern signal — regardless of theMCP-Protocol-Versionheader and regardless of whether the key's value is well-formed.ClassifyRevision(lines 433-469) short-circuitsinitializeto Legacy (lines 434-436). For every other method with a Modern signal,stringMetaValue(line 442) requires the_metaprotocolVersion to be a non-empty string; when it is absent (or an empty string) and the header is non-empty, lines 443-445 returnRevisionModern, &HeaderMismatchError{Header: protoHeader, Body: ""}. The wire code isCodeHeaderMismatch = -32020(line 219); the message format is at line 253.- The transparent proxy invokes the classifier unconditionally for every parsed single JSON-RPC request (
pkg/transport/proxy/transparent/transparent_proxy.go, line 619) and converts any classification error into an HTTP 400 JSON-RPC error response without contacting the backend (mcp.ClassificationErrorResponseinpkg/mcp/classification_response.go; the call site's own comment reads "Malformed Modern request: reject before the backend is ever contacted.").
Real-world consequence, observed live: the ChatGPT connector (user agent openai-mcp/1.0.0, client registered via CIMD with a URL client_id) negotiates MCP protocol 2025-11-25. Its initialize succeeds (exempt by the short-circuit) and tools/list succeeds, but its tools/call requests carry the MCP-Protocol-Version: 2025-11-25 header plus at least one reserved _meta signal key with no valid _meta protocolVersion — so every single tools/call is rejected in about 1 ms with exactly this user-visible error text, which ChatGPT surfaces to the end user:
MCP-Protocol-Version header "2025-11-25" does not match _meta protocol version ""
The server operator has no configuration escape: the check is unconditional in the proxy binary and the triggering value is inside the request body.
We understand this behavior is deliberate and pinned by a test (details in Additional context). This report argues that the design meets a real, arguably highest-profile MCP client and loses — and proposes a narrow adjustment that keeps Modern validation fully strict.
Steps to reproduce
The classifier is a pure exported function, so the defect reproduces deterministically without any deployment:
- Clone the repository at tag
v0.41.0(commit d722304). - Save the harness below as
cmd/repro-classifier/main.go. It imports only the exportedgithub.com/stacklok/toolhive/pkg/mcppackage;go.mod/go.sumstay untouched. - Run
go run ./cmd/repro-classifier.
// SPDX-FileCopyrightText: Copyright 2025 Stacklok, Inc.
// SPDX-License-Identifier: Apache-2.0
// Command repro-classifier is a minimal, throwaway reproduction of the
// ToolHive v0.41.0 revision classifier rejecting Legacy tools/call requests
// that carry a reserved _meta signal key without a valid _meta
// protocolVersion. It calls only the exported mcp.ClassifyRevision API.
package main
import (
"errors"
"fmt"
"github.com/stacklok/toolhive/pkg/mcp"
)
// codedError mirrors the CodedError interface implemented by the classifier's
// error types (HeaderMismatchError, UnsupportedVersionError, etc.) so this
// harness can extract the JSON-RPC error code without importing anything
// beyond the mcp package's exported error types.
type codedError interface {
error
Code() int64
}
func printVariant(label, description, method string, meta map[string]any, header string) {
rev, err := mcp.ClassifyRevision(method, meta, header)
fmt.Printf("=== Variant %s: %s ===\n", label, description)
fmt.Printf(" method: %q\n", method)
fmt.Printf(" meta: %#v\n", meta)
fmt.Printf(" protoHeader: %q\n", header)
fmt.Printf(" -> revision: %v\n", revisionName(rev))
if err == nil {
fmt.Printf(" -> error: <nil>\n")
} else {
fmt.Printf(" -> error: %v\n", err)
var ce codedError
if errors.As(err, &ce) {
fmt.Printf(" -> JSON-RPC code: %d\n", ce.Code())
} else {
fmt.Printf(" -> JSON-RPC code: <error does not implement CodedError>\n")
}
}
fmt.Println()
}
func revisionName(r mcp.Revision) string {
if r == mcp.RevisionModern {
return "RevisionModern"
}
return "RevisionLegacy"
}
func main() {
fmt.Println("ToolHive v0.41.0 pkg/mcp.ClassifyRevision minimal reproduction")
fmt.Println("================================================================")
fmt.Println()
// (A) Control: plain Legacy client, no _meta at all, Legacy header.
printVariant(
"A",
"plain Legacy client (no _meta, header 2025-11-25) — expect Legacy, nil",
"tools/call",
nil,
"2025-11-25",
)
// (B) The ChatGPT shape: a reserved _meta signal key (clientInfo) present,
// no _meta protocolVersion, Legacy header. This is the live-observed
// failure mode: tools/call rejected pre-backend.
printVariant(
"B",
"reserved _meta key (clientInfo) present, no protocolVersion, header 2025-11-25 — expect Modern + HeaderMismatchError -32020 (the ChatGPT shape)",
"tools/call",
map[string]any{
"io.modelcontextprotocol/clientInfo": map[string]any{"name": "x", "version": "1"},
},
"2025-11-25",
)
// (C) Empty-string protocolVersion variant: same rejection.
printVariant(
"C",
"_meta protocolVersion is empty string, header 2025-11-25 — expect same rejection (empty string variant)",
"tools/call",
map[string]any{
"io.modelcontextprotocol/protocolVersion": "",
},
"2025-11-25",
)
// (D) Control: well-formed Modern request works.
printVariant(
"D",
"well-formed Modern request (protocolVersion 2026-07-28, clientCapabilities {}), header 2026-07-28 — expect Modern, nil (control: well-formed Modern works)",
"tools/call",
map[string]any{
"io.modelcontextprotocol/protocolVersion": "2026-07-28",
"io.modelcontextprotocol/clientCapabilities": map[string]any{},
},
"2026-07-28",
)
// (E) Same reserved-key _meta as (B), but method is "initialize" — shows
// initialize is exempt, matching the observed initialize-succeeds/
// tools-call-fails pattern.
printVariant(
"E",
"initialize with the same B meta (clientInfo, no protocolVersion), header 2025-11-25 — expect Legacy, nil (initialize is exempt)",
"initialize",
map[string]any{
"io.modelcontextprotocol/clientInfo": map[string]any{"name": "x", "version": "1"},
},
"2025-11-25",
)
}For reference, the on-the-wire request shape that triggers the same rejection through the transparent proxy is a POST with the header MCP-Protocol-Version: 2025-11-25 and a body like:
{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "some_tool",
"arguments": {},
"_meta": {
"io.modelcontextprotocol/clientInfo": {"name": "x", "version": "1"}
}
}
}Which of the three reserved keys ChatGPT actually sends is not observable from the proxy logs (request bodies are not logged), but any of them triggers the same branch, as does "io.modelcontextprotocol/protocolVersion": "" (variant C).
Expected behavior
A request that explicitly names a Legacy revision in the MCP-Protocol-Version header and never claims any protocol version in the request body should classify Legacy and be proxied to the backend. Concretely: variants B and C below should behave like variant A (Legacy, nil), while strict Modern validation — including the hard header/body mismatch rejection — should continue to apply whenever _meta does declare a protocol version, as in variant D and in genuine header/body conflicts.
Actual behavior
Verbatim output of the harness at v0.41.0 (variant B is the ChatGPT shape):
ToolHive v0.41.0 pkg/mcp.ClassifyRevision minimal reproduction
================================================================
=== Variant A: plain Legacy client (no _meta, header 2025-11-25) — expect Legacy, nil ===
method: "tools/call"
meta: map[string]interface {}(nil)
protoHeader: "2025-11-25"
-> revision: RevisionLegacy
-> error: <nil>
=== Variant B: reserved _meta key (clientInfo) present, no protocolVersion, header 2025-11-25 — expect Modern + HeaderMismatchError -32020 (the ChatGPT shape) ===
method: "tools/call"
meta: map[string]interface {}{"io.modelcontextprotocol/clientInfo":map[string]interface {}{"name":"x", "version":"1"}}
protoHeader: "2025-11-25"
-> revision: RevisionModern
-> error: MCP-Protocol-Version header "2025-11-25" does not match _meta protocol version ""
-> JSON-RPC code: -32020
=== Variant C: _meta protocolVersion is empty string, header 2025-11-25 — expect same rejection (empty string variant) ===
method: "tools/call"
meta: map[string]interface {}{"io.modelcontextprotocol/protocolVersion":""}
protoHeader: "2025-11-25"
-> revision: RevisionModern
-> error: MCP-Protocol-Version header "2025-11-25" does not match _meta protocol version ""
-> JSON-RPC code: -32020
=== Variant D: well-formed Modern request (protocolVersion 2026-07-28, clientCapabilities {}), header 2026-07-28 — expect Modern, nil (control: well-formed Modern works) ===
method: "tools/call"
meta: map[string]interface {}{"io.modelcontextprotocol/clientCapabilities":map[string]interface {}{}, "io.modelcontextprotocol/protocolVersion":"2026-07-28"}
protoHeader: "2026-07-28"
-> revision: RevisionModern
-> error: <nil>
=== Variant E: initialize with the same B meta (clientInfo, no protocolVersion), header 2025-11-25 — expect Legacy, nil (initialize is exempt) ===
method: "initialize"
meta: map[string]interface {}{"io.modelcontextprotocol/clientInfo":map[string]interface {}{"name":"x", "version":"1"}}
protoHeader: "2025-11-25"
-> revision: RevisionLegacy
-> error: <nil>
Live, this means the ChatGPT connector connects, completes initialize, lists tools successfully — and then fails 100 percent of tool calls with a protocol error surfaced to the end user, with the backend never contacted.
Environment (if relevant)
- ToolHive v0.41.0. Behavior verified at tag
v0.41.0(commit d722304) and unchanged on currentmainas of 2026-08-04: the!hasBodyVersionbranch andmodernSignalMetaKeysare identical. - Deployment context where this was hit live: Kubernetes operator with the proxyrunner image. The reproduction above is deployment-independent (a pure function call into the exported
pkg/mcpAPI).
Additional context
The current behavior is deliberate — this report questions the design, not a regression
- The exact outcome is pinned by the test
modern signal via reserved key with non-modern header is a header mismatch(pkg/mcp/revision_test.go, line 293), which assertsRevisionModernplusHeaderMismatchErrorwith code -32020, header2025-11-25, and an empty body value, usingmetaKeyClientCapabilitiesas the trigger key (same family as theclientInfokey used in variant B). - PR Add MCP 2026-07-28 revision classification and method vocabulary #5834, which introduced
ClassifyRevision,hasModernSignal, the reserved-key signal list (then namedreservedModernMetaKeys), and the -32020/-32021/-32022 taxonomy, states in its own body that "any Modern signal ... forces a valid-or-error outcome" — the hard-reject-instead-of-downgrade behavior is by design, not a later regression. - The doc comment in
pkg/mcp/revision.go(lines 403-408) is explicit: presence of a reserved key is the signal "independent of whether its value is well-formed, since a Legacy client never sets these keys at all", and "A request with a signal is never silently downgraded: it either classifies Modern with a nil error, or Modern with an error the caller must reject on."
Why we think the design should bend here
Facts first, interpretation second. Facts: the released 2025-11-25 streamable-http spec defines the MCP-Protocol-Version header as carrying the protocol version negotiated during initialization; ChatGPT negotiates 2025-11-25, sends that header on every request, and still includes at least one reserved io.modelcontextprotocol/* key in _meta on tools/call; the classifier's stated premise that "a Legacy client never sets these keys at all" is therefore empirically false for at least one major first-party client.
Interpretation: a request that explicitly names a Legacy revision in the header and never claims a Modern one in the body is a Legacy request that happens to carry forward-compatible metadata keys — not a malformed Modern request. The SEP-2575 header/body match requirement applies to Modern requests; a request whose body declares no protocol version at all arguably is not one, so there is no genuine header/body conflict to reject: the current code manufactures a mismatch against an empty string (Body: ""), producing an error message about a value the client never sent.
Proposed direction: in the !hasBodyVersion branch of ClassifyRevision (lines 443-445), treat an explicit non-Modern MCP-Protocol-Version header as authoritative and classify the request Legacy, instead of returning HeaderMismatchError against an empty body value. Everything else stays exactly as strict as today: a request whose _meta DOES declare a protocol version keeps the current validation (unsupported version -> -32022; genuine header/body conflict -> -32020); a request whose only Modern signal is a reserved key with no header at all still returns MissingModernMetadataError; well-formed Modern requests (variant D) are unaffected. This would make real-world hybrid clients work without weakening Modern enforcement.
PR #6184 is precedent that this same classifier is already being tuned to accommodate real-world dual-era client behavior; this report asks for the analogous accommodation on the header-vs-absent-body-version axis, which that PR's method-allowlist approach structurally cannot cover (tools/call has a Modern counterpart and can never join legacyOnlyMethods).
Related issues and PRs (checked — none are duplicates)
- PR Skip logging/setLevel on a Modern-negotiated session #6184 "Classify logging/setLevel as a Legacy-only method" (open, 2026-08-04): tunes the same
ClassifyRevisionfunction in the same era of work, but only generalizes the existing initialize-only short-circuit into alegacyOnlyMethods = {initialize, logging/setLevel}map; it does not touchhasModernSignal,modernSignalMetaKeys, or the!hasBodyVersionbranch, and would not fix this case even if merged. - PR Add MCP 2026-07-28 revision classification and method vocabulary #5834 "Add MCP 2026-07-28 revision classification and method vocabulary": the introducing PR for
ClassifyRevisionand the -32020/-32021/-32022 taxonomy; confirms the hard-reject behavior is deliberate design. - PR Serve MCP 2026-07-28 stateless requests through the transparent proxy #5884 "Serve MCP 2026-07-28 stateless requests through the transparent proxy": the PR that wired
ClassifyRevisioninto the transparent proxy'sRoundTrip, producing the exact 400-before-backend behavior described above. - Issue vMCP oscillates between Modern and Legacy revision, failing every other health check #6154 "vMCP oscillates between Modern and Legacy revision, failing every other health check": same dual-era problem space, but a different code path (
pkg/vmcp/client/client.gobackend-egress revision cache) and a different trigger — not this ingress classifier hard-reject. - Issue MCP 2026-07-28 conformance and revision follow-ups from the go-sdk v1.7 review #6002 "MCP 2026-07-28 conformance and revision follow-ups from the go-sdk v1.7 review": tracking issue whose item 1 (splitting
modernSignalMetaKeysfrom the strip-list) sits in the same SEP-2577/logging accommodation lineage as PR Skip logging/setLevel on a Modern-negotiated session #6184; its checklist never mentionstools/callor the!hasBodyVersionhard-reject. - Clarify behavior when
initialize.params.protocolVersionconflicts withMCP-Protocol-Versionmodelcontextprotocol/modelcontextprotocol#2721 "Clarify behavior when initialize.params.protocolVersion conflicts with MCP-Protocol-Version": spec-side discussion of header/body protocol-version conflicts, but scoped to theinitializehandshake, where a body value exists to prefer; in this non-initializecase the body carries no value at all, which is exactly the ambiguity this report is about.
Activity
alex-feel commentedon Aug 4, 2026
Sibling reports from the same investigation: #6186 (CIMD omitted-scope rejection), #6187 (CIMD x Redis session rehydration). Both had to be resolved before this one became observable.
jerm-dro commentedon Aug 10, 2026
Thanks for the report, @alex-feel, and for the standalone reproduction against the exported classifier — it made the failure mode unmistakable.
@amirejaz has picked up a related change in #6231 ("Let an explicit non-Modern header outrank a reserved key"), which implements the direction proposed here — an explicit non-Modern
MCP-Protocol-Versionheader is treated as authoritative and the request classifies Legacy, while Modern validation stays strict whenever_metadeclares a protocol version.@amirejaz, will #6231 fully close this issue? If so, adding
Closes #6188to the PR would link the two so this closes automatically on merge.Assigning to @amirejaz and leaving this open until the PR lands.
amirejaz commentedon Aug 10, 2026
Yes, #6231 fully closes this. I've added
Closes #6188to the PR body — it was only in the commit message, which a squash merge would have dropped.It implements the proposed direction as written: an explicit non-Modern
MCP-Protocol-Versionheader is authoritative and the request classifies Legacy, with everything else left as strict as it is today. Checked each shape against the classifier directly:_meta2025-11-25{clientCapabilities}2025-11-25{}2026-07-28{clientCapabilities}{clientCapabilities}@alex-feel one deliberate extra, worth flagging since it goes slightly beyond the report: an unrecognised header such as
1999-01-01now classifies Legacy as well. Same reasoning — version validity belongs to the transport (isSupportedMCPVersion), not the classifier, and that header with no reserved key already classified Legacy.The incoherence in rows 1 and 2 is what convinced me this is a bug rather than strictness: adding an unrelated reserved key flipped an otherwise-fine Legacy request from accepted to rejected.
Retarget classification tests at the still-rejected shape
Let an explicit non-Modern header outrank a reserved key (stacklok#6231)