# MCP server

Drive Automaintainer from an agentic terminal (Claude Code, opencode, …) as
**native tools** — no shelling out. `am-cloud mcp` runs a stdio
[MCP](https://modelcontextprotocol.io) server backed by the same panel API and
API key as [`am-cloud platform`](/docs/cli).

## Configure your MCP client

Point your client at the `am-cloud` binary with the `mcp` subcommand. Most clients
take a command + env:

```json
{
  "mcpServers": {
    "automaintainer": {
      "command": "am-cloud",
      "args": ["mcp"],
      "env": {
        "AM_PANEL": "https://automaintainer.intrane.fr",
        "AM_API_KEY": "amk_..."
      }
    }
  }
}
```

Get `AM_API_KEY` from **Settings → API key** (or [API key](/docs/api-key)).
`--panel` / `--api-key` flags also work if your client passes args instead of env.

> Transport is **stdio only** (JSON-RPC over stdin/stdout) — there's no port to
> open and no inbound network exposure. `initialize` and `tools/list` work without
> credentials, so a client can introspect the tools before you set the key.

## Tools

| Tool | What it does |
|---|---|
| `am_status` | Account + connected worker status |
| `am_repo_list` | List your repos (id, name, focus, enabled) |
| `am_repo_run` | Run a repo and optionally wait for the verified result. Identify by `repo_url` (added if missing — the one-shot) or `id`; `focus` and `wait` optional. Returns `{run_id, status, pr_url}` |
| `am_repo_set` | Configure a repo (`focus`, `verify_cmd`, `objective`, `team_config`, `arch_context`, `auto_merge`, `issue_scout`) |
| `am_runs` | Recent runs (optionally by `repo_id`) |
| `am_run_get` | One run by `run_id` (status, verify_status, pr_url) |
| `am_probe` | Liveness-probe a `cli`/`model` before spending a run |

Tool failures come back as MCP `isError` content (with the message), so the agent
can read and react rather than crashing.

## The one-shot, as a tool call

The headline flow — "enrich docs/ in this repo, run now" — is a single
`am_repo_run`:

```json
{ "name": "am_repo_run",
  "arguments": { "repo_url": "https://github.com/you/your-repo", "focus": "enrich docs/", "wait": true } }
```

It adds the repo if it's new, sets the focus, runs, and (with `wait`) returns the
verified PR. Re-running the same `repo_url` reuses the repo (no duplicate).

## CLI vs MCP

Both surfaces wrap the same API. Use the **[CLI](/docs/cli)** for scripts and
shell pipelines; use **MCP** when an agent should call AM as first-class tools.
See the [Agent cheatsheet](/docs/agent-cheatsheet) for the full JSON contract and
self-healing loops.

## Related

- [Agent cheatsheet](/docs/agent-cheatsheet) · [am-cloud CLI](/docs/cli) · [API key](/docs/api-key)
