Repository navigation
Answer vMCP list calls from one aggregation - #7338
Conversation
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]>
Codecov Report❌ Patch coverage is
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. 🚀 New features to boost your workflow:
|
jhrozek
left a comment
There was a problem hiding this comment.
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.
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]>
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]>
jhrozek
left a comment
There was a problem hiding this comment.
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.
Summary
Follow-up to #7325. A list-call token's server check and its items came from separate core lookups, which caused four problems:
LookupBackendplus a resource-templates list) and the items (List*) were separate aggregations. A backend that dropped out between them was answered200 [], and the token was spent.prompts/listreturning 503 whiletools/listworks) into an empty list. The list call passed the check and spent the token on[].server_not_foundinstead of 503, because templates were checked through a health-filtered list.What changed:
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 inpkg/vmcp/server/call_binding.gouses it, andcallBindingListServerremains only as the fallback below.core.VMCP, so a decorator that embedscore.VMCPdoes not inherit it. Such a decorator's list calls fall back to its ownLookupBackendandList*answers, so whatever it filters stays filtered.core.LookupBackendCapabilities(ctx, v, ...)forwards tov, or returnscore.ErrBackendCapabilitiesLookupUnsupportedwhenvlacks 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.ListErrorsmaps 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 atools/listentry for a backend that advertisesexecute_tool_script, so that backend's prompts, resources and templates are still listed.server_not_foundand 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.server_not_foundfor every name, asLookupBackendanswers it.serverit names, and the token stays unused.docs/authz.mdanddocs/arch/vmcp-library.md(writing aVMCPdecorator) are updated.#7325's contract is kept:
server_not_found;Part of #7062
Type of change
Test plan
go test -raceonpkg/vmcp/...,pkg/mcp/toolcalldetailsandcmd/vmcp. The fulltask testmatrix is left to CI.task test-e2e)task lint)Real-core tests (
call_binding_list_real_test.go, throughserver.New) cover:The first three fail on
mainand pass here.Core and server tests:
core.VMCPgets its own narrowed list.prompts/liston a backend that advertisesexecute_tool_script.Local run. The setup was a real AS-1 → AS-2 token chain and
vmcp servewith the production OIDC validator and Cedar. It had ten backends, one of them Modern with a switch to failprompts/list.main, the same suite shows the old behaviour wherever this PR changes it.Cedar cost, answered list call. A list call on a backend of 9,000 tools, median over 20 samples:
mainA 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:Changes
pkg/vmcp/core/core.go,core_vmcp.goBackendCapabilitiesLookup,AdmittedBackendCapabilities,LookupBackendCapabilities; equal admission on refusalspkg/vmcp/server/call_binding.gopkg/vmcp/client/client.go,pkg/vmcp/types.gopkg/vmcp/aggregator/*.goErrNoBackendCapabilities; cancelled-leader sweeps not sharedpkg/vmcp/codemode/decorator.gotools/listrefused for a backend advertisingexecute_tool_scriptpkg/vmcp/ratelimit/decorator.godocs/arch/10-virtual-mcp-architecture.md,docs/authz.md,docs/arch/vmcp-library.mdDoes this introduce a user-facing change?
Yes, for list-call tokens (
authorization_detailsentries with amethod):200 [], token spent200 [], token spentserver_not_foundserver, token unusedserver_not_found, as for an unknown serverFor embedders: a
VMCPdecorator that embedscore.VMCPkeeps working, and its list calls are answered from its own lists. To get the single-aggregation path, implementcore.BackendCapabilitiesLookup, as described indocs/arch/vmcp-library.md.Special notes for reviewers
LookupBackendCapabilitiescounts resource templates toward a backend being in the caller's view;ListBackendsandLookupBackenddo not. This is stated in the method's contract. A follow-up should makeauthorizedBackendscount templates too, and share the admission calls thatDiscover,authorizedBackendsand the new method each make. That change alters whatListBackendsreturns, so it is left out of this PR.prompts/listfails. 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.LookupBackendcheck onmainran.exp, touches the same area.🤖 Generated with Claude Code