Skip to content

binding-mcp-schema-registry: composite mcp_schema_registry · client binding - #2068

Merged
jfallows merged 22 commits into
developfrom
claude/zilla-schema-registry-mcp-62egyz
Jul 22, 2026
Merged

jfallows merged 22 commits into
developfrom
claude/zilla-schema-registry-mcp-62egyz

Conversation

@jfallows

@jfallows jfallows commented Jul 8, 2026 •

Copy link
Copy Markdown
Contributor

Description

mcp_schema_registry · client binding: a thin composite generator that exposes the Karapace/vanilla Schema Registry REST API as a fixed, LLM-optimised MCP tool set (list_subjects, describe_subject, get_schema, register_schema, delete_subject, delete_schema_version, check_compatibility, get_compatibility, set_compatibility).

Rather than reimplementing MCP tool-call handling, mcp_schema_registry (kind: client) generates a composite namespace containing:

  • an inline catalog with the bundled Schema Registry OpenAPI spec (9 operations, operationId values pre-set to the exact tool names)
  • an mcp_openapi (kind: client) binding, driven by that inlined spec, with the 9 tool → operation routes synthesized internally

The engine attaches the generated mcp_openapi binding through its own already-registered BindingFactorySpi, which does its own real OpenAPI parsing/tool-naming/composite generation — mcp_schema_registry itself never touches OpenAPI parsing, request/response body shaping, or path-param extraction; McpSchemaRegistryClientFactory is a pure pass-through relay (BEGIN/DATA/END/ABORT/RESET/WINDOW), mirroring McpOpenapiClientFactory.

The only required operator-facing config is options.server (the Schema Registry base URL) — no catalog:. routes: is optional and, when present, lets an operator scope and guard individual tools:

routes:
  - when:
      - tool: list_*          # name or glob, matches against the fixed 9-tool set
  - when:
      - tool: register_schema
    guarded:
      jwt0: [write]           # threaded through to the generated mcp_openapi0 route,
                               # resolved to an absolute namespace-qualified guard qname

Omitting routes: entirely exposes all 9 tools ungated (the original default). routes[].with stays disallowed — the operation mapping is always synthesized internally from the tool name, never operator-declared.

Building on #2103/#2105, which added guarded: support to mcp_openapi's own routes, independent of the underlying OpenAPI spec's security schemes — needed here since the bundled schema-registry spec declares no security schemes at all.

  • specs/binding-mcp-schema-registry.spec/ — JSON schema patch (kind: [client], catalog/vault/entry/exit disallowed, routes[].when[].tool + routes[].guarded allowed, routes[].with disallowed, options.server required), 18 .rpt scenario pairs (9 tools × mcp-side + http-side, using the zilla://streams/http0 k3po transport required to intercept nested composite-generated streams), invalid-config fixtures, and self-consistency IT classes.
  • runtime/binding-mcp-schema-registry/ — BindingFactorySpi, McpSchemaRegistryOptionsConfig/Adapter, McpSchemaRegistryConditionConfig/Adapter (the when.tool condition), McpSchemaRegistryCompositeGenerator (the composite namespace builder, including tool-name/glob matching and guard qname resolution), and McpSchemaRegistryClientFactory (the pass-through stream relay).

${result.*} summary interpolation

5 of the bundled spec's tool summaries now interpolate a confirmable value from the response, e.g. register_schema's summary is "Registered schema with id ${result.id}" (also get_schema, check_compatibility, get_compatibility, set_compatibility) — mirrors the existing mcp_openapi/mcp_http interpolation mechanism (see "Created pull request #${result.number}" precedent).

binding-mcp-http fix: result-wrapping decided from the real response shape, not schema presence

Implementing the interpolation above surfaced a real bug in McpHttpResultWrap (shared by every mcp_openapi/mcp_http-based binding, not just this one): when a tool's OpenAPI operation has no declared response schema, the transform unconditionally wrapped structuredContent as {"result": } regardless of whether the real response was already an object — a schema-presence decision, not a runtime-shape one. This meant any undeclared-schema operation whose response happens to already be a JSON object got a spurious wrapper, and (the symptom that surfaced it) ${result.*} interpolation paths were matched one depth level too shallow whenever that spurious wrap occurred.

Fixed by making McpHttpResultWrap peek the real body's own first event and decide from that: skip wrapping when it's already an object, wrap otherwise (arrays, scalars, or anything a declared array/scalar schema guarantees non-object). McpOpenapiCompositeGenerator's existing schema-presence check is unchanged in purpose — it still decides whether to install the transform at all (skipped entirely when a declared object schema statically proves it's never needed) — only the transform's own decision of whether to actually wrap is now runtime-shape-based. McpHttpToolConfig.outputWrapped is renamed to outputMaybeWrapped to reflect that the field now only gates installation, not behavior.

Touches runtime/binding-mcp-http/ (McpHttpResultWrap, McpHttpToolConfig, McpHttpProxyFactory, and McpHttpResultWrapTest) and runtime/binding-mcp-openapi/ (the composite generator's call site and its test) in addition to the new binding itself.

list_contexts removed — Confluent-specific, not part of vanilla Schema Registry

The bundled spec originally also included a list_contexts tool (GET /contexts). Verified against the real Aiven-Open/karapace implementation (zero references to /contexts in its source) and a live Karapace 3.15.2 instance (404) that this endpoint is a Confluent Platform/Confluent Cloud "Schema Contexts" feature, not part of the open API surface Karapace implements. Since binding-mcp-schema-registry targets vanilla/Karapace-compatible Schema Registry deployments, list_contexts has been removed from the bundled OpenAPI spec, the composite generator's tool list, and all associated tests/fixtures. A future Confluent-specific mcp-confluent-schema-registry binding in zilla-plus, mirroring the existing confluent-schema-registry catalog split, is the intended home for this and other Confluent-only behavior.

Fixes #1672

Test plan

  • ./mvnw clean install -pl specs/binding-mcp-schema-registry.spec — 22/22 tests pass (4 schema validation + 9 mcp-side + 9 http-side self-consistency)
  • ./mvnw clean verify -pl runtime/binding-mcp-schema-registry — 9/9 integration test scenarios pass end-to-end against a real engine through the full nested composite (mcp_schema_registry → mcp_openapi → mcp_http), including request/response bodies for the 3 body-bearing tools and interpolated summaries for the 5 tools above; plus composite-generator (default all-unguarded, reduced scope, guarded route with qname resolution, no-match), options-adapter, and configuration unit tests; checkstyle, license headers, NOTICE, and JaCoCo all pass
  • ./mvnw clean verify -pl runtime/binding-mcp-http and ./mvnw clean verify -pl runtime/binding-mcp-openapi — full suites green after the result-wrapping fix, confirming no regression for existing array/scalar-response and declared-schema tools

Known gaps acknowledged as out of scope for this PR: no tools/list support yet, and spec coverage is happy-path + config-validation only. A kind: proxy variant (operator-declared exit instead of options.server) is tracked separately as #2104.


Generated by Claude Code

claude added 2 commits July 8, 2026 23:52
#1672

Adds specs/binding-mcp-schema-registry.spec/ (schema patch, 20 mcp/http
.rpt scenario pairs for the 10 bundled tools, config fixtures, self
consistency ITs — all green) and runtime/binding-mcp-schema-registry/
module scaffold, wired into runtime/specs/docker-image poms. No Java
implementation yet by design: the runtime IT currently fails with an
unrecognized binding type, the expected checkpoint before implementation
begins per the repo's test-first discipline.

Design: kind: proxy emitting the real OpenapiBeginEx wire extension to an
operator-declared `type: openapi, kind: client` exit, mirroring the
binding-openapi-asyncapi precedent, using an internally-bundled spec to
resolve tool -> operationId with zero operator catalog boilerplate.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01HL4h3tkf4oYSdjEgK4zffn
…y binding

Adds the BindingFactorySpi, config adapters, and stream handler
(McpSchemaRegistryProxyFactory) that map the 10 bundled MCP tools onto
Schema Registry OpenAPI operations, forwarding through an operator-declared
openapi client exit per the mcp-natural design in #1672.

Also fixes escaping bugs in the .rpt fixtures: k3po strips a single
backslash-quote in single-quoted write/read literals, so scripts embedding
a JSON-quoted string value (the "schema" field) need \\" to produce a
literal \" on the wire. This was silently truncating declared contentLength
and corrupting response bodies for get_schema/register_schema/
check_compatibility. Also fixes the request-body flush to respect
initial-window flow-control credit instead of writing the full body
unconditionally on the first WINDOW frame.

Fixes #1672
@jfallows jfallows self-assigned this Jul 9, 2026
@jfallows
jfallows marked this pull request as ready for review July 9, 2026 03:16
@jfallows jfallows removed their assignment Jul 9, 2026
claude added 2 commits July 9, 2026 04:04
The module was already wired into runtime/pom.xml, specs/pom.xml, and
cloud/docker-image/pom.xml, but missing from the zpm packaging manifest,
so it would not have been installed into the published Docker image.
…per around mcp_openapi

Replace the hand-rolled MCP proxy implementation with a kind:client
composite generator that inlines a bundled schema-registry OpenAPI spec
into a generated catalog and drives it through an mcp_openapi kind:client
binding, mirroring how binding-openapi's own kind:client generates its
downstream bindings. The 10 tools are fixed and author-controlled, so
routes and tool naming are synthesized internally rather than exposed as
operator-facing config; the only remaining option is options.server.

McpSchemaRegistryClientFactory is now a pure pass-through relay (no
protocol awareness), matching McpOpenapiClientFactory. Spec fixtures were
rewritten to the zilla://streams/http0 k3po transport (required for the
external-exit test double to intercept nested composite-generated
streams) and structuredContent shapes corrected to match mcp_openapi's
verbatim JSON passthrough behavior.
@jfallows jfallows changed the title binding-mcp-schema-registry: spec-first scaffold for mcp_schema_registry · proxy binding binding-mcp-schema-registry: composite mcp_schema_registry · client binding Jul 10, 2026
claude added 2 commits July 10, 2026 04:37
… key

mcp_openapi/mcp_http on current develop always wraps tool-call
structuredContent under a top-level "result" key, regardless of the
underlying HTTP response shape (object, array, or scalar) - a behavior
change picked up by merging develop (most likely from the common-json
parsson removal). Update all 10 scenarios' mcp-side fixtures to match.
claude added 16 commits July 10, 2026 07:16
Allow operators to scope and guard individual tools via routes[], on
top of #2103/#2105's new mcp_openapi routes[].guarded support:

- routes[].when[].tool accepts a tool name or glob pattern (mirrors
  mcp_openapi's own when.tool schema - a singular string, not an
  array, since when[] is already the "match any of several"
  mechanism)
- routes[].guarded threads through to the generated mcp_openapi0
  route, resolved to an absolute namespace-qualified guard qname
  since the guard is declared in the operator's outer namespace but
  the generated route lives in the nested composite namespace
- with omitting routes entirely still exposes all 10 tools ungated
  (unchanged default); declaring routes narrows exposure to only the
  tools matched by a when.tool entry

routes[].with stays disallowed - the operation mapping is still
synthesized internally from the tool name, never operator-declared.
…mmaries

Add explicit response schemas to register_schema, get_schema,
check_compatibility, get_compatibility, and set_compatibility in the bundled
OpenAPI spec, and interpolate their tool summaries with the confirmable
result value (e.g. "Registered schema with id ${result.id}").

Declaring the response schema is required, not cosmetic: without it,
McpOpenapiCompositeGenerator treats the tool output as schema-less and wraps
structuredContent as {"result": <value>}, shifting every capture path down
one level and making ${result.*} resolve empty.
…shape

McpHttpResultWrap previously wrapped structuredContent as {"result": <value>}
whenever no declared object response schema existed, regardless of what the
upstream API actually returned. Any undeclared-schema operation whose real
response happened to already be an object got a spurious wrapper.

Make the decision from the real body's own first event instead: skip
wrapping when it's already an object, wrap otherwise (arrays, scalars, or
anything a declared array/scalar schema guarantees non-object). Rename
McpHttpToolConfig.outputWrapped to outputMaybeWrapped to reflect that the
field now only gates whether the transform is installed, not what it does.

Backs out the karapace-schema-registry.openapi.json response-schema
additions from the previous commit -- declaring schemas was a workaround for
this bug, not the real fix. ${result.*} interpolation in the 5 tool
summaries now works via the runtime fix alone, with no schema required.
Our spec and runtime modules were created before develop's bulk
copyright-year-update (#2183) landed, so their license headers still said
2021-2024 while the rest of the repo now says 2021-2026. license:format
brings both modules in line.
…y, not in vanilla/Karapace Schema Registry)

GET /contexts ("Schema Contexts") is a Confluent Platform/Confluent Cloud
extension, absent from the Aiven-Open/karapace source and 404s against a
live Karapace instance. binding-mcp-schema-registry targets vanilla/Karapace
Schema Registry, so drop list_contexts from the bundled OpenAPI spec, the
composite generator's tool list, and all associated tests/fixtures.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01HL4h3tkf4oYSdjEgK4zffn
… Karapace

Extends the multi-toolkit MCP gateway example with an mcp_schema_registry
kind:client binding wired against a real Karapace Schema Registry (not a
mock) sharing the example's existing Kafka broker. Adds the
south_mcp_schema_registry_client binding/routes, the karapace-registry
compose service, README documentation (architecture diagram, authorization
layering, walkthrough), and .github/test.sh assertions covering
tools/list scope filtering plus a full register -> list -> describe ->
get_schema -> set_compatibility -> get_compatibility -> check_compatibility
call sequence against the live Karapace instance.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01HL4h3tkf4oYSdjEgK4zffn
Every existing scenario only exercised tools/call by name; tools/list was
never tested for this binding. Add shouldListTools, driving a bare
mcp:beginEx().toolsList() request directly against the binding's own accept
side and asserting the full nine-tool set with correct input schemas comes
back.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01HL4h3tkf4oYSdjEgK4zffn
…ix tools/list hydration

Renames the schema-registry toolkit's routing key from "schemaregistry" to
"kafka_sr" throughout north_mcp_proxy's routes, the eager tools.match list,
JWT scope examples, README, and .github/test.sh.

While validating this end-to-end, tools/list never surfaced any of the
toolkit's tools (not even as a cold/searchable tool), though tools/call by
name worked fine. Root cause: north_mcp_proxy.options.cache.authorization's
hardcoded hydration JWT never had its scope updated to include
kafka_sr:tools when this toolkit was added -- its guard silently rejected
the hydration stream while every other toolkit's required scope happened
to already be present in that credential. tools/call was unaffected
because real calls use the caller's own JWT, not this shared one. Minted a
new hydration credential including kafka_sr:tools and added a comment
warning that every new guarded toolkit must be added here too.

Full .github/test.sh run against the real stack (including live Karapace)
now passes 25/25 with zero failures.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01HL4h3tkf4oYSdjEgK4zffn
@jfallows
jfallows merged commit b776dd6 into develop Jul 22, 2026
42 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

binding-mcp-schema-registry: implement mcp_schema_registry · proxy binding

2 participants