Skip to content

Answer vMCP list calls from one aggregation - #7338

Merged
rdimitrov merged 7 commits into
mainfrom
vmcp-list-call-single-aggregation
Nov 27, 2026
Merged

rdimitrov merged 7 commits into
mainfrom
vmcp-list-call-single-aggregation

Conversation

@rdimitrov

@rdimitrov rdimitrov commented Nov 26, 2026 •

Copy link
Copy Markdown
Member

Summary

Follow-up to #7325. A list-call token's server check and its items came from separate core lookups, which caused four problems:

  • Race. The check (LookupBackend plus a resource-templates list) and the items (List*) were separate aggregations. A backend that dropped out between them was answered 200 [], and the token was spent.
  • Transient failures looked like empty lists. The Modern client turns a transient failure of an optional list (for example prompts/list returning 503 while tools/list works) into an empty list. The list call passed the check and spent the token on [].
  • Templates-only backend got the wrong refusal. A reachable but unhealthy backend that offers only resource templates got 403 server_not_found instead of 503, because templates were checked through a health-filtered list.
  • Cost. The check ran a second full Cedar pass over every backend's items.

What changed:

  • One aggregation. A new optional interface, core.BackendCapabilitiesLookup, has one method, LookupBackendCapabilities(ctx, identity, backendID). It returns what the caller is admitted to on one backend from one aggregation, and an answer runs admission over that backend's items only. The list-call path in pkg/vmcp/server/call_binding.go uses it, and callBindingListServer remains only as the fallback below.
  • Optional, so decorators can't leak. The method is not on core.VMCP, so a decorator that embeds core.VMCP does not inherit it. Such a decorator's list calls fall back to its own LookupBackend and List* answers, so whatever it filters stays filtered. core.LookupBackendCapabilities(ctx, v, ...) forwards to v, or returns core.ErrBackendCapabilitiesLookupUnsupported when v lacks the method, which triggers that fallback. The rate-limit decorator forwards it in one line. The code-mode decorator implements it with its own filtering.
  • Per-list refusals. The result's ListErrors maps a list method to the reason it can't be listed now, and a list call for that method gets 503 with the token unused. The Modern client and the aggregator report which optional lists failed transiently and fill it. Code mode adds a tools/list entry for a backend that advertises execute_tool_script, so that backend's prompts, resources and templates are still listed.
  • Equal refusals. Every 403 server_not_found and every health 503 runs the same aggregations. In each, it checks every item once: the named backend's items, then every other backend's, with the same authorizer calls the lists make, discarding the results. So neither the response time nor an aggregation error tells an unknown name from a hidden backend, whatever that backend's size. An answered list call checks only its own backend's items.
  • Edge cases.
    • When every backend is healthy, one aggregation decides every outcome.
    • A listed backend whose discovery changes between the lookup's two aggregations gets 503, never 403.
    • An empty group gets 403 server_not_found for every name, as LookupBackend answers it.
    • While no backend of a non-empty group answers discovery, a valid list call that misses the capability cache gets the same 503 whatever server it names, and the token stays unused.
  • Cancelled sweeps. When the leader of a shared capability sweep is cancelled, its failure is no longer handed to callers still waiting on it, whatever the error.
  • Docs. The known-limit note is removed from arch/10, and docs/authz.md and docs/arch/vmcp-library.md (writing a VMCP decorator) are updated.

#7325's contract is kept:

  • unknown, hidden, nothing-admitted and failed-discovery backends get the same 403 server_not_found;
  • a visible but unhealthy backend gets 503;
  • degraded backends are listed;
  • the token is recorded only once the answer is ready.

Part of #7062

Type of change

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

Test plan

  • Unit tests: focused go test -race on pkg/vmcp/..., pkg/mcp/toolcalldetails and cmd/vmcp. The full task test matrix is left to CI.
  • E2E tests (task test-e2e)
  • Linting (task lint)
  • Manual testing (described below)

Real-core tests (call_binding_list_real_test.go, through server.New) cover:

  • the race;
  • the transient list;
  • the unhealthy templates-only backend;
  • hidden unhealthy backends whose only items lose a name conflict;
  • an outage of every backend: the same 503 and headers for a real and an unknown server; once backends answer, the same 403 for unknown and hidden; and the same token lists after recovery.

The first three fail on main and pass here.

Core and server tests:

  • An unknown name, hidden backends (healthy and unhealthy) and the health 503 make exactly the authorizer calls the lists make for the whole view, call for call, while an answer checks only its own backend's items.
  • The padding stops when the request goes away and leaves the 403 unchanged.
  • A first sweep that fails and a second that succeeds never gives a visible backend 403.
  • An empty registry is not found.
  • A decorator that only embeds core.VMCP gets its own narrowed list.
  • Code mode answers prompts/list on a backend that advertises execute_tool_script.

Local run. The setup was a real AS-1 → AS-2 token chain and vmcp serve with the production OIDC validator and Cedar. It had ten backends, one of them Modern with a switch to fail prompts/list.

  • 89/89 checks pass on Legacy and Modern clients.
  • On main, the same suite shows the old behaviour wherever this PR changes it.
  • This run predates the last three commits: the outage answer back to 503, the review fixes, and the equal refusals. The tests above cover those.

Cedar cost, answered list call. A list call on a backend of 9,000 tools, median over 20 samples:

List call Plain list
main 262 ms 63 ms
this PR 200 ms 63 ms

A Go benchmark (BenchmarkCallBindingReal_ListCallCedar) gives 188 → 136 ms (plain 67 ms). On the current head it gives 135–161 ms (plain 69–83 ms).

Cedar cost, refusals. BenchmarkCallBindingReal_ListCallRefusalCedar: Cedar admits only a backend of 1,000 tools and hides one of 9,000. Each call has a fresh subject. Median of 8 rounds of 20 calls:

Hidden backend (9,000 tools) Unknown name
this PR, before equal refusals 73.0 ms 32.3 ms
this PR 77.8 ms 78.7 ms

Changes

File Change
pkg/vmcp/core/core.go, core_vmcp.go BackendCapabilitiesLookup, AdmittedBackendCapabilities, LookupBackendCapabilities; equal admission on refusals
pkg/vmcp/server/call_binding.go List calls answered from the lookup, or from the core's lists as a fallback
pkg/vmcp/client/client.go, pkg/vmcp/types.go Which Modern optional lists failed transiently
pkg/vmcp/aggregator/*.go Unavailable lists per backend; ErrNoBackendCapabilities; cancelled-leader sweeps not shared
pkg/vmcp/codemode/decorator.go Lookup implemented; tools/list refused for a backend advertising execute_tool_script
pkg/vmcp/ratelimit/decorator.go Lookup forwarded
docs/arch/10-virtual-mcp-architecture.md, docs/authz.md, docs/arch/vmcp-library.md Known limit removed; new answers and decorator guidance documented

Does this introduce a user-facing change?

Yes, for list-call tokens (authorization_details entries with a method):

Case Before After
Backend drops out of the view during the call 200 [], token spent Answered from one view, with its items
The method's list failed transiently on the backend 200 [], token spent 503, token unused
Templates-only backend, reachable but unhealthy 403 server_not_found 503
Every backend fails discovery 503 503 (unchanged), the same body whatever server, token unused
Group with no backends 503 403 server_not_found, as for an unknown server

For embedders: a VMCP decorator that embeds core.VMCP keeps working, and its list calls are answered from its own lists. To get the single-aggregation path, implement core.BackendCapabilitiesLookup, as described in docs/arch/vmcp-library.md.

Special notes for reviewers

  • Two "in view" rules. LookupBackendCapabilities counts resource templates toward a backend being in the caller's view; ListBackends and LookupBackend do not. This is stated in the method's contract. A follow-up should make authorizedBackends count templates too, and share the admission calls that Discover, authorizedBackends and the new method each make. That change alters what ListBackends returns, so it is left out of this PR.
  • Prompts-only backend whose prompts/list fails. If the caller could see a backend only through the list that failed, it gets 403, not 503. A 503 would reveal a backend that isn't known to be in the caller's view. Pinned in a test.
  • Remaining cost.
    • An answered list call still costs 2–3× a plain first page (the benchmark and the local run above). The usual handler still runs its own full list, and its items are replaced (Enforce list-call tokens at the vMCP #7325's design).
    • A refusal now runs as much admission as a full list for each aggregation it runs, about what the LookupBackend check on main ran.
  • Tool-filter deadline. Admission of tools runs under one deadline per filter call. A hidden backend's refusal makes two such calls (its own tools, then the rest); an unknown name makes one. So under a PDP slow enough to hit that deadline, the two can stop at different points.
  • Coordination. Accept a call's messages after its token expires #7339, which accepts a call's messages after its token's exp, touches the same area.

🤖 Generated with Claude Code

rdimitrov and others added 4 commits November 26, 2026 17:36
A list call's server check and its items came from separate core
lookups. A backend that dropped out of the view between the two was
answered with an empty list and the token was spent; a transient
failure of one optional list looked like an empty list; a templates-only
backend that was unhealthy got 403 instead of 503; and the check ran a
second admission pass over every backend's items.

Add core.LookupBackendCapabilities, which returns one backend's admitted
items and its transiently unavailable lists from a single aggregation,
and answer list calls from it. The Modern client now reports which
optional lists it degraded to empty, and the aggregator carries that per
backend.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
For a backend the lists leave out for its health, aggregate the whole
registry rather than the backend alone: conflict resolution depends on
which backends are aggregated together, so a hidden backend whose item
loses a conflict was answered 503 instead of 403 when aggregated alone.

A shared capability sweep whose leader's context ended no longer hands
its failure to the callers waiting on it, whatever the error: the
default aggregator turns a cancelled sweep into "no backend answered",
which a live list call then took as the backend failing discovery. The
core also checks its own context before treating that as not found.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
An unknown server name was refused before any aggregation, while a
backend hidden from the caller was aggregated first, so the response
time, or an aggregation error's 503, told the two apart. Every name is
now looked up in one aggregation of the backends the lists include; a
listed backend that offers the caller something is answered from it
alone, and every other outcome is decided after an aggregation of the
whole registry, as ListBackends aggregates it.

Rename the core result type to AdmittedBackendCapabilities, document
where its view rule differs from ListBackends (resource templates
count), the aggregator's no-backend sentinel and the decorator contract
for the new method, name the server in the unavailable-list error, and
pin the whole-registry rule, the prompts-only edge case and the single
list pass in tests.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
When no backend in the registry answers discovery, a list call got 403
server_not_found, which clients take as final. It now gets 503, as it
did before this branch. The answer depends only on no backend
answering, so every server name gets the same 503 and the outage tells
nothing about which backends exist; every refusal still runs the same
two aggregations, and the token stays unused.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions github-actions Bot added the size/XL Extra large PR: 1000+ lines changed label Nov 26, 2026
@codecov

codecov Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 92.81437% with 12 lines in your changes missing coverage. Please review.
✅ Project coverage is 82.60%. Comparing base (df5aed7) to head (7337fcc).
⚠️ Report is 4 commits behind head on main.

Files with missing lines Patch % Lines
pkg/vmcp/server/call_binding.go 82.05% 7 Missing ⚠️
pkg/vmcp/core/core_vmcp.go 94.87% 4 Missing ⚠️
pkg/vmcp/client/client.go 94.73% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7338      +/-   ##
==========================================
+ Coverage   82.56%   82.60%   +0.04%     
==========================================
  Files         941      943       +2     
  Lines       96689    96943     +254     
==========================================
+ Hits        79829    80082     +253     
- Misses      16855    16856       +1     
  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.

@jhrozek jhrozek mentioned this pull request Nov 27, 2026
2 of 10 tasks

@jhrozek jhrozek left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The single-snapshot success path is a real improvement: the visibility check and the items can no longer disagree. I read through the whole diff and found a few things worth sorting out before merge. Two are behaviour bugs (recovered backend gets a 403, reserved tool name takes down non-tool lists), one is about the interface change, and the rest are small doc and test items.

Comment thread pkg/vmcp/core/core.go Resolved
Comment thread pkg/vmcp/core/core_vmcp.go Resolved
Comment thread pkg/vmcp/core/core_vmcp.go Resolved
Comment thread pkg/vmcp/codemode/decorator.go Resolved
rdimitrov and others added 2 commits November 27, 2026 12:02
Move LookupBackendCapabilities off core.VMCP into the optional
core.BackendCapabilitiesLookup interface. A decorator that embeds
core.VMCP no longer promotes the inner core's lookup, so a list call on
it falls back to its own LookupBackend and List* answers. Code mode
implements the lookup with its own filtering, and rate limiting forwards
it through core.LookupBackendCapabilities.

When every backend is healthy, the lookup reuses its one aggregation
instead of aggregating the same backends again, so a sweep that fails
and then recovers can no longer turn into a 403 for a backend in view.
A listed backend whose discovery changes between the two aggregations
gets ErrBackendUnavailable (503). An empty registry is not found, as
LookupBackend answers it.

Code mode now refuses only the tools/list of a backend that advertises
execute_tool_script, through AdmittedBackendCapabilities.ListErrors,
which replaces UnavailableLists; the backend's prompts, resources and
templates are still listed.

Scope the docs' timing claim to the refusals' aggregations, and the
outage 503 to valid list calls that miss the capability cache.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions github-actions Bot added size/XL Extra large PR: 1000+ lines changed and removed size/XL Extra large PR: 1000+ lines changed labels Nov 27, 2026
A list call's lookup runs admission over the named backend's items only,
so a refusal for a hidden backend with many items took longer than one
for an unknown name. With Cedar, a hidden backend of 9,000 tools was
refused in about 73 ms and an unknown name in about 32 ms.

On every refusal, the lookup now also runs admission over the other
backends' items in each aggregation it decides from, with the same
authorizer calls the lists make, and discards the result. Every
not-found and health refusal then checks every item once per
aggregation, whichever backend it names; both now take about 78 ms. An
answered list call still checks only its backend's items. The padding
cannot change the answer: nothing it admits is returned, its errors are
dropped, and it stops once the request's context ends.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions github-actions Bot added size/XL Extra large PR: 1000+ lines changed and removed size/XL Extra large PR: 1000+ lines changed labels Nov 27, 2026

@jhrozek jhrozek left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for the quick turnaround. The optional interface, the single-aggregation fix for the recovery case, the tools/list-only reserved-name refusal, the empty-registry answer and the doc scoping all do what I was after, and the tests cover each. I read through the padding commit too. The extra admission work on refusals is a fair price for closing the timing difference, and it stays bounded by the request context. One thing I didn't chase: the per-backend admission calls get their own budget, so under a deadline they can show a tool the full list would drop. Cedar still has to permit it, so it's a parity point rather than a leak. Fine to leave.

@rdimitrov
rdimitrov merged commit 35c677f into main Nov 27, 2026
48 checks passed
@rdimitrov
rdimitrov deleted the vmcp-list-call-single-aggregation branch November 27, 2026 12:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/XL Extra large PR: 1000+ lines changed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants