> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.recursiv.io/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.recursiv.io/_mcp/server.

# MCP

## What is MCP?

The [Model Context Protocol](https://modelcontextprotocol.io/) lets AI assistants call external tools. `@recursiv/mcp` exposes Recursiv to Claude Code, Claude Desktop, Cursor, Codex, and any MCP-compatible client.

Use it when an agent should create projects, run sandboxed code, inspect deployments, manage agents, coordinate dispatcher tasks, persist memory, work with social primitives, or self-evaluate before delivering work.

The current source registry contains 150 tool registrations. Scope filtering can register fewer tools for a given API key.

## Connect

There are two ways to connect. Most people want the first — it takes about two minutes.

### Hosted connect (recommended)

No key to copy, nothing to install, no config file. In your AI client, add Recursiv as a custom connector and sign in.

1. In your client, open connector settings and **add a custom connector**.

2. Paste the Recursiv MCP URL:

   ```text
   https://api.recursiv.io/mcp
   ```

3. You're sent to a Recursiv sign-in — log in and click **Allow**.

The client discovers the server, registers itself over OAuth, and connects. This works anywhere that supports remote MCP connectors:

| Client                     | Where to add it                                                           |
| -------------------------- | ------------------------------------------------------------------------- |
| Claude Desktop / Claude.ai | Settings → Connectors → **Add custom connector**                          |
| ChatGPT                    | Settings → Connectors → **Add**                                           |
| Gemini (web app)           | Connected apps → **add a custom app**                                     |
| Gemini CLI                 | Configured via the CLI's remote-server support (OAuth is auto-discovered) |

No API key is involved — the connection is authorized by your Recursiv login. Under the hood the platform provisions a per-user credential the moment you approve access, scoped to what you can already reach.

### Local connector (coding agents & local dev)

For **Claude Code, Cursor, and Codex** — and for local development where you want the [dev tunnel](#local-dev-tunnel) — run the MCP server as a local subprocess authenticated with an [API key](/guides/start-here/auth-api-keys). The rest of this page covers that path.

## Setup (local connector)

### Claude Code

Add to `.mcp.json` in your project root:

```json
{
  "mcpServers": {
    "recursiv": {
      "command": "npx",
      "args": ["-y", "@recursiv/mcp"],
      "env": {
        "RECURSIV_API_KEY": "sk_live_your_key_here",
        "RECURSIV_BASE_URL": "https://api.recursiv.io/api/v1",
        "RECURSIV_ORGANIZATION_ID": "your-org-uuid",
        "RECURSIV_PROJECT_ID": "your-project-uuid"
      }
    }
  }
}
```

You can also install from the CLI:

```bash
npx -p @recursiv/cli recursiv mcp install claude-code --api-key sk_live_...
```

### Claude Desktop

Add to your Claude Desktop config:

```json
{
  "mcpServers": {
    "recursiv": {
      "command": "npx",
      "args": ["-y", "@recursiv/mcp"],
      "env": {
        "RECURSIV_API_KEY": "sk_live_your_key_here",
        "RECURSIV_ORGANIZATION_ID": "your-org-uuid"
      }
    }
  }
}
```

Typical config locations:

* macOS: `~/Library/Application Support/Claude/claude_desktop_config.json`
* Windows: `%APPDATA%\Claude\claude_desktop_config.json`

### Cursor

Add to `.cursor/mcp.json` in your project root (same format as Claude Code above).

### Codex

Codex uses TOML config:

```toml
[mcp_servers.recursiv]
command = "npx"
args = ["-y", "@recursiv/mcp"]
env = { "RECURSIV_API_KEY" = "sk_live_your_key_here" }
```

Codex reads `~/.codex/config.toml` or repo-local `.codex/config.toml`.

For local repo development:

```bash
pnpm --filter @recursiv/mcp build
```

```toml
[mcp_servers.recursiv]
command = "node"
args = ["packages/mcp/dist/bin.js"]
env = { "RECURSIV_API_KEY" = "sk_live_your_key_here" }
```

## Environment Variables

| Variable                   | Required | Description                                                                                           |
| -------------------------- | -------- | ----------------------------------------------------------------------------------------------------- |
| `RECURSIV_API_KEY`         | Yes      | SDK API key (`sk_live_*`). Auto-scopes all operations to the key's organization.                      |
| `RECURSIV_BASE_URL`        | No       | API base URL. Default: `https://api.recursiv.io/api/v1`                                               |
| `RECURSIV_ORGANIZATION_ID` | No       | Default organization UUID. Used by dispatcher and memory tools when not explicitly provided.          |
| `RECURSIV_PROJECT_ID`      | No       | Default project UUID. Used by memory tools when not explicitly provided.                              |
| `RECURSIV_API_KEY_SCOPES`  | No       | Optional comma-separated scope filter. When set, tools requiring scopes outside the list are skipped. |
| `RECURSIV_TUNNEL_DISABLED` | No       | Set to `true` to disable the [local dev tunnel](#local-dev-tunnel).                                   |
| `RECURSIV_TUNNEL_PORT`     | No       | Local port the tunnel forwards to. Default: `3000`                                                    |
| `RECURSIV_TUNNEL_METHODS`  | No       | Comma-separated HTTP methods the tunnel will proxy. Default: `GET`                                    |

`SOCIAL_DEV_API_KEY` is accepted as a backwards-compatible fallback for `RECURSIV_API_KEY`. `RECURSIV_ORG_ID` is accepted as a deprecated alias for `RECURSIV_ORGANIZATION_ID`.

## Local dev tunnel

On startup the MCP server connects an outbound WebSocket to the Recursiv platform and registers a **local dev tunnel** for your default project. You'll see this on stderr:

```
[recursiv-tunnel] Connected, waiting for token...
[recursiv-tunnel] Tunnel active: localhost:3000
```

This is expected. The tunnel lets Recursiv platform agents (for example the QA agent, or a swarm reviewing your work) reach the dev server running on your machine, so they can test changes before they're deployed.

Scope and safety:

* Only **GET** requests are proxied by default (`RECURSIV_TUNNEL_METHODS` widens this explicitly)
* It only forwards to `localhost:3000` (configurable via `RECURSIV_TUNNEL_PORT`)
* Traffic flows through your authenticated project on the platform — your machine is not exposed publicly

To opt out, set `RECURSIV_TUNNEL_DISABLED=true` in the MCP server's environment. Everything else works normally; platform agents just can't reach your local dev server.

## Available tool groups

Tool availability depends on scopes. The counts below reflect the current source registry before scope filtering.

| Group                 | Source registrations | Examples                                             |
| --------------------- | -------------------- | ---------------------------------------------------- |
| Social                | 9                    | posts, communities, chat                             |
| Projects              | 13                   | projects, deployments, project sandboxes             |
| Agents                | 12                   | agent CRUD, streaming chat, inbox, project access    |
| Sandbox               | 1                    | anonymous code execution                             |
| Memory                | 7                    | facts, decisions, memory search                      |
| Dispatcher            | 30                   | tasks, claims, stale/stuck checks, signals, outcomes |
| Swarms                | 10                   | swarms, members, schedules                           |
| Evidence              | 4                    | author evals, run simulations, read graded results   |
| Templates             | 6                    | list, create, fork, publish templates                |
| Devtools              | 13                   | project/storage/database/deploy helper tools         |
| Platform              | 5                    | org, settings, admin helpers                         |
| Remaining API surface | 43                   | additional generated API tools                       |
| Self-evaluation       | 1                    | evaluate work before delivery                        |

## Common tools

Use the tool list exposed by your MCP client as the runtime source of truth. The server registers tools from the source groups above, then applies any `RECURSIV_API_KEY_SCOPES` filter before startup.

High-signal examples that are present in the current source registry:

| Task                            | Tool examples                                                                                 |
| ------------------------------- | --------------------------------------------------------------------------------------------- |
| Work with posts and communities | `list_posts`, `get_post`, `create_post`, `search_posts`, `list_communities`                   |
| Work with projects              | `list_projects`, `get_project`, `create_project`, `delete_project`, `deploy_project`          |
| Run code                        | `try_code`, `start_sandbox`, `execute_code`, `stop_sandbox`                                   |
| Manage agents                   | `list_agents`, `get_agent`, `create_agent`, `update_agent`, `delete_agent`, `chat_with_agent` |
| Coordinate work                 | `create_task`, `claim_next_task`, `complete_task`, `list_stuck_tasks`, `get_dispatcher_stats` |
| Persist memory                  | `add_fact`, `list_facts`, `search_memory`, `log_decision`, `list_decisions`                   |
| Manage swarms                   | `list_swarms`, `create_swarm`, `add_swarm_member`, `schedule_agent_task`                      |
| Measure agents (evidence)       | `create_eval`, `run_evals`, `list_eval_runs`, `get_eval_run`                                  |
| Use templates                   | `list_templates`, `create_template`, `fork_template`, `publish_template`                      |
| Self-check output               | `self_evaluate`                                                                               |

## Authentication model

The MCP server authenticates with `RECURSIV_API_KEY`. The key determines which resources and scopes the agent can use.

* SDK API keys (`sk_live_*`) are scoped to the organization that created them.
* `RECURSIV_ORGANIZATION_ID` provides a default organization for tools that accept it.
* `RECURSIV_PROJECT_ID` provides a default project for memory and project-scoped tools.
* `RECURSIV_API_KEY_SCOPES` can limit tool registration at startup.
* `SOCIAL_DEV_API_KEY` remains supported only as a backwards-compatible fallback.

## Verify setup

```bash
npx -p @recursiv/cli recursiv mcp verify
```

From this repo:

```bash
pnpm --filter @recursiv/mcp build
RECURSIV_API_KEY=sk_live_... node packages/mcp/dist/bin.js
```

The server runs over stdio, so a successful direct launch waits for MCP client messages instead of printing an HTTP URL.

## Usage examples

Once configured, ask your MCP client for direct tasks such as:

* "Run this TypeScript snippet in an anonymous sandbox."
* "List my projects and show the current deployment status."
* "Create a task, claim it, and mark it complete after the code change."
* "Remember that this project uses Hono for the API."
* "Create an agent and grant it access to this project."
* "Search memory for decisions about database isolation."
* "Create a swarm for a small documentation cleanup."
* "Self-evaluate this implementation before final delivery."