Skip to content

MCP server for coding agents (F22) - #2

Merged
jainath merged 1 commit into
mainfrom
feat/mcp-server
Jul 11, 2026
Merged

MCP server for coding agents (F22)#2
jainath merged 1 commit into
mainfrom
feat/mcp-server

Conversation

@jainath

@jainath jainath commented Jul 11, 2026

Copy link
Copy Markdown
Owner

Summary

Adds an opt-in, loopback-only HTTP MCP server so coding agents (Claude Code, Cursor, anything that speaks MCP) manage the user's dev servers through DevHarbor instead of spawning npm run dev in a shell they then lose track of. Processes started this way outlive the agent's session, stay visible in the app, and get logs, port tracking, readiness checks, and clean shutdown for free.

22 tools: list / add / update / remove apps · add / remove tasks · start / stop / restart apps and individual tasks · read / search logs · inspect ports, env vars, run history, node versions · scan folders · configure readiness probes.

Off by default. Enable under Settings → MCP server (status, port, token, copy-paste client config). Version bumped to 1.2.0.

Highlights

  • Security posture: binds 127.0.0.1 only (not configurable), validates Host/Origin on every request, requires a bearer token by default (sha256 + timingSafeEqual, never logged). Secret env values are masked in responses and redacted from log output. Optional HTTPS via a self-signed localhost certificate generated on first use.
  • Honest readiness: a probe-less task reports ready: null instead of a vacuous true; a factual listening flag is reported separately from verified ready; start results carry readinessVerified plus recent output so an agent can judge for itself; a new http readiness kind polls /health until a service can actually serve; set_readiness lets an agent configure a probe. Each detected port is labeled with its owning process, and the start path waits for the port set to stabilize so slow-binding monorepo siblings are captured inline.
  • Monorepos: add_app with workspaceTasks: true registers a repo once with one task per workspace package (pnpm/yarn/npm, same detection as the UI); add_task / remove_task shape the task set with per-task working directory, dependsOn ordering (migrate → api → web), and oneShot for migrations/builds. Workspace globs that escape the repo root are rejected so a task can never run an unrelated sibling project.
  • Live UI: MCP mutations push a state:invalidate event so the desktop reflects add/remove/start/stop without a manual reload.

Implementation notes

  • New src/main/mcp/ module: stateless Streamable HTTP transport (@modelcontextprotocol/sdk, per-request server), pure gate.ts (Host/Origin/bearer), hygiene.ts (ANSI strip + secret redaction), token.ts, tls.ts.
  • Shared AppOps de-duplicates the create/update/remove/scan/search flows between the existing IPC handlers and MCP.
  • New settings keys mcp_enabled / mcp_port / mcp_require_auth / mcp_https.
  • Design and full tool catalog: specs/07-mcp-server.md.

Testing

  • 143 unit tests (vitest): gate, hygiene, resolver, TLS, HTTP readiness, and the full 22-tool catalog against a fake context — no electron/better-sqlite3 imports in the unit suite.
  • Live E2E: an Electron harness drives the real packaged server with the SDK client (functional + auth/403/405/413), plus a monorepo run against a pnpm fixture (per-package registration, per-service start/stop, dependency-ordered oneShot, an http probe verifying a slow-boot API, guard rejections) — all 25 checks pass against the built binary.
  • Multiple adversarial multi-agent review rounds; all confirmed findings fixed.
  • typecheck clean · lint 0 · 143/143 tests.

Release notes

The local build is signed with a Developer ID but not notarized (no Apple creds in the build env). The real release should go through the v1.2.0 tag → CI workflow, which notarizes and publishes.

Add an opt-in, loopback-only HTTP MCP server so coding agents manage dev
servers through DevHarbor instead of spawning npm/yarn/pnpm in a shell they
lose track of. 22 tools: list/add/update/remove apps, add/remove tasks,
start/stop/restart apps and individual tasks, read/search logs, inspect
ports, env vars, run history, node versions, scan folders, and configure
readiness probes.

Highlights:
- Security: binds 127.0.0.1 only, validates Host/Origin on every request,
  bearer token by default (sha256 + timingSafeEqual), secret env values
  masked in responses and redacted from log output. Optional HTTPS with a
  self-signed localhost certificate generated on first use.
- Honest readiness: probe-less tasks report ready: null instead of a vacuous
  true; a factual listening flag is separate from verified ready; start
  results carry readinessVerified plus recent output; a new http readiness
  kind polls /health until a service can actually serve; set_readiness lets
  an agent configure a probe. Ports are labeled with their owning process and
  the start path waits for the port set to stabilize.
- Monorepos: add_app with workspaceTasks: true registers a repo once with one
  task per workspace package (shared detection with the UI); add_task /
  remove_task shape the task set with per-task working dir, dependsOn
  ordering, and oneShot for migrations/builds.
- Live UI: MCP mutations push state:invalidate so the desktop reflects them
  without a manual reload.

Shared AppOps de-duplicates the create/update/remove/scan/search flows
between IPC and MCP. Settings gains mcp_enabled/mcp_port/mcp_require_auth/
mcp_https with a Settings -> MCP server section (status, token, client
config). Tests: gate, hygiene, resolver, TLS, HTTP readiness, and the full
22-tool catalog under vitest, plus a live Electron E2E harness. Bumps to
1.2.0.
@jainath
jainath merged commit bc70f3e into main Jul 11, 2026
1 check passed
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