# Connect an agent

> Give Claude Desktop, Claude Code, Cursor or Devin Desktop the Atracode compiler through the MCP server, and see how results and refusals reach the agent.

> Preview: the commands, tools and API shapes on this page may change before launch.

Source: https://atracode.com/docs/connect-an-agent

The Atracode MCP server, `@atracode/mcp-server`, gives any MCP client four tools: compile, verify equivalence, inspect a SEG, and get a RAVEN hash. It runs locally over stdio and calls the hosted compiler with your API key. The compiler itself stays on Atracode's servers.

> **Note:** The `@atracode/mcp-server` package is published at launch. You can set up your account and plan now.

## Get an API key

Pick a plan on the [pricing page](/pricing). The free Community plan works for this walkthrough: it includes one agent stream and 250 compilations a month. Picking a plan creates your account if you don't have one.

Once you have a plan, you copy your API key from your workspace. It looks like `atc_live_xxxxxxxxxxxx`. Keys that call the compiler are issued at launch. Treat yours like a password. See [Authentication](/docs/authentication) for more on keys.

## Add the server to your client

Use the block for your client and replace the placeholder key with yours. Each one runs the server with `npx` and passes the key in `ATRACODE_API_KEY`.

### Claude Desktop

Add this to `claude_desktop_config.json`, then restart Claude Desktop:

```json
{
  "mcpServers": {
    "atracode": {
      "command": "npx",
      "args": [
        "-y",
        "@atracode/mcp-server"
      ],
      "env": {
        "ATRACODE_API_KEY": "atc_live_xxxxxxxxxxxx"
      }
    }
  }
}
```

### Claude Code

Run this in your terminal:

```shell
claude mcp add atracode --env ATRACODE_API_KEY=atc_live_xxxxxxxxxxxx -- npx -y @atracode/mcp-server
```

### Cursor

Add this to `.cursor/mcp.json` in your project:

```json
{
  "mcpServers": {
    "atracode": {
      "command": "npx",
      "args": [
        "-y",
        "@atracode/mcp-server"
      ],
      "env": {
        "ATRACODE_API_KEY": "atc_live_xxxxxxxxxxxx"
      }
    }
  }
}
```

### Devin Desktop

Devin Desktop is the editor formerly called Windsurf, and it still reads the same file. Add this to `~/.codeium/windsurf/mcp_config.json`:

```json
{
  "mcpServers": {
    "atracode": {
      "command": "npx",
      "args": [
        "-y",
        "@atracode/mcp-server"
      ],
      "env": {
        "ATRACODE_API_KEY": "atc_live_xxxxxxxxxxxx"
      }
    }
  }
}
```

Other MCP clients take the same `command`, `args` and `env` values. Agents can also discover the server from `/.well-known/mcp.json`.

## Check the four tools appear

Open your client's list of MCP tools. You should see:

| Tool | What it does |
| --- | --- |
| `atracode_compile` | Compiles source to a SEG and returns the RAVEN hash, or a refusal with file, line and column |
| `atracode_verify_equivalence` | Checks whether two programs, in any languages, behave identically, and where they diverge if not |
| `atracode_inspect_seg` | Shows a SEG's inputs, membrane reads and writes, and bounds |
| `atracode_get_raven_hash` | Returns a program's RAVEN hash |

If the tools are missing, check that the key is set and that `npx` is on the client's path. Parameters and return shapes are in [MCP tools](/docs/mcp-tools).

## Ask the agent to compile something

Ask in plain language, for example: "Compile interest.py with Atracode and tell me its RAVEN hash." The agent calls `atracode_compile` with a `path` (or the `source` text) and gets back:

```json
{
  "status": "verified",
  "raven_hash": "13803fe6908d64b3301b931688e6244c99d9b80f15c781f5de7581abb7c3d2af"
}
```

The language is inferred from the file name, and the agent can pass `language` when it sends source text with no file name. Each call draws on your workspace's compilations.

Agents are useful for migrations. Ask "Rewrite INTEREST.cbl in Rust and prove the behavior is unchanged", and the agent can write the Rust, call `atracode_verify_equivalence` on both files, and keep going until `identical` is `true`.

## Handle refusals

When a program can't be verified exactly, the tool returns `status: "refused"` with the location and a hint:

```json
{
  "status": "refused",
  "refusal": {
    "file": "rotate.sh",
    "line": 12,
    "column": 9,
    "reason": "reads $(date), which differs on every run",
    "hint": "pass the timestamp in as an argument and compile again"
  }
}
```

This is the same information the CLI prints, in a form the agent can act on. A capable agent will open the file at that line, apply the hint, and call `atracode_compile` again. When `atracode_verify_equivalence` finds a difference, it returns `divergence` with the `input` and both outputs, so the agent can see exactly which case broke.

See [Refusals](/docs/refusals) for common causes and fixes.

## Next steps

- [MCP tools](/docs/mcp-tools): parameters and return values for all four tools
- [Agent streams](/docs/agent-streams): how many agents can run at once on each plan
- [Refusals](/docs/refusals): why the compiler refuses and how to fix it
