# MCP connections for runs

URL: https://codepanel.ai/docs/mcp-connections

Connect external stdio and HTTP MCP servers to coding agent runs with SHA-256 tool pinning, owner-marked read-only tools, and data boundaries.

CodePanel lets coding agent runs call external Model Context Protocol (MCP) servers (stdio or remote HTTP) that your account has approved. Every approved tool is pinned by a canonical SHA-256 hash so a server cannot silently rewrite a tool description after approval, and production connections expose only tools you explicitly mark read-only.

## Adding and approving a connection

Approve external MCP connections in **Settings → MCP & integrations**, via [`add_connection`](/docs/mcp-server/add_connection), or through the HTTP API (`POST /api/v1/autopilot/connections`). A local (`stdio`) program is added only in the dashboard; see below.

- **Repository `.mcp.json` files are proposals only:** A `.mcp.json` committed to a repository is never started automatically, since any pull request could alter it.
- **SHA-256 tool pinning:** At approval time, CodePanel hashes each tool's canonical JSON (name, description, and input schemas). Before every run, the runner re-hashes the server's live tool definitions and drops any tool whose hash changed until you approve it again.
- **Explicit read-only marking:** Server-supplied annotations such as `readOnlyHint` are never trusted for authorization. Production connections only expose tools the account owner explicitly marked read-only.

## Who can add a local program

A `stdio` connection is a program the runner starts on your machine, so only you add one, signed in to the dashboard: **Settings → MCP & integrations → Add a connection**. An agent's API token, whatever its scopes, and an OAuth or MCP grant cannot, since an agent could otherwise give itself a program to run.

- **What a token is refused:** adding a `stdio` connection, turning an `http` one into `stdio`, and, on a `stdio` connection, changing its command, arguments or environment, granting it to more coding agents, or granting, re-approving or marking read-only a tool. The answer is a `403` (`forbidden`) naming each refused change in `fields`, nothing is saved, and its `nextAction` is the dashboard page.
- **What a token can still do:** remove a connection, or add it again with the same command and fewer agents or tools. Remote `http` connections are unchanged: a token with `agents:write` adds and changes them.
- **From the CLI:** run `codepanel connections add <name> … -- <command> [args...]` where the program runs. It starts the program, pins the tools you named, and, when your token is refused, prints the connection as JSON. Paste it into the dashboard form, check what it shows, and add it. **Change** on a connection fills the same form with it, to widen it there.
- **Connections added before this rule:** a `stdio` connection a token added shows `addedIn: "token"` and the runner does not start it. Add it again in the dashboard to run it.

## Scrubbed stdio transport and sandboxing

Local stdio MCP servers run as child processes inside the run's [OS sandbox](/docs/local-sandbox) through a custom transport that passes only the exact allowlisted environment variables you configure, preventing leakage of parent shell variables (`HOME`, `PATH`, `USER`, or local tokens).

## Production data boundaries

When a repository's run contract lists a connection under `productionReads`:

1. Runs holding those tools start only on approved zero-retention providers (Anthropic, Workers AI, or OpenAI when `"openaiZeroRetention": true` is set) and never on external CLIs.
2. On team runs, every team member and subagent is checked against the allowlist before starting.
3. If your account's LLM gateway is unreachable, production-read runs stop (`gateway_unreachable`) instead of falling back to direct provider calls.

See [Securing MCP servers for unattended coding agents](/guides/securing-mcp-for-unattended-agents) and [Security](/security) for full details.
