Repository navigation
Description
Summary
mcp_http currently supports only kind: proxy, and its own schema never validates exit at all (neither top-level nor per-route). Two related changes:
- Add a
kind: clientvariant that disallowsexitin schema and implicitly routes every request to the real, engine-providedsys:http_clientbinding at runtime — no operator-declaredexitneeded. - Fix a silent gap in the existing
kind: proxy:exitshould be required (top-level or per-route), not left optional.
Background
This came out of discussion on #2104/#2231/#2237: mcp_openapi's own composite generator always builds an inner mcp_http0 with kind: proxy, defaulting its exit to sys:http_client via the zilla.binding.mcp.openapi.http.client.exit Configuration property when no override is supplied. That's a workable pattern for mcp_openapi because it has a composite generator to vary the exit in. binding-mcp-http itself has no such generator — it's the leaf/terminal binding — so for mcp_http to offer the same "self-contained, real HTTP" vs. "operator-declared exit" split that mcp_openapi/mcp_schema_registry have, the default has to be filled in at the binding's own config-construction time, not by a generator.
Design
kind: client
- Schema:
kindenum widened to["client", "proxy"].clientbranch sets"exit": falseboth top-level and per-route (routes[].items.properties.exit: false) — disallowed entirely, since the exit is implicit. - Runtime:
McpHttpBindingContext.attach()/detach()widen theirkind == PROXYgates to also acceptCLIENT, delegating to the sameMcpHttpProxyFactory(already kind-agnostic internally, same relay behavior either way — mirrorsMcpSchemaRegistryClientFactory/McpSchemaRegistryBindingContext's existing client+proxy dual-kind pattern from binding-mcp-schema-registry: add kind: proxy variant with operator-declared exit #2231). - Mechanism (traced and confirmed against
runtime/engine):EngineManager.java:452-456resolves every route's exit generically for every binding:route.id = resolver.resolve(route.exit), before any binding-specific code runs.RouteConfig.idispublic transient long id— mutable, notfinal.binding.resolveId = resolver::resolve(EngineManager.java:413) — the exact same resolver, exposed to every binding's config wrapper, and it already handles qualified"namespace:name"strings.- So in
McpHttpBindingConfig's constructor, before it mapsbinding.routesintoMcpHttpRouteConfig(which capturesroute.idat construction time), add: whenbinding.kind == KindConfig.CLIENT, overwrite every route'sroute.id = binding.resolveId.applyAsLong("sys:http_client")— a hardcoded literal, no new Configuration property, directly mirroringbinding-openapi'sOpenapiClientGenerator/binding-asyncapi'sAsyncapiClientGenerator, which already hardcodeexit("sys:tcp_client")with no configuration knob.
"sys:http_client"is confirmed to be a real, always-present engine construct, not an operator-authored convention:EngineManager.buildSystemNamespaceIfNecessary()assembles the built-insysnamespace at startup fromsystem()patches contributed by installedBinding/ExporterSPIs —binding-httpcontributessys:http_client(routinghttps→tls_client/http→tcp_client),binding-tlscontributessys:tls_client,binding-tcpcontributessys:tcp_client(the real socket connect).examples/mcp.proxy/etc/zilla.yamlalready referencesexit: sys:http_clientdirectly with no such namespace authored anywhere in that file.McpHttpBindingitself needs no change — it doesn't overrideoriginType/routedType(defaults to accepting any kind, likeTcpBinding).
kind: proxy — require exit
Traced EngineManager.NameResolver.resolve(String name) (EngineManager.java:612-628): when name (i.e. route.exit) is null, it returns 0L with no error — no exception, no config-time validation failure. That 0L becomes route.id, which McpHttpProxyFactory uses directly as the routed exit target. So today, a kind: proxy mcp_http binding with routes but no exit anywhere silently gets a dead/invalid routing target instead of a clear startup error.
Fix: require exit, top-level or per-route, mirroring binding-tcp's kind: server pattern — but written correctly. binding-tcp's own per-route branch ("routes": {"required": ["exit"]}) looks like a latent bug: "required" only constrains object instances, and routes is type: array, so that check is vacuously true and doesn't actually enforce anything (only tcp's top-level "required": ["exit"] branch does real work). mcp_http's version should nest correctly: "routes": {"items": {"required": ["exit"]}}, so it actually validates each route object.
(Not proposing to touch binding-tcp's existing schema in this issue — separate, pre-existing, out of scope here — just flagging it so mcp-http's version doesn't copy the same mistake.)
Notes
- Independent of
kind: proxy's existing runtime behavior otherwise — no change for existing valid configs that already declareexitsomewhere. - Needs test coverage:
SchemaTestcases for the valid/invalidkind: client/kind: proxycombinations (including the newly-requiredexitforproxy), a unit test onMcpHttpBindingConfigcovering theroute.idresolution forkind: client(config-POJO logic, not a stream-handler state machine, so a mocked-EngineContextunit test is appropriate here perruntime/AGENTS.md), and ideally a real end-to-end IT exercisingkind: clientagainst the genuinesys:http_clientpipeline (would needbinding-http/binding-tls/binding-tcpas real — not test-scope — dependencies ofruntime/binding-mcp-http, mirroring howbinding-openapidepends on them and itsOpenapiClientITdoes a real network round-trip with no exit override needed).
Activity
binding-mcp-http: add kind: client and require exit for kind: proxy (a…