Repository navigation
Description
Summary
A Legacy (2025-11-25) vMCP session whose client declared elicitation.url at initialize receives a URL elicitation answer as JSON-RPC -32042 URLElicitationRequiredError, with the elicitations in error.data.elicitations. Before this slice every Legacy session receives the fallback, because vMCP cannot read the client's declared capabilities. This slice reads them through a toolhive-core accessor and switches declaring sessions to -32042.
The smallest proof: a go-sdk 2025-11-25 client that declares elicitation: {url: {}} calls a tool whose BackendClient decorator returns the answer, and receives a *jsonrpc.Error with code -32042 whose data lists the elicitation with its elicitationId.
Sub-issue of #6970. Lands after #7022, and after the toolhive-core release that exposes declared client capabilities (stacklok/toolhive-core#447).
Governing decisions
- MCP 2025-11-25
client/elicitation § URL Elicitation Required Error: the error "MUST include a list of elicitations", each "MUST be URL mode elicitations and have anelicitationIdproperty". "Servers MUST NOT send elicitation requests with modes that are not supported by the client", and anelicitationcapability of{}means form only. - go-sdk v1.8
internal/jsonrpc2/messages.gotoWireError: a*jsonrpc.Errorreturned unwrapped from a raw tool handler reaches the wire with its code and data. A wrapped one keeps the code and drops the data. mcpcompat'swrapToolHandlerpasses the handler error through unchanged. So every Legacy handler returns the bare error. .claude/rules/vmcp-anti-patterns.mdImplement secret injection #5: SDK session details stay behind the adapter. vMCP reads capabilities through the mcpcompat accessor, never from go-sdk internals.- vMCP: answer tools/call with a URL-mode elicitation (Modern and fallback) #7022 defines
vmcp.URLElicitationRequiredError, the fixed fallback, and the in-process-only boundary. This slice changes only which Legacy sessions skip the fallback. Grounded indocs/arch/10-virtual-mcp-architecture.md § Answering a call with a URL elicitation, which vMCP: answer tools/call with a URL-mode elicitation (Modern and fallback) #7022 adds.
Vocabulary
- URL elicitation answer, fallback, Legacy: as vMCP: answer tools/call with a URL-mode elicitation (Modern and fallback) #7022 defines them.
- Rehydrated session: a Legacy session that mcpcompat reconstructs on a pod that did not see its
initialize. Its declared capabilities are unknown.
Scenario 1. A declaring Legacy client receives -32042
Grounded in docs/arch/10-virtual-mcp-architecture.md § Answering a call with a URL elicitation.
Work:
- Bump
github.com/stacklok/toolhive-coreto the tagged release carrying the accessor. pkg/vmcp/server: the shared Legacy render helper reads the declared capabilities. Whenknownis true andelicitation.urlis present, it returns a bare*jsonrpc.Errorwith code-32042, messageURL elicitation required, anddata.elicitationsas[{mode: "url", elicitationId, url, message}].serve_optimizer.go: the optimizercall_toolhandler wraps inner errors with%wbeforeconversion.ErrorToToolResult, which drops the error data. It returns a-32042*jsonrpc.Errorfrom the inner call unwrapped.- Rewrite the
conversion.ErrorToToolResultdoc comment, which says tool handlers "cannot reliably carry custom JSON-RPC codes". A bare*jsonrpc.Errorcan. Coded domain errors keep theisErrorshape by choice.
Acceptance:
- AC1.1: A go-sdk 2025-11-25 client that declared
elicitation: {url: {}}receives-32042with every elicitation indata.elicitations, in order, each carrying itselicitationId.- verify:
AT: pkg/vmcp/server integration, TestIntegration_Legacy_URLElicitation_Required drives a real go-sdk client with a test BackendClient decorator
- verify:
- AC1.2: Through the optimizer
call_toolmeta-tool, the same client receives the same-32042with the same data.- verify:
AT: pkg/vmcp/server integration, TestIntegration_Legacy_URLElicitation_RequiredViaOptimizer
- verify:
- AC1.3: An error that both wraps
ErrAuthorizationFailedand carries the answer renders as the deny tool result.- verify:
Unit: TestLegacyRender_DenialOutranksURLElicitation, no AT because branch ordering
- verify:
Scenario 2. Non-declaring and unknown sessions keep the fallback
Grounded in the MCP 2025-11-25 capability rule above and .claude/rules/vmcp-anti-patterns.md #5: vMCP trusts only what the accessor reports as known.
Acceptance:
- AC2.1: A client that declared
elicitation: {}, onlyform, or no elicitation, or that negotiated a revision older than 2025-11-25, receives the fallback and no-32042.- verify:
AT: pkg/vmcp/server integration, TestIntegration_Legacy_URLElicitation_UndeclaredFallsBack
- verify:
- AC2.2: A session whose declared capabilities are unknown, such as a rehydrated session, receives the fallback. vMCP sends URL mode only when the accessor reports the capabilities as known.
- verify:
Unit: TestLegacyRender_UnknownCapabilitiesFallBack, no AT because rehydration needs a second pod
- verify:
Out of scope
| Item | Defer to | Why |
|---|---|---|
| Persisting declared capabilities across pods | Unscheduled toolhive-core follow-up | Unknown capabilities fall back safely |
notifications/elicitation/complete |
Unscheduled follow-up | Needs out-of-band delivery to one session across pods |
| Modern rendering, the domain type, the fallback content | #7022 | Lands before this |
Documentation impact
-
docs/arch/10-virtual-mcp-architecture.md: the URL elicitation render table gains the Legacy-32042row and the unknown-capabilities caveat for rehydrated sessions.- verify:
inspection: table matches the shipped behaviour
- verify:
-
pkg/vmcp/conversion/errors.go: doc comment rewritten as above.- verify:
inspection: comment states the current reason for the isError shape
- verify:
Delivery shape
One PR, and the second of two sub-issues of #6970. Lands after #7022 and after the toolhive-core release with the capability accessor.
Closes AC1.1 to AC2.2. Does not change Modern rendering, the domain type, or the fallback content, which #7022 owns.
Risks and open questions
- toolhive-core release timing gates this PR. vMCP: answer tools/call with a URL-mode elicitation (Modern and fallback) #7022 ships without it.
- Failover: a client moved to another pod falls back to the
isErrorresult until the follow-up persists capabilities.
Definition of done
- Every checkbox above is checked, and every
verify:test exists and is green. task build,task test,task test-integration, andtask lint-fixpass with no diff.go.modpins a tagged toolhive-core release, not a pseudo-version.- The PR body states the before and after for Legacy clients.
Activity
tgrunnagle commentedon Nov 5, 2026
Blocked on stacklok/toolhive-core#467.
toolhive-core v0.0.59 (#447) exposes
DeclaredClientCapabilities(), which covers AC1.1–AC1.3, AC2.2, and the{}/ form-only / no-elicitation part of AC2.1. The other part of AC2.1, falling back for a client that negotiated a revision older than 2025-11-25, needs the negotiated protocol version. A tool handler can't read it today:wrapToolHandlerdoesn't passMCP-Protocol-VersionintoCallToolRequest.Header.Reading the header through a context value would add vmcp-anti-patterns #1, so this waits for the accessor in toolhive-core#467. Once that ships, the Legacy render helper returns
-32042only when capabilities and version are both known,elicitation.urlis declared, and the version is at least 2025-11-25. Every other session gets the fallback.Render -32042 for Legacy clients that declared URL elicitation (stack…