Repository navigation
Description
Summary
An embedder can answer a vMCP tools/call with an MCP URL-mode elicitation by returning a typed error from its own code. vMCP renders that answer per negotiated protocol. A 2026-07-28 (Modern) client that declared elicitation.url receives an InputRequiredResult carrying elicitation/create with mode: "url". Every other client receives a fixed fallback. Legacy (2025-11-25) sessions always take the fallback in this slice: rendering -32042 needs the session's declared capabilities, which ToolHive cannot read yet, and lands in the second sub-issue.
The smallest proof: a test BackendClient decorator returns the typed error, and a real go-sdk Modern client receives resultType: "input_required" with the URL elicitation in one HTTP response, with no standalone stream and no vMCP-side state.
Sub-issue of #6970. Lands first.
Use case
An embedder aggregates many backends, each with its own per-user credential from a different OAuth provider. When one backend's credential is dead, the only prompt available today is HTTP 401, which sends the client through a full sign-in for every provider. With URL-mode elicitation the embedder points the user at a connect page for that one backend and reconnects only that provider. The embedder owns the connect page, its identity check, and the credential store. vMCP owns only the protocol rendering.
Governing decisions
docs/arch/16-vmcp-mrtr.md § What replaces ElicitationRequester: on Modern paths the seam is a value returned through the ordinary return path,vmcp.InputRequiredResult, whichdispatchModernrenders as theinput_requiredenvelope. This slice adds that writer. It takes avmcp.InputRequiredResult, and the URL answer is converted to one at render time, so Support MRTR pass-through for Modern backends in vMCP #6059's slice 2 reuses the same writer for relayed backend rounds.docs/arch/10-virtual-mcp-architecture.md § Limitation: elicitation and sampling are unavailable to Modern clients: the-32021at HTTP 200 deviation (go-sdk#1117) applies to this slice's Modern fallback.pkg/vmcp/core/core.go(VMCPcontract): decorators may only refuse a call. A URL elicitation answer is a refusal, so aVMCPorBackendClientdecorator may return it..claude/rules/vmcp-anti-patterns.mdfix(typo): corrects readme #1 and Start simple hardcoded registry #8: callers get no capability query, throughcontextor through a new method. vMCP decides at the render seam.- MCP 2026-07-28
client/elicitation: URL mode carriesmode,message, andurlonly (noelicitationId) and is delivered only insideInputRequiredResult. "Servers MUST NOT send elicitation requests with modes that are not supported by the client." Anelicitationobject withouturlmeans form only.schema/draftreserves-32042as "2025-11-25 only".
Vocabulary
- URL elicitation answer: the typed error a
tools/callimplementation returns to ask the client to send the user to a URL and then retry the call. New. Owed to thepkg/vmcpdoc comment anddocs/arch/10-virtual-mcp-architecture.md. - Fallback: the fixed response vMCP renders when the client did not declare URL-mode elicitation.
- Modern and Legacy: as
docs/arch/10-virtual-mcp-architecture.mduses them, the 2026-07-28 stateless revision and the 2025-11-25 session revision.
Scenario 1. The domain type validates what it carries
pkg/vmcp is a Stable package (docs/arch/vmcp-library.md § pkg/vmcp/ Stability Table), so the exported shape is a one-way door. Both types have unexported fields, a validating constructor, and read accessors, so no answer reaches the render seam unvalidated. The error type does not implement mcpparser.CodedError, because writeModernDispatchError would then render -32042 on Modern, where the code does not exist. vmcp.ElicitationRequest stays form-only; it is the push seam for server-initiated requests, which URL mode does not use here.
Work:
pkg/vmcp:URLElicitation(elicitation ID, URL, message) withNewURLElicitation, andURLElicitationRequiredErrorwithNewURLElicitationRequiredError(...URLElicitation), anElicitations()accessor, andURLElicitationFromError(err) (*URLElicitationRequiredError, bool)usingerrors.As.- Rewrite the
ElicitationRequestdoc comment so it namesURLElicitationRequiredErroras the URL-mode path instead of saying the fields are omitted.
Acceptance:
- AC1.1:
NewURLElicitationrejects an empty message, an empty elicitation ID, a URL that does not parse, a URL with an empty host, a URL carrying userinfo, a scheme other thanhttps, andhttpon a host that is not loopback.httponlocalhost,127.0.0.0/8, or::1is accepted.- verify:
Unit: TestNewURLElicitation_Validation, no AT because pure value validation
- verify:
- AC1.2:
NewURLElicitationRequiredErrorrejects zero elicitations and duplicate elicitation IDs.- verify:
Unit: TestNewURLElicitationRequiredError_Validation, no AT because pure value validation
- verify:
- AC1.3:
URLElicitationFromErrorfinds the answer through%wwrapping and reports false for any other error.- verify:
Unit: TestURLElicitationFromError, no AT because pure error unwrapping
- verify:
- AC1.4:
Error()names the condition and the message and never the URL, so code-mode scripts, composite workflows, and log lines that stringify the error do not leak the connect URL.- verify:
Unit: TestURLElicitationRequiredError_ErrorOmitsURL, no AT because string property
- verify:
Scenario 2. A Modern client that declared URL mode receives InputRequiredResult
writeModernCallFailure (pkg/vmcp/server/modern_dispatch.go) gains a branch ahead of its capability-refusal branch. Authorization denials are checked inside writeModernDispatchError, after that function's own branches, so the new branch carries an explicit !errors.Is(err, vmcp.ErrAuthorizationFailed) guard, matching the refusal branch. It reads _meta.io.modelcontextprotocol/clientCapabilities.elicitation.url. Grounded in docs/arch/16-vmcp-mrtr.md § What replaces ElicitationRequester.
Work:
pkg/vmcp/server: aninput_requiredwriter inmodern_envelope.gotaking a*vmcp.InputRequiredResult, a conversion from the URL answer, and the branch.- The envelope is
resultType: "input_required"withinputRequestskeyed by elicitation ID, each{method: "elicitation/create", params: {mode: "url", message, url}}, at HTTP 200, under the request's own id. NorequestState. NoelicitationIdin params.
Acceptance:
- AC2.1: A Modern
tools/callwhose decorator returns the answer, from a client declaringelicitation: {url: {}}, returns the envelope above in a single HTTP response, and a go-sdk v1.8 Modern client delivers the URL elicitation to its elicitation handler.- verify:
AT: pkg/vmcp/server integration, TestIntegration_Modern_URLElicitation_InputRequired drives a real go-sdk client against vMCP with a test BackendClient decorator
- verify:
- AC2.2: The retry is an ordinary
tools/call, accepted with itsinputResponsesparam. When the decorator no longer returns the answer, the retry completes normally. When it still does, the client receives a freshinput_required. vMCP holds no state between the two, proven by serving the retry from a fresh server instance.- verify:
AT: pkg/vmcp/server integration, TestIntegration_Modern_URLElicitation_RetryIsStateless
- verify:
- AC2.3: An error that both wraps
ErrAuthorizationFailedand carries the answer renders as the 403 denial.- verify:
Unit: TestWriteModernCallFailure_DenialOutranksURLElicitation, no AT because branch ordering
- verify:
Scenario 3. Every other client receives the fixed fallback
A Modern client that declared only form mode, or no elicitation, and every Legacy session in this slice, receive the fallback. It never contains the URL, so a model cannot follow the link and skip the user's consent step that URL mode exists for. Grounded in docs/arch/10-virtual-mcp-architecture.md § Limitation: elicitation and sampling are unavailable to Modern clients.
Work:
pkg/vmcp/server: a new Modern writer for this-32021. The existingwriteModernMissingCapabilityemits only{capName: {}}and says declaring the capability will not help, which is false here.- On Legacy, one helper used by
coreToolHandler(serve_handlers.go) and the optimizercall_toolhandler (serve_optimizer.go).
Acceptance:
- AC3.1: A Modern client that declared
elicitation: {}, onlyform, or no elicitation receives-32021withdata.requiredCapabilitiesequal to{elicitation: {url: {}}}at HTTP 200. The message tells the client to declareelicitation.urland retry, and does not contain the URL.- verify:
AT: pkg/vmcp/server integration, TestIntegration_Modern_URLElicitation_UndeclaredFallsBack
- verify:
- AC3.2: A Legacy session receives an
isErrortool result whose text is the elicitation message and does not contain the URL, both through a directtools/calland through the optimizercall_toolmeta-tool.- verify:
AT: pkg/vmcp/server integration, TestIntegration_Legacy_URLElicitation_FallsBack drives a go-sdk 2025-11-25 client
- verify:
Scenario 4. Only in-process code produces the answer
The typed answer is constructed only by Go code running in the vMCP process. Backend wire errors are wrapped with %w by pkg/vmcp/client, and a Modern backend's input_required round decodes into vmcp.InputRequiredError (pkg/vmcp/client/modern_mrtr.go), which writeModernCallFailure renders as -32603 today. So a backend cannot make vMCP present a URL to the user. docs/arch/16-vmcp-mrtr.md Cell 1 plans to relay backend inputRequests verbatim once #6059 lands; whether that relay passes URL mode through is #6059's call, raised there. Composite workflows and code-mode scripts flatten step errors into isError results (executeComposite in pkg/vmcp/core/core_calls.go, pkg/vmcp/codemode/decorator.go).
Acceptance:
- AC4.1: A Legacy backend that answers
tools/callwith-32042yields the existing generic tool error at the client edge, never a URL elicitation.- verify:
Unit: TestBackendURLElicitationIsNotRendered_Legacy, no AT because the backend client decode is the boundary
- verify:
- AC4.2: A Modern backend whose
input_requiredround carrieselicitation/createwithmode: "url"yields-32603at the client edge, and the response contains no URL elicitation.- verify:
Unit: TestBackendURLElicitationIsNotRendered_Modern, no AT because the backend client decode is the boundary
- verify:
- AC4.3: A composite workflow whose step returns the answer yields an
isErrorworkflow failure without the URL.- verify:
Unit: TestExecuteComposite_URLElicitationFromStepFlattens, no AT because the composite path flattens before the render seam
- verify:
Out of scope
| Item | Defer to | Why |
|---|---|---|
-32042 on Legacy sessions |
#7023 | Needs the session's declared capabilities, which mcpcompat does not expose |
notifications/elicitation/complete |
Unscheduled follow-up | 2025-11-25 only; needs out-of-band delivery to one session across pods. go-sdk clients do not wait for it by default |
| Relaying a backend's URL elicitation | #6059 | A relay, not an answer. The filtering question is raised on #6059 |
resources/read and prompts/get |
Unscheduled | The answer on those verbs renders as today's generic error |
| A caller-supplied fallback or a capability query | Not planned | vMCP decides at the render seam. A field or option can be added later without breaking callers |
Passing inputResponses to the caller |
#6059 slice 2 | Accept and decline look the same to the decorator in this slice |
| A metric for rendered answers | Not planned | An answer from a BackendClient decorator already counts as a backend error with a distinct error.type, and the embedder can count in its own decorator |
| MCP conformance suite coverage | Not planned | The suite has no URL elicitation scenario and drives only backends, which cannot produce the answer. The integration tests above use a real go-sdk client instead |
Documentation impact
-
docs/arch/10-virtual-mcp-architecture.md: the Modern-client limitation section says the dispatcher never emitsinput_required. Rewrite it to name the URL elicitation answer as the one producer, and add an "Answering a call with a URL elicitation" section with the per-protocol render table.- verify:
inspection: section reflects the shipped shape
- verify:
-
docs/arch/16-vmcp-mrtr.md: slice 2 says theinput_requiredwriter exists and is reused, and Cell 1 notes the open question on relaying URL mode.- verify:
inspection: slice 2 and Cell 1 text match the code
- verify:
-
docs/arch/vmcp-library.md: a "Guidance for Downstream Embedders" entry on returning the answer from aBackendClientdecorator, covering the connect page's obligations: no credentials, PII, or pre-authenticated URLs; the page verifies that the user who opens it is the same vMCP-authenticated subject the answer was issued to; and that the answer counts as a backend error in telemetry. It also states that vMCP meets the spec's binding requirement by rendering in-band on the same authenticated request and holding no state.- verify:
inspection: embedder guidance present
- verify:
-
pkg/vmcp/elicitation.goand thewriteModernCallFailureandwriteModernMissingCapabilitydoc comments: rewritten so none says the dispatcher never emitsinput_required.- verify:
inspection: comments describe the current shape
- verify:
Delivery shape
One PR, and the first of two sub-issues of #6970. Its sibling #7023 renders -32042 on Legacy sessions and lands after a toolhive-core release (stacklok/toolhive-core#447) that exposes declared client capabilities.
Closes AC1.1 to AC4.3. Ordered commits: 1. domain type. 2. fallback on both protocols. 3. Modern input_required, kept last.
Does not touch the toolhive-core pin, the composer, backend telemetry, or ElicitationRequester.
Risks and open questions
- Decline loops: a client that declines and retries gets the answer again. Bounded by the client's retry budget (go-sdk caps at 10 rounds).
- Spec drift: URL mode is marked as possibly changing in future revisions. The shape is confined to one writer per protocol.
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.task genproduces no mock drift.- The PR body states the before and after for both protocols, per
CLAUDE.md § Architecture Documentation.
Activity
Answer vMCP tools/call with a URL elicitation (stacklok#7025)