Repository navigation
feat(mcpbroker): list gateway tools over HTTP, per server, failing closed - #2888
Merged
Merged
Conversation
jhrozek
force-pushed
the
feat/identitybroker-gateway-listing
branch
from
November 20, 2026 11:44
7425a51 to
6fd8e1b
Compare
Base automatically changed from
feat/identitybroker-gateway-resource
to
main
November 20, 2026 12:24
…osed With a gateway installed (identity broker on, gateway servers configured), the authenticated catalogue no longer discovers a gateway route's tools in process. It asks the gateway for one server's tools at a time through the new Gateway.ListTools, which takes the bearer as a parameter so #2729 can pass a broker-issued token in place of the workspace-enrollment credential used today. The embedded gateway sends an MCP tools/list to the vMCP over its HTTP client (every page, redirects refused) and keeps only the tools the vMCP routes to the server, under their names on that server. Filtering by the vMCP's `{workload}.` prefix is a marked shortcut, removed by #2729. Listing fails closed: an error, or no tools, for a configured gateway server aborts the catalogue freeze, rather than freezing without that server. Every listed tool passes the same admission checks as in-process discovery (attribution, duplicates, names, UTF-8, size, object schema, and the bearer scrub). Listing errors never carry the bearer or the gateway's answer. Non-gateway routes, and every route with the flag off, keep the in-process discovery path unchanged. Part of #2728 Co-authored-by: Mecatl <[email protected]>
jhrozek
force-pushed
the
feat/identitybroker-gateway-listing
branch
from
November 20, 2026 12:27
6fd8e1b to
f9d5c17
Compare
jhrozek
approved these changes
Nov 20, 2026
jhrozek
left a comment
Contributor
There was a problem hiding this comment.
Approving so this can land while you're away. The design is right: listing behind Gateway.ListTools over HTTP, one server at a time, failing closed.
We'll send a follow-up PR with fixes we found in review, rather than pushing to your branch:
- Bound the gateway
tools/list: it followednextCursorwith no repeated-cursor check, no page, tool, or byte cap, and no overall deadline (the embedded in-process client has no timeout). The fix reuses the bounded loop andCandidateListBudgetthe ordinary MCP listing already uses, adds one timeout for the whole listing, and makes the limits tunable throughGatewayCalls.ListLimits. - Keep a gateway tool's output schema in
GatewayTool, which #2728's result check will need. Gateway.ListToolstakes anidentitybroker.Tokeninstead of anoauth2.TokenSource, so the bearer sent is the one checked for, as on the call path.- Direct tests for
ListGatewayTools: every page, the limits, the bearer on every request, and no redirects. - The comment on
gatewayProtocolVersionnow gives the real reason for the pin: on 2026-07-28 the vMCP answers a call needing URL elicitation with aninput_requiredresult, whichclassifywould read as completed. A tracking issue for moving the gateway paths to 2026-07-28 will follow.
This was referenced Nov 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
PR 2 of #2728, stacked on PR 1 (
feat(mcpbroker): carry the vMCP resource on Gateway).mecak8s's MCP client now lists the gateway's tools one server at a time, and the catalogue fails closed when a configured server's listing fails or is empty.
Gateway.ListTools(ctx, server, credential oauth2.TokenSource) ([]GatewayTool, error)(internal/adapter/mcpbroker/gateway.go). It returns the tools the gateway routes toserver, under their names on that server, with description, input schema, and read-only hint. The credential is a parameter so List gateway tools with a broker-issued token #2729 can swap the workspace-enrollment credential for a broker-issued token.mcp.ListGatewayTools(internal/adapter/mcp/gatewaylist.go) runs an MCPtools/list(every page) over its own session. It sets the bearer only inAuthorization, follows no redirects, and returnsErrGatewayListwithout the gateway's answer.embeddedGateway.ListToolsfilters the vMCP's aggregate listing by its{workload}.routed-name prefix. This is a marked shortcut that List gateway tools with a broker-issued token #2729 removes (toolhive#7062). Name parsing stays inside the embedded gateway.Runtime.discoverBackend(authenticated_discovery.go) is used by both the enrollment freeze and the lazy bundle refresh:GatewayCalls.Servers), it callsGateway.ListToolswith the enrollment credential.QueryAuthenticatedCapabilities, unchanged.neutralCapabilities/neutralToolDefinition/containsPrivate*checks, scrubbing for the exact bearer sent.errGatewayListingFailed, and an empty listing witherrGatewayListedNoTools. Both wrapErrAuthenticatedDiscovery. The per-backend diagnostic reason isdiscovery_failedorno_tools, keyed bybackend_indexwith no name and no token.Tests
TestEmbeddedGatewayListsOnlyTheServersToolsuses a real ToolHive process and vMCP, reached in process, with two anonymous backends. Each server's listing returns only its own tools, unprefixed, with schema and read-only hint. A protected backend with no upstream credential lists nothing, and a token the vMCP refuses returnsErrGatewayList.TestFreezeListsGatewayRoutesThroughTheGateway: the gateway route is listed through the gateway with the enrollment credential, and the non-gateway backend still goes through the in-process query. The route is broker-routed and maps back throughRoute.TestFreezeFailsClosedOnAGatewayListingcovers a listing error, no tools, a duplicate, a private string in the description, a private string in the schema, an invalid name, invalid UTF-8, and a missing schema. In each case the freeze fails, nothing is published, and the diagnostic reason is right.TestGatewayListingNeverLeaksTheBeareruses gateways that echo the bearer in a 401 body, a 500 body, and a tool description. Neither the freeze error, theListToolserror, nor the diagnostics carry it. Positive control: the gateway received it inAuthorization.Run:
go test ./internal/adapter/mcpbroker/... ./internal/adapter/mcp/... -count=1go test ./internal/app/ -run 'MCPBroker|IdentityBroker|Gateway|AS2|IDJAG' -count=1go test ./internal/adapter/server/ -run MCPBroker -count=1go test ./cmd/mecak8s/ -run Gateway -count=1go test -raceon the new testsgo veton the touched packagestask lintAPI compatibility
Assessment: no wire change, and no major or feature change.
GatewayCalls.Servers. The only source of those servers isapp.Config.IdentityBrokerGatewayServers, which is test-only; no production path or settings key sets it (internal/app/build.go).mcp__<server>__<tool>). Only where the tool metadata comes from changes, and the freeze now fails rather than freezing without the server. An enrollment failure still surfaces as the existingfailedenrollment status, with no new error text on the wire.Gatewayinterface gainsListTools. Its only implementations are internal (embeddedGatewayand test doubles).The per-server, fail-closed listing rule is being recorded in the agent identity design in a separate docs PR.