feat: add dcd-mcp stdio MCP server#25
Merged
Merged
Conversation
Ship a second bin (dcd-mcp) that exposes the CLI's service layer to MCP clients (Claude, Cursor, VS Code) over stdio. Reuses resolveAuth, the gateways, and the existing release pipeline — no auth or publish rebuild. Tools: dcd_list_devices, dcd_list_runs, dcd_get_status, dcd_download_artifacts (read-only), and dcd_run_cloud_test (billable, async-by-default, destructive-annotated, gated by --read-only / DCD_MCP_READONLY). - src/mcp/: index/server/context/helpers + one file per tool. stdout is the JSON-RPC channel, so tools call services/gateways directly with a stderr logger, never the commands layer or utils/cli logger. - Extract computeCommonRoot/buildTestMetadataMap into src/services/flow-paths.ts and reuse from cloud.ts so the CLI and MCP build identical server-side paths. - Telemetry: mcp tool invoked/completed/failed events (async flush). - Tests: flow-paths unit tests + a stdio integration suite driving the built bin with the real MCP client against the mock API. - Docs: README MCP section, server.json registry manifest, CLAUDE.md. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Code reviewNo issues found. Checked for bugs and CLAUDE.md compliance. |
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
Adds a local stdio MCP server shipped as a second bin (
dcd-mcp) inside@devicecloud.dev/dcd, so AI agents (Claude, Cursor, VS Code) can drive devicecloud.dev. It's a third front-end onto the existing service layer — a sibling tosrc/commands/— reusingresolveAuth, the gateways, and the same release-please pipeline. No auth or publishing rebuild.Tools
dcd_list_devicesdcd_list_runsdcd_get_statusdcd_download_artifactsdcd_run_cloud_testdcd_run_cloud_testis async-by-default (returnsuploadId, polldcd_get_status), annotated destructive, and hidden under--read-only/DCD_MCP_READONLY=1. It also supportswait(bounded) anddryRun.Design notes
src/commands/*layer orutils/clilogger(both write stdout / canprocess.exit). Results go back viajsonResult/errorResult;runToolrecords telemetry and converts thrown errors toisErrorresults.DEVICE_CLOUD_API_KEYenv or storeddcd loginsession;DCD_API_URLoverrides the base URL. Resolved lazily + once, sotools/listworks unauthenticated.computeCommonRoot/buildTestMetadataMapintosrc/services/flow-paths.tsand reused them fromcloud.tsso the CLI and MCP build identical server-side paths (no copy-paste; covered by the existing cloud integration test).dcd/api+ infra, not here.Tests
pnpm test→ 142 passing, including:test/unit/flow-paths.test.ts— the extracted path logic (guards thecloud.tsrefactor)test/integration/mcp.integration.test.ts— spawns the built bin and drives it with the real MCP client against the mock API: tool discovery, read-only gate, destructive annotation, livelist_runs/get_statusround-trips (which prove stdout stays clean), andisErrorhandlingLint 0 errors ·
tscsrc + test clean ·pnpm buildemits all MCP files (incl. shebang + chmod).Distribution
bin.dcd-mcp→dist/mcp/index.js; build script chmods itserver.jsonregistry manifest; CLAUDE.md architecture + entry-point docs🤖 Generated with Claude Code