Skip to content

binding-mcp-http: add kind: client (implicit sys:http_client exit) and require exit for kind: proxy #2238

Description

@jfallows

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:

  1. Add a kind: client variant that disallows exit in schema and implicitly routes every request to the real, engine-provided sys:http_client binding at runtime — no operator-declared exit needed.
  2. Fix a silent gap in the existing kind: proxy: exit should 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: kind enum widened to ["client", "proxy"]. client branch sets "exit": false both top-level and per-route (routes[].items.properties.exit: false) — disallowed entirely, since the exit is implicit.
  • Runtime: McpHttpBindingContext.attach()/detach() widen their kind == PROXY gates to also accept CLIENT, delegating to the same McpHttpProxyFactory (already kind-agnostic internally, same relay behavior either way — mirrors McpSchemaRegistryClientFactory/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-456 resolves every route's exit generically for every binding: route.id = resolver.resolve(route.exit), before any binding-specific code runs.
    • RouteConfig.id is public transient long id — mutable, not final.
    • 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 maps binding.routes into McpHttpRouteConfig (which captures route.id at construction time), add: when binding.kind == KindConfig.CLIENT, overwrite every route's route.id = binding.resolveId.applyAsLong("sys:http_client") — a hardcoded literal, no new Configuration property, directly mirroring binding-openapi's OpenapiClientGenerator/binding-asyncapi's AsyncapiClientGenerator, which already hardcode exit("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-in sys namespace at startup from system() patches contributed by installed Binding/Exporter SPIs — binding-http contributes sys:http_client (routing https→tls_client/http→tcp_client), binding-tls contributes sys:tls_client, binding-tcp contributes sys:tcp_client (the real socket connect). examples/mcp.proxy/etc/zilla.yaml already references exit: sys:http_client directly with no such namespace authored anywhere in that file.
  • McpHttpBinding itself needs no change — it doesn't override originType/routedType (defaults to accepting any kind, like TcpBinding).

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 declare exit somewhere.
  • Needs test coverage: SchemaTest cases for the valid/invalid kind: client/kind: proxy combinations (including the newly-required exit for proxy), a unit test on McpHttpBindingConfig covering the route.id resolution for kind: client (config-POJO logic, not a stream-handler state machine, so a mocked-EngineContext unit test is appropriate here per runtime/AGENTS.md), and ideally a real end-to-end IT exercising kind: client against the genuine sys:http_client pipeline (would need binding-http/binding-tls/binding-tcp as real — not test-scope — dependencies of runtime/binding-mcp-http, mirroring how binding-openapi depends on them and its OpenapiClientIT does a real network round-trip with no exit override needed).

Activity

  1. added theissue type on Jul 31, 2026
  2. self-assigned this
    on Jul 31, 2026
  3. added a commit that references this issue on Aug 4, 2026
    76209c7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions