Skip to content

mcp: typed stdio tool gateway (first slice, 30 tools) - #522

Merged
athNdev merged 2 commits into
mainfrom
codex/mcp-core
Nov 18, 2026
Merged

athNdev merged 2 commits into
mainfrom
codex/mcp-core

Conversation

@athNdev

@athNdev athNdev commented Nov 18, 2026

Copy link
Copy Markdown
Owner

What this adds

A first-slice MCP core for Carbon Panel: cmd/carbonpanel-mcp (stdio) and internal/mcp.

  • Typed clients only. Every tool calls a generated carbonpanelv1connect.New<Service>Client; no hand-rolled product HTTP. A dp_… token from CARBONPANEL_API_TOKEN (or CARBONPANEL_TOKEN) is sent as a Bearer header, with CARBONPANEL_URL as the controller endpoint. Missing credentials stop startup.
  • Auth readiness. Before any tool is exposed, Clients.Verify calls GetAuthStatus (requires a real auth provider) and GetCurrentUser (requires a concrete active user identity). A well-formed token against a no-auth installation is refused. All calls use a bounded http.Client (30s).
  • 30 tools / FIRST SLICE. Inventory coverage is not implemented API coverage; OSS-370 remains open for the remaining supported families.
    • Lifecycle: list_servers, get_server, start_server, stop_server, restart_server (mutations require confirm=true).
    • Player: list_players, get_player, list_player_capabilities, get_player_skin.
    • World library/bindings: list_world_entries, get_world_entry, list_world_revisions, get_world_revision, list_world_bindings, get_world_binding, list_import_jobs, get_import_job, check_world_compatibility, get_world_config_schema, preview_world_config, search_world_artifacts, get_provider_capabilities.
    • World view: list_world_view_targets, get_world_view_status, list_world_view_capabilities, list_map_overlays.
    • Backup: list_backups, restore_backup (confirm-gated).
    • File read-only: list_files, get_file. No write tools.
  • Honest capability errors. The catalog is identical on every panel build. Unimplemented (and an explicitly identified transport-level NotFound) produce a structured capability_unavailable error naming the procedure and minimum build; a domain NotFound produces not_found and never claims an upgrade is needed. No tool hiding, no false success.
  • Capability qualification. Player/World/WorldView families are marked post-v1.0.40+fa23a8d73c181f9907633024d9023aead928324e; smoke tools use pre-v1.0.40 read RPCs. No auto-detection or channel switching.

Coverage drift gate

TestCoverageDriftGate enumerates 25 mounted services / 220 reachable RPCs from the shared mount list in internal/mcp/catalog.go (mirroring internal/rpc/server.go registerServices, also verified by a source-parsing test). It fails on missing or extra declared tuples, compares every declared scope to live internal/rbac, pins a proto descriptor fingerprint (202c7152b9f81f8c1b6b3c0fcafcda05dec7a49b45a2d6a80fccbef13e2ae9ea), asserts NodeControlService is unmounted and WorldViewService is included. gRPC reflection (19) and the 24-service RBAC parity list are not used as sources.

Evidence

  • go build ./... — pass
  • go vet ./... — pass
  • go test ./... -count=1 — pass (no FAIL lines)
  • go test ./internal/mcp/... ./cmd/carbonpanel-mcp/... ./internal/rpc/... -count=1 — pass
  • go run ./cmd/knowledge-lint -root . -fix then without -fix — 38/38 queries, 66 concepts, indexes current
  • TestCoverageDriftGate, TestSharedMountListMatchesServerRegistrations, TestNewServiceFamiliesRequirePostStableBuild — pass
  • TestToolFamiliesSuccessAndStructuredAuthErrors — 6 families × success / structured permission_denied / structured unauthenticated — pass
  • TestStableBuildSmokeAndCapabilityErrors (unimplemented + transport-notfound), TestDomainNotFoundIsNotACapabilityError, TestNoAuthPanelIsRefusedEvenWithWellFormedToken, TestBoundedBackendTimeout, TestConfirmationGateAndBoundedArguments — pass
  • TestRealStdioBinaryToolCall, TestRealStdioBinaryFailsClosedWithoutToken — real SDK CommandTransport subprocess against the actual binary — pass
  • TestAuthInterceptorExtractionParity — 7 cases comparing the extracted interceptor to the pre-extraction body byte-for-byte (public, authenticated-only, unauthenticated, scoped allow/deny, unmapped, nil enforcer) — pass

Interceptor refactor

Server.authInterceptor now delegates to exported rpc.NewAuthInterceptor, so fixtures use the production authorization path. TestAuthInterceptorExtractionParity proves identical Connect code and error message for all tested cases.

Distribution coordination

  • Canonical command path is cmd/carbonpanel-mcp (package main). Version variables for ldflags: main.version, main.commit, main.buildDate (e.g. -X main.version=v0.1.0 -X main.commit=<sha> -X main.buildDate=<rfc3339>). -version prints them. No rename.
  • The stdio binary exposes the unmodified 30-tool catalog and a read-only smoke path (list_servers) against any CARBONPANEL_URL/token fixture. Dist lane owns all publication; this PR does not publish or announce.

Boundaries

EXCLUDE list intact: no NodeControlService, node discovery/scan, enrollment/TLS/secrets, browser/WebSocket handshakes, OIDC exchange, health endpoints, operator maintenance, free-form SendCommand, or file writes. Nothing here touches the Docker Hub or mcp-dist lanes. No deployment, release, merge or live service/data use.

Independent review and CI required; please do not merge until both are green.

Add cmd/carbonpanel-mcp and internal/mcp: a first slice of 30 bounded,
fail-closed operator tools built only on generated Connect clients with a
dp_ API-token bearer credential. The catalog is stable across panel builds;
unimplemented RPCs become structured capability errors while domain NotFound
stays honest. Verify auth provider and token identity before serving, and
bound all controller calls with an HTTP timeout.

Add a deterministic drift gate over the 25 mounted services / 220 RPCs with
live RBAC scope assertions, a pinned descriptor fingerprint, and explicit
NodeControl-excluded / WorldView-included checks. Fixtures drive a real MCP
client over the stdio wire against httptest Connect handlers behind the
production auth interceptor, plus a subprocess CommandTransport smoke.

Extract the shared fail-closed interceptor to internal/rpc.NewAuthInterceptor
with a byte-for-byte parity test against the previous implementation.

Update knowledge concepts for the new gateway and capability decision.
- check Close and structured-error helper returns in fixtures (errcheck)
- use fmt.Fprintf in catalog generator per QF1012
- remove unused specFor helper
@athNdev
athNdev merged commit 17729f7 into main Nov 18, 2026
21 checks passed
@athNdev
athNdev deleted the codex/mcp-core branch November 18, 2026 08:27
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.

1 participant