Skip to content

Let embedders set the Legacy URL fallback text - #7136

Merged
tgrunnagle merged 3 commits into
mainfrom
url-elicitation-embedder-fallback
Nov 14, 2026
Merged

tgrunnagle merged 3 commits into
mainfrom
url-elicitation-embedder-fallback

Conversation

@tgrunnagle

@tgrunnagle tgrunnagle commented Nov 13, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • A Legacy (2025-11-25) client that did not declare elicitation.url, or whose capabilities vMCP does not know (a rehydrated session), gets an isError result carrying only the elicitation message. For an embedder whose clients have no other way to reach its connect page, that is a dead end: the client is told to reconnect but never told where. vMCP: answer tools/call with a URL-mode elicitation (Modern and fallback) #7022 listed a caller-supplied fallback as "addable later without breaking callers". This PR adds it, keeping the rule that callers get no capability query (vmcp-anti-patterns fix(typo): corrects readme #1 and Start simple hardcoded registry #8). The embedder supplies the text and vMCP still decides the rendering at the render seam.
  • pkg/vmcp: (*URLElicitationRequiredError).WithLegacyFallback(text) returns a copy whose Legacy fallback renders text, and rejects empty or whitespace-only text. LegacyFallback() returns that text, or Message() when none is set. Both are additive on the Stable package.
  • conversion.ErrorToToolResult renders LegacyFallback() instead of Message(). Nothing else changes: -32042 still carries the elicitation messages, the Modern -32021 still tells the client to declare elicitation.url, the Modern decline result does not hand back a link the user declined, and Error(), Format and GoString never include the fallback, so code that stringifies the error does not print a link written into it.
  • Docs: docs/arch/10-virtual-mcp-architecture.md (render table and a new property) and docs/arch/vmcp-library.md.

Part of #6970. Follow-up to #7114.

Type of change

  • Bug fix
  • New feature
  • Refactoring (no behavior change)
  • Dependency update
  • Documentation
  • Other (describe):

Test plan

  • Unit tests (task test)
  • E2E tests (task test-e2e)
  • Linting (task lint-fix)
  • Manual testing (describe below)

go test ./pkg/vmcp/... -count=1 passes, and task lint reports "0 issues." and a clean go vet.

  • TestURLElicitationRequiredError_WithLegacyFallback: by default the fallback is Message(); empty or whitespace text is rejected; the method returns a copy with the same elicitations and Message(), leaves the receiver unchanged, and the copy is still found by URLElicitationFromError; Error() and every fmt verb omit the fallback.
  • TestErrorToToolResult: a new case where the embedder fallback replaces the message.
  • TestIntegration_Legacy_URLElicitation_EmbedderFallback, with real go-sdk clients: an undeclared Legacy client gets the embedder text through a direct tools/call and through the optimizer call_tool; a declared Legacy client still gets -32042 carrying the elicitation message, not the fallback; an undeclared Modern client still gets -32021 without the fallback; and a Modern client that declines gets the elicitation message as its isError result, not the fallback.

Does this introduce a user-facing change?

Only for embedders that call WithLegacyFallback. A Legacy client that cannot receive -32042 then sees the embedder's text instead of the elicitation message. Without the call, rendering is unchanged.

Special notes for reviewers

  • The fallback may carry a URL by design. The default fallback keeps the URL away from a model so it cannot skip the user consent step URL mode exists for. A client without URL mode has no consent step to skip, so an embedder that wants a link in-band has made that call itself. One exception: a rehydrated session also gets this fallback because vMCP does not know its capabilities, so in a multi-replica deployment a link written into it can reach the model of a client that did declare elicitation.url. The arch doc says this too. The doc comment and the arch doc say this.
  • Legacy only. Modern renderings ignore the fallback. A Modern client without elicitation.url gets -32021, a protocol signal to declare the capability, and an embedder that wants an in-band link on Modern can return its own tool result there, because the request _meta carries the client's capabilities. The Modern decline result must not repeat a link the user declined.
  • Copy, not mutation. WithLegacyFallback returns a new answer, so the type stays immutable after construction like the rest of it.

🤖 Generated with Claude Code

A Legacy client that did not declare elicitation.url gets an isError
result carrying only the elicitation message, so an embedder whose
clients have no other way to reach its connect page cannot hand them a
link. URLElicitationRequiredError.WithLegacyFallback sets the text vMCP
renders for that fallback; LegacyFallback returns it, or Message() when
unset. -32042, Modern renderings, Error() and fmt output are unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions github-actions Bot added the size/S Small PR: 100-299 lines changed label Nov 13, 2026

@tgrunnagle tgrunnagle left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review

A small, additive feature on the Stable pkg/vmcp package: (*URLElicitationRequiredError).WithLegacyFallback(text) returns an immutable copy whose Legacy isError fallback renders embedder-supplied text, and LegacyFallback() reads it back (defaulting to Message()). conversion.ErrorToToolResult is the only renderer switched over. The approach is sound and minimal: the zero value is unchanged, no interface gains a method, there is no capability query (vmcp-anti-patterns #1 and #8 hold), and Error(), Format, GoString, -32042 and the Modern -32021 and decline renderings still use the elicitation messages. The trade-off the PR documents is that an embedder who writes a link into the text puts that link in front of the model.

Cross-cutting observations

  • Renderers outside the diff stay consistent: the Modern decline result (modern_dispatch.go:638) and the Modern -32021 message (modern_dispatch.go:683) still use answer.Message(), and nothing rebuilds an answer from Elicitations(), so the fallback cannot be dropped by a re-wrap.
  • The new architecture-doc bullet contradicts the unchanged bullet directly above it (first low finding).
  • The "Modern decline does not hand back the link" guarantee is stated in the docs and the PR body, but no test would fail if it regressed (the medium finding).

Findings

# Severity Finding Location Raised by
1 MEDIUM No test shows the Modern decline result omits the embedder fallback pkg/vmcp/server/url_elicitation_integration_test.go:710 tests
2 LOW Architecture doc still says every fallback uses the same Message() text docs/arch/10-virtual-mcp-architecture.md:559 readability, correctness
3 LOW Message() comment contradicts itself after the edit pkg/vmcp/url_elicitation.go:173 readability
4 LOW WithLegacyFallback rebuilds the struct field by field instead of copying it pkg/vmcp/url_elicitation.go:206 api-design
5 LOW Repeated hard-coded fallback host in new tests pkg/vmcp/server/url_elicitation_integration_test.go:651 readability
6 LOW Commit subject exceeds the 50-character limit commit 9a26aba readability

Additional findings

  • [LOW] Commit subject exceeds the 50-character limit (commit 9a26aba): "Let an embedder set the Legacy URL elicitation fallback" is 55 characters; CONTRIBUTING.md and CLAUDE.md set a 50-character limit. Shorten it, for example "Let embedders set the Legacy URL fallback text" (45), if the commit message is kept on merge. Raised by: readability.

How to test

  • Run task test and expect TestURLElicitationRequiredError_WithLegacyFallback, the new TestErrorToToolResult case and TestIntegration_Legacy_URLElicitation_EmbedderFallback to pass.
  • Deliberately break it: change urlElicitationFallbackResult in pkg/vmcp/conversion/errors.go back to answer.Message() and confirm the new TestErrorToToolResult case and the integration test fail.
  • Deliberately break the Modern side: change modern_dispatch.go:638 to answer.LegacyFallback() and note that no test fails; that is the gap in finding 1.
  • Run task lint.

Reviewed by dev:review-pr (finders: correctness, readability and conventions, API design, tests). Generated with Claude Code.

Comment thread pkg/vmcp/url_elicitation.go Resolved
Comment thread pkg/vmcp/url_elicitation.go Resolved
@codecov

codecov Bot commented Nov 13, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 81.31%. Comparing base (b9de592) to head (cdd1e0a).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7136      +/-   ##
==========================================
+ Coverage   81.26%   81.31%   +0.05%     
==========================================
  Files         879      880       +1     
  Lines       89947    89960      +13     
==========================================
+ Hits        73091    73147      +56     
+ Misses      16851    16808      -43     
  Partials        5        5              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Addresses #7136 review comments:
- MEDIUM pkg/vmcp/server/url_elicitation_integration_test.go:710 (4569174107): add a Modern decline case on the fallback-carrying answer
- LOW docs/arch/10-virtual-mcp-architecture.md:563 (4569174113): qualify the same-text bullet as the default, here and in vmcp-library.md
- LOW pkg/vmcp/url_elicitation.go:173 (4569174122): reword the Message comment as the default text
- LOW pkg/vmcp/url_elicitation.go:206 (4569174127): copy the struct in WithLegacyFallback
- LOW pkg/vmcp/server/url_elicitation_integration_test.go:651 (4569174154): name the fallback host once per test

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@tgrunnagle tgrunnagle changed the title Let an embedder set the Legacy URL elicitation fallback Let embedders set the Legacy URL fallback text Nov 13, 2026
@tgrunnagle

Copy link
Copy Markdown
Collaborator Author

Re the [LOW] commit-subject finding in review 5898696147: I retitled the PR to "Let embedders set the Legacy URL fallback text" (45 characters). The squash merge takes its subject from the title, and rewriting 9a26aba itself would need a force-push.

@github-actions github-actions Bot added size/S Small PR: 100-299 lines changed and removed size/S Small PR: 100-299 lines changed labels Nov 13, 2026
jhrozek
jhrozek previously approved these changes Nov 14, 2026

@tgrunnagle tgrunnagle left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review

Incremental review of the one commit since the last review (9a26aba to f38df96). The commit addresses all five inline findings from the previous review: the Modern decline path now has a test that fails if it renders the embedder fallback, the architecture doc and the Message() comment no longer claim every fallback reads the same, WithLegacyFallback copies the struct instead of rebuilding it, and each test names the fallback host once. The change is still small and additive on the Stable pkg/vmcp package, and nothing in the new commit alters runtime behavior beyond the struct copy, which shares no mutable state with the receiver. Two cosmetic nits remain.

Findings

# Severity Finding Location Raised by
1 LOW Reflowed doc paragraphs left over-long lines inside wrapped prose docs/arch/10-virtual-mcp-architecture.md:564 readability
2 LOW Test doc comment became a run-on sentence pkg/vmcp/server/url_elicitation_integration_test.go:648 readability

Resolved since the last review

  • No test shows the Modern decline result omits the embedder fallback (pkg/vmcp/server/url_elicitation_integration_test.go): the new "Modern decline result omits the fallback" subtest asserts the isError text equals the elicitation message and that neither host appears in the result.
  • Architecture doc still says every fallback uses the same Message() text (docs/arch/10-virtual-mcp-architecture.md): the bullet now says "by default" and names the Legacy isError fallback as the one replaceable text.
  • Message() comment contradicts itself after the edit (pkg/vmcp/url_elicitation.go): the comment now calls it the default text and says only the Legacy isError text can be replaced.
  • WithLegacyFallback rebuilds the struct field by field instead of copying it (pkg/vmcp/url_elicitation.go): it now copies *e, clones the slice and overrides legacyFallback.
  • Repeated hard-coded fallback host in new tests (pkg/vmcp/server/url_elicitation_integration_test.go): each test declares fallbackHost and uses it in every assertion.

How to test

  • Run task test and expect the three WithLegacyFallback tests, including the new Modern decline subtest, to pass.
  • Deliberately break it: change modern_dispatch.go:638 to answer.LegacyFallback() and confirm "Modern decline result omits the fallback" fails.
  • Run task lint.

Reviewed by dev:review-pr (finders: correctness, readability and conventions, tests). Generated with Claude Code.

Addresses #7136 review comments:
- LOW docs/arch/10-virtual-mcp-architecture.md:567 (4574659313): say a rehydrated session, which may have declared elicitation.url, also gets the embedder's Legacy fallback, and qualify the bullet heading
- LOW docs/arch/10-virtual-mcp-architecture.md:564 (4575168449): rewrap and tighten the URL-mode bullet and the vmcp-library.md paragraph
- LOW pkg/vmcp/server/url_elicitation_integration_test.go:648 (4575168454): split the test doc comment

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@tgrunnagle
tgrunnagle marked this pull request as ready for review November 14, 2026 18:57
@github-actions github-actions Bot added size/S Small PR: 100-299 lines changed and removed size/S Small PR: 100-299 lines changed labels Nov 14, 2026
@tgrunnagle
tgrunnagle merged commit a9e9e48 into main Nov 14, 2026
62 of 64 checks passed
@tgrunnagle
tgrunnagle deleted the url-elicitation-embedder-fallback branch November 14, 2026 20:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/S Small PR: 100-299 lines changed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants