Repository navigation
feat(mcp): DCR client mode for the broker's MCP OAuth surface - #1244
Conversation
JAORMX
left a comment
There was a problem hiding this comment.
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-13docs/development-process.md:47-53docs/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
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]>
4380bd9 to
25d4e1b
Compare
JAORMX
left a comment
There was a problem hiding this comment.
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:
dcrremains a closedpermconfigunion 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
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]>
Summary
Adds
dcras a thirdmcp.servers[].auth.oauth.client.mode, alongside theexisting
preregisteredandcimdmodes, exposing ToolHive's existing RFC7591 Dynamic Client Registration upstream-client support
(
authserver.OAuth2UpstreamRunConfig.DCRConfig) so an operator can pointmecak8s 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 logoutput on either success or failure, making "backend legitimately returned
zero tools" indistinguishable from "discovery silently failed" without
inspecting raw Redis state.
docs/acceptance/mcp-broker-dcr-client.md(all 3 Human decisions resolved and recorded)docs/adr/0314-mcp-broker-dcr-client.md— reconciles this with ADR 0219/0220's prior DCR exclusion (that exclusion targeted the go-sdk's non-durable per-flow DCR; ToolHive'spkg/auth/dcrresolver has its own durable registration cache, which is the gate 0219/0220 said was missing)Both the DCR client mode and the logging fix were verified against a real,
live
connector-gateway.stacklok.devdeployment 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=Nlog line fires correctly.Development stage
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
docs/acceptance/mcp-broker-dcr-client.mda6796ccfc3551bd9f583f8d3501f7079a99a05efInterface conformance
permconfig.MCPOAuthClientProfilegains adcrvariant + newMCPDCRClientProfile;mcpbroker.ToolHiveOAuthandtoolhive_construction.go'stoolHiveUpstreamgain DCR conversion (a genuine restructuring of its previously-unconditionalClientID-required guard).mcpbroker.ToolHiveConfigalso gains an optionalDiagnostics port.Diagnosticsfield (the logging fix), nil-safe via a newProcess.diagnostics()accessor.mcp.servers[].auth.oauth.client.mode: dcrwithdcr: {discovery_url}(discovery-URL-only for v1) and a required explicitupstream: {mode: oauth2, ...}(a bareissueris rejected fordcrat config-validation time, since ToolHive's library has no DCR-on-OIDC-upstream path). Mirrored in the Helm chart schema/templates andinternal/configgen's generated reference.preregistered/cimdunchanged.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 —
InitialAccessTokenis re-read fresh fromits configured source on every resolution attempt), and an explicit
registration_endpointalternative todiscovery_url.Issue relationship
No tracking issue yet.
Type of change
Test plan
Baseline checks
bash .claude/skills/to-acceptance-plan/scripts/check-acceptance-plan.sh docs/acceptance/mcp-broker-dcr-client.md)go test ./internal/adapter/mcpbroker/... ./internal/app/...)matlatl check . --strict— 0 broken links/anchors/orphans/unreachable)mecak8spointed atconnector-gateway.stacklok.dev: real DCR registration, real Okta-federated consent, confirmed the new discovery-outcome log line fires with the correct backend/tool-counttask lint— not run standalone in this session;go build ./...andgo vet ./internal/...are cleantask test— not run standalone in this session (ran the specific touched packages instead)Changes
internal/adapter/permconfig/schema.godcrclient mode +MCPDCRClientProfileinternal/adapter/mcpbroker/toolhive_construction.go,toolhive_process.goDCRConfig;Diagnosticsthreadinginternal/adapter/mcpbroker/workspace_catalogue.gointernal/app/mcp_broker_toolhive.go,build.godeploy/helm/mecak8s/values.schema.json,templates/_helpers.tpldcrinternal/configgen/build.godocs/usage/mecak8s.md,docs/configuration-reference.md,user-docs/features/mcp-oauth-and-credentials.mddcrexample + reference docsUser-facing change
Operators can now configure
mcp.servers[].auth.oauth.client.mode: dcrtoconnect 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
dcrshould ever support anexplicit
registration_endpointalongsidediscovery_url. Both aredeferred with recorded rationale in the plan's Human decisions section.