Skip to content

vMCP: answer tools/call with a URL-mode elicitation (Modern and fallback) #7022

Closed

Description

@tgrunnagle

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, which dispatchModern renders as the input_required envelope. This slice adds that writer. It takes a vmcp.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 -32021 at HTTP 200 deviation (go-sdk#1117) applies to this slice's Modern fallback.
  • pkg/vmcp/core/core.go (VMCP contract): decorators may only refuse a call. A URL elicitation answer is a refusal, so a VMCP or BackendClient decorator may return it.
  • .claude/rules/vmcp-anti-patterns.md fix(typo): corrects readme #1 and Start simple hardcoded registry #8: callers get no capability query, through context or through a new method. vMCP decides at the render seam.
  • MCP 2026-07-28 client/elicitation: URL mode carries mode, message, and url only (no elicitationId) and is delivered only inside InputRequiredResult. "Servers MUST NOT send elicitation requests with modes that are not supported by the client." An elicitation object without url means form only. schema/draft reserves -32042 as "2025-11-25 only".

Vocabulary

  • URL elicitation answer: the typed error a tools/call implementation returns to ask the client to send the user to a URL and then retry the call. New. Owed to the pkg/vmcp doc comment and docs/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.md uses 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) with NewURLElicitation, and URLElicitationRequiredError with NewURLElicitationRequiredError(...URLElicitation), an Elicitations() accessor, and URLElicitationFromError(err) (*URLElicitationRequiredError, bool) using errors.As.
  • Rewrite the ElicitationRequest doc comment so it names URLElicitationRequiredError as the URL-mode path instead of saying the fields are omitted.

Acceptance:

  • AC1.1: NewURLElicitation rejects 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 than https, and http on a host that is not loopback. http on localhost, 127.0.0.0/8, or ::1 is accepted.
    • verify: Unit: TestNewURLElicitation_Validation, no AT because pure value validation
  • AC1.2: NewURLElicitationRequiredError rejects zero elicitations and duplicate elicitation IDs.
    • verify: Unit: TestNewURLElicitationRequiredError_Validation, no AT because pure value validation
  • AC1.3: URLElicitationFromError finds the answer through %w wrapping and reports false for any other error.
    • verify: Unit: TestURLElicitationFromError, no AT because pure error unwrapping
  • 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

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: an input_required writer in modern_envelope.go taking a *vmcp.InputRequiredResult, a conversion from the URL answer, and the branch.
  • The envelope is resultType: "input_required" with inputRequests keyed by elicitation ID, each {method: "elicitation/create", params: {mode: "url", message, url}}, at HTTP 200, under the request's own id. No requestState. No elicitationId in params.

Acceptance:

  • AC2.1: A Modern tools/call whose decorator returns the answer, from a client declaring elicitation: {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
  • AC2.2: The retry is an ordinary tools/call, accepted with its inputResponses param. When the decorator no longer returns the answer, the retry completes normally. When it still does, the client receives a fresh input_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
  • AC2.3: An error that both wraps ErrAuthorizationFailed and carries the answer renders as the 403 denial.
    • verify: Unit: TestWriteModernCallFailure_DenialOutranksURLElicitation, no AT because branch ordering

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 existing writeModernMissingCapability emits 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 optimizer call_tool handler (serve_optimizer.go).

Acceptance:

  • AC3.1: A Modern client that declared elicitation: {}, only form, or no elicitation receives -32021 with data.requiredCapabilities equal to {elicitation: {url: {}}} at HTTP 200. The message tells the client to declare elicitation.url and retry, and does not contain the URL.
    • verify: AT: pkg/vmcp/server integration, TestIntegration_Modern_URLElicitation_UndeclaredFallsBack
  • AC3.2: A Legacy session receives an isError tool result whose text is the elicitation message and does not contain the URL, both through a direct tools/call and through the optimizer call_tool meta-tool.
    • verify: AT: pkg/vmcp/server integration, TestIntegration_Legacy_URLElicitation_FallsBack drives a go-sdk 2025-11-25 client

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/call with -32042 yields 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
  • AC4.2: A Modern backend whose input_required round carries elicitation/create with mode: "url" yields -32603 at the client edge, and the response contains no URL elicitation.
    • verify: Unit: TestBackendURLElicitationIsNotRendered_Modern, no AT because the backend client decode is the boundary
  • AC4.3: A composite workflow whose step returns the answer yields an isError workflow failure without the URL.
    • verify: Unit: TestExecuteComposite_URLElicitationFromStepFlattens, no AT because the composite path flattens before the render seam

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 emits input_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
  • docs/arch/16-vmcp-mrtr.md: slice 2 says the input_required writer 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
  • docs/arch/vmcp-library.md: a "Guidance for Downstream Embedders" entry on returning the answer from a BackendClient decorator, 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
  • pkg/vmcp/elicitation.go and the writeModernCallFailure and writeModernMissingCapability doc comments: rewritten so none says the dispatcher never emits input_required.
    • verify: inspection: comments describe the current shape

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

  1. Every checkbox above is checked, and every verify: test exists and is green.
  2. task build, task test, task test-integration, and task lint-fix pass with no diff.
  3. task gen produces no mock drift.
  4. The PR body states the before and after for both protocols, per CLAUDE.md § Architecture Documentation.

Activity

  1. added
    enhancement
    size/M
    vmcp
    on Nov 2, 2026
  2. added
    needs-triage
    on Nov 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementneeds-triagesize/Mvmcp

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions