Repository navigation
mcp: typed stdio tool gateway (first slice, 30 tools) - #522
Merged
Merged
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this adds
A first-slice MCP core for Carbon Panel:
cmd/carbonpanel-mcp(stdio) andinternal/mcp.carbonpanelv1connect.New<Service>Client; no hand-rolled product HTTP. Adp_…token fromCARBONPANEL_API_TOKEN(orCARBONPANEL_TOKEN) is sent as a Bearer header, withCARBONPANEL_URLas the controller endpoint. Missing credentials stop startup.Clients.VerifycallsGetAuthStatus(requires a real auth provider) andGetCurrentUser(requires a concrete active user identity). A well-formed token against a no-auth installation is refused. All calls use a boundedhttp.Client(30s).list_servers,get_server,start_server,stop_server,restart_server(mutations requireconfirm=true).list_players,get_player,list_player_capabilities,get_player_skin.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.list_world_view_targets,get_world_view_status,list_world_view_capabilities,list_map_overlays.list_backups,restore_backup(confirm-gated).list_files,get_file. No write tools.Unimplemented(and an explicitly identified transport-levelNotFound) produce a structuredcapability_unavailableerror naming the procedure and minimum build; a domainNotFoundproducesnot_foundand never claims an upgrade is needed. No tool hiding, no false success.post-v1.0.40+fa23a8d73c181f9907633024d9023aead928324e; smoke tools use pre-v1.0.40 read RPCs. No auto-detection or channel switching.Coverage drift gate
TestCoverageDriftGateenumerates 25 mounted services / 220 reachable RPCs from the shared mount list ininternal/mcp/catalog.go(mirroringinternal/rpc/server.go registerServices, also verified by a source-parsing test). It fails on missing or extra declared tuples, compares every declared scope to liveinternal/rbac, pins a proto descriptor fingerprint (202c7152b9f81f8c1b6b3c0fcafcda05dec7a49b45a2d6a80fccbef13e2ae9ea), assertsNodeControlServiceis unmounted andWorldViewServiceis included. gRPC reflection (19) and the 24-service RBAC parity list are not used as sources.Evidence
go build ./...— passgo vet ./...— passgo test ./... -count=1— pass (no FAIL lines)go test ./internal/mcp/... ./cmd/carbonpanel-mcp/... ./internal/rpc/... -count=1— passgo run ./cmd/knowledge-lint -root . -fixthen without-fix— 38/38 queries, 66 concepts, indexes currentTestCoverageDriftGate,TestSharedMountListMatchesServerRegistrations,TestNewServiceFamiliesRequirePostStableBuild— passTestToolFamiliesSuccessAndStructuredAuthErrors— 6 families × success / structuredpermission_denied/ structuredunauthenticated— passTestStableBuildSmokeAndCapabilityErrors(unimplemented + transport-notfound),TestDomainNotFoundIsNotACapabilityError,TestNoAuthPanelIsRefusedEvenWithWellFormedToken,TestBoundedBackendTimeout,TestConfirmationGateAndBoundedArguments— passTestRealStdioBinaryToolCall,TestRealStdioBinaryFailsClosedWithoutToken— real SDKCommandTransportsubprocess against the actual binary — passTestAuthInterceptorExtractionParity— 7 cases comparing the extracted interceptor to the pre-extraction body byte-for-byte (public, authenticated-only, unauthenticated, scoped allow/deny, unmapped, nil enforcer) — passInterceptor refactor
Server.authInterceptornow delegates to exportedrpc.NewAuthInterceptor, so fixtures use the production authorization path.TestAuthInterceptorExtractionParityproves identical Connect code and error message for all tested cases.Distribution coordination
cmd/carbonpanel-mcp(packagemain). 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>).-versionprints them. No rename.list_servers) against anyCARBONPANEL_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-formSendCommand, or file writes. Nothing here touches the Docker Hub ormcp-distlanes. No deployment, release, merge or live service/data use.Independent review and CI required; please do not merge until both are green.