Skip to content

feat(mcp): DCR client mode for the broker's MCP OAuth surface - #1244

Merged
jhrozek merged 3 commits into
mainfrom
plan/mcp-broker-dcr-client
Sep 8, 2026
Merged

jhrozek merged 3 commits into
mainfrom
plan/mcp-broker-dcr-client

Conversation

@jhrozek

@jhrozek jhrozek commented Sep 8, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Adds dcr as a third mcp.servers[].auth.oauth.client.mode, alongside the
existing preregistered and cimd modes, exposing ToolHive's existing RFC
7591 Dynamic Client Registration upstream-client support
(authserver.OAuth2UpstreamRunConfig.DCRConfig) so an operator can point
mecak8s at a protected MCP upstream (e.g. a ToolHive-hosted connector
gateway) whose authorization server supports DCR, without hand-registering a
client or hosting a CIMD document.

Also fixes a real, separately-discovered observability gap in the broker's
existing catalogue-freeze path (affects all three client modes, not just
dcr): authenticated discovery for a protected backend produced zero log
output on either success or failure, making "backend legitimately returned
zero tools" indistinguishable from "discovery silently failed" without
inspecting raw Redis state.

Both the DCR client mode and the logging fix were verified against a real,
live connector-gateway.stacklok.dev deployment on a local Kind cluster —
including a genuine RFC 7591 registration, a real company-Okta-federated
consent round, and confirming the new authenticated discovery succeeded backend=connector_gateway tools=N log line fires correctly.

Development stage

  • Implementation — based on an approved, merged Plan / Interface PR

This PR was rebased onto the merged Plan / Interface PR (#1260) per
JAORMX's review feedback —
the docs/ADR-only commits are gone from this diff (fully absorbed by #1260's
squash-merge); only implementation remains.

Contract linkage

  • Acceptance plan: docs/acceptance/mcp-broker-dcr-client.md
  • Human decisions resolved and recorded: Yes (3/3, all checked with recorded decisions)
  • Plan / Interface PR: docs(acceptance): MCP broker DCR client — Plan / Interface #1260
  • Approved commit baseline: a6796ccfc3551bd9f583f8d3501f7079a99a05ef
  • Combined/exemption rationale: n/a (Split)

Interface conformance

  • gRPC/protobuf: none.
  • Exported Go APIs: permconfig.MCPOAuthClientProfile gains a dcr variant + new MCPDCRClientProfile; mcpbroker.ToolHiveOAuth and toolhive_construction.go's toolHiveUpstream gain DCR conversion (a genuine restructuring of its previously-unconditional ClientID-required guard). mcpbroker.ToolHiveConfig also gains an optional Diagnostics port.Diagnostics field (the logging fix), nil-safe via a new Process.diagnostics() accessor.
  • Tool schemas: none.
  • CLI/config: new mcp.servers[].auth.oauth.client.mode: dcr with dcr: {discovery_url} (discovery-URL-only for v1) and a required explicit upstream: {mode: oauth2, ...} (a bare issuer is rejected for dcr at config-validation time, since ToolHive's library has no DCR-on-OIDC-upstream path). Mirrored in the Helm chart schema/templates and internal/configgen's generated reference.
  • Events/persistence: none — DCR credentials live entirely in ToolHive's own existing storage.
  • Security/authority: DCR client identity is minted by the upstream at registration time rather than operator-asserted; HTTPS-only, no private-IP/insecure-HTTP escape hatch, matching the existing OAuth invariant. Separately: the new discovery-outcome log lines are metadata-only (backend name + tool count), never token/credential material.
  • Compatibility/migration: additive only; preregistered/cimd unchanged.

Deferred (see plan's Human decisions + Out of scope): DCR initial-access-token
support (confirmed with ToolHive that deferring this is a clean scope cut,
not a caching-gap workaround — InitialAccessToken is re-read fresh from
its configured source on every resolution attempt), and an explicit
registration_endpoint alternative to discovery_url.

Issue relationship

No tracking issue yet.

Type of change

  • New feature
  • Bug fix
  • Documentation/process

Test plan

Baseline checks

  • Acceptance-plan checker (bash .claude/skills/to-acceptance-plan/scripts/check-acceptance-plan.sh docs/acceptance/mcp-broker-dcr-client.md)
  • Offline test suite for the touched packages (go test ./internal/adapter/mcpbroker/... ./internal/app/...)
  • Markdown changed: docs generation/link checks (ADR-uniqueness/stale-slug Go tests; matlatl check . --strict — 0 broken links/anchors/orphans/unreachable)
  • Live manual verification against a real Kind-deployed mecak8s pointed at connector-gateway.stacklok.dev: real DCR registration, real Okta-federated consent, confirmed the new discovery-outcome log line fires with the correct backend/tool-count
  • task lint — not run standalone in this session; go build ./... and go vet ./internal/... are clean
  • Full task test — not run standalone in this session (ran the specific touched packages instead)

Changes

File Change
internal/adapter/permconfig/schema.go New dcr client mode + MCPDCRClientProfile
internal/adapter/mcpbroker/toolhive_construction.go, toolhive_process.go DCR conversion into ToolHive's DCRConfig; Diagnostics threading
internal/adapter/mcpbroker/workspace_catalogue.go Per-backend authenticated-discovery log lines (the logging fix, covers all 3 client modes)
internal/app/mcp_broker_toolhive.go, build.go Composition wiring for both the DCR conversion and Diagnostics
deploy/helm/mecak8s/values.schema.json, templates/_helpers.tpl Helm chart schema/rendering for dcr
internal/configgen/build.go Generated settings.yaml reference
docs/usage/mecak8s.md, docs/configuration-reference.md, user-docs/features/mcp-oauth-and-credentials.md Worked dcr example + reference docs

User-facing change

Operators can now configure mcp.servers[].auth.oauth.client.mode: dcr to
connect mecak8s to a protected MCP upstream that supports RFC 7591 Dynamic
Client Registration, without pre-registering a client or hosting a CIMD
document. Separately, operators get a new log line
(authenticated discovery succeeded/failed backend=<name> tools=<n>)
diagnosing why a configured protected backend's tools are or aren't showing
up, for all client modes.

Special notes for reviewers

Rebased onto the merged plan baseline per review feedback — see the
Development stage note above. Two open, non-blocking follow-ups recorded in
the plan itself (not this PR's scope): whether to plumb ToolHive's optional
DCR initial-access-token support, and whether dcr should ever support an
explicit registration_endpoint alongside discovery_url. Both are
deferred with recorded rationale in the plan's Human decisions section.

@JAORMX JAORMX left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Panel review

Standards — blocker

This PR explicitly declares Split delivery, then says implementation was performed directly on this branch with no approved, merged Plan / Interface PR or baseline. That misses the required review checkpoint for substantive interface- and security-bearing work (operator YAML/Helm configuration plus OAuth/DCR registration behavior). The Combined exception cannot apply: the acceptance plan itself declares Split and the runtime/config/security categories are material.

Please move the plan/interface contract through its own reviewed-and-merged PR, then open the implementation PR from that approved baseline. The direct implementation branch should not merge as the Split implementation delivery.

  • docs/acceptance/mcp-broker-dcr-client.md:5-13
  • docs/development-process.md:47-53
  • docs/adr/0306-human-reviewed-development-contracts.md:67-80

Other axes

  • Spec: unable to independently inspect the PR head in a local worktree in this environment; the supplied diff is consistent with the stated DCR surface, but this is not a completed spec sign-off.
  • Test adequacy: likewise not independently completed against a checked-out PR head. GitHub CI is green (30/32 applicable checks; the two live/perf-main jobs are intentionally skipped).
  • Domain: no concrete security, architecture, Helm, reuse, or duplication blocker was established from the reviewable diff excerpts. Several specialist reviewers could not access the PR head and are recorded as review gaps, not findings.

PANEL: ship_blockers=1 important=0 advisory=0 reviewer_failures=5

jhrozek and others added 3 commits September 8, 2026 19:20
Expose ToolHive's durable RFC 7591 registration resolver as the third MCP broker OAuth client mode, alongside preregistered and CIMD clients. This lets an operator enroll against a DCR-capable protected upstream without registering or hosting a client identity themselves.

Validate the closed configuration union, require HTTPS discovery and an explicit OAuth2 upstream, and pass the discovery URL through composition into ToolHive's DCR configuration with its insecure/private-IP defaults intact. Helm and generated/user documentation expose the same operator shape.

Prove metadata discovery, registration, enrollment, bearer injection, fail-closed registration failure, and cross-Process Redis-backed registration reuse. The hermetic protocol fixture uses ToolHive's loopback development exception because v0.45.0 provides no DCR custom-CA/client seam; the public configuration remains HTTPS-only.

Co-Authored-By: mecatl <[email protected]>
The broker's catalogue-freeze loop collapsed every authenticated
discovery outcome (success or failure, for any client mode:
preregistered/cimd/dcr) into total silence — no log line named which
backend was queried, whether it succeeded, or how many tools it
returned. A backend that authenticates fine but legitimately exposes
zero tools was indistinguishable from a genuine discovery failure
without inspecting raw Redis state and replaying tokens by hand.

Thread port.Diagnostics through ToolHiveConfig -> Process (nil-safe via
a Process.diagnostics() accessor, defaulting to NopDiagnostics for both
an unset config value and a test fixture built without going through
newToolHiveProcess) and log one INFO/WARN line per backend at the
existing stageAuthenticatedRoutes choke point.

Co-Authored-By: mecatl <[email protected]>
origin/main's #1239 landed its own ADR 0313 (interim GitHub Packages
distribution for the TypeScript SDK) after this branch's ADR 0313
(Dynamic Client Registration for MCP broker upstreams) was drafted.
Renumber ours, never an already-landed main ADR, and fix every
cross-reference (docs/adr/README.md, IMPLEMENTATION-NOTES.md, the
acceptance plan, and the TestADR_0313_* -> TestADR_0314_* test names).

Co-Authored-By: Claude Sonnet 5 <[email protected]>
@jhrozek
jhrozek force-pushed the plan/mcp-broker-dcr-client branch from 4380bd9 to 25d4e1b Compare September 8, 2026 17:22

@JAORMX JAORMX left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Follow-up review — rebased head 25d4e1b

The earlier process blocker is resolved: this implementation is now based on merged Plan / Interface PR #1260 (a6796ccfc3551bd9f583f8d3501f7079a99a05ef).

I rechecked the current PR diff's config, conversion, Helm, and test coverage:

  • dcr remains a closed permconfig union arm and requires an HTTPS, non-root discovery document plus an explicit OAuth2 upstream; it rejects OIDC/issuer and client-identity combinations.
  • Composition carries the DCR declaration only to the broker's DCRConfig; production keeps ToolHive's HTTP/private-IP defaults closed. The loopback relaxation is confined to unexported integration-test options.
  • Helm validation/rendering reflects the same DCR shape, and the implementation includes strict-config, rendering, conversion, registration/enrollment, reuse, and no-fallback tests.
  • The broker diagnostics contain metadata only (backend and tool count), not credentials.
  • All applicable CI checks on this head are green; live and perf-main jobs are intentionally skipped.

No concrete remaining merge blocker found.

PANEL: ship_blockers=0 important=0 advisory=0 reviewer_failures=0

@jhrozek
jhrozek merged commit 97ac1c3 into main Sep 8, 2026
33 checks passed
@jhrozek
jhrozek deleted the plan/mcp-broker-dcr-client branch September 8, 2026 18:55
jhrozek added a commit that referenced this pull request Sep 8, 2026
origin/main's #1239 landed ADR 0313 (interim GitHub Packages
distribution), and this session's own #1244 landed ADR 0314, both after
this branch's ADR 0313 (server-owned discovered OIDC scopes) was
drafted. Renumber ours, never an already-landed main ADR, fix every
cross-reference, and record ADR 0305's now-partial supersession by the
renumbered ADR.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
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.

2 participants