> ## Documentation Index
> Fetch the complete documentation index at: https://docs.labelbox.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Connect to the Recursion MCP

> Connect Claude Code, Codex, Cursor, or another MCP client to the public docs MCP server and to the authenticated Recursion MCP endpoint with an API key.

Recursion offers two MCP servers for coding agents and other MCP clients:

* **The docs MCP server** at `https://docs.labelbox.com/mcp` searches and reads every page here. It's public and needs no key.
* **The Recursion MCP endpoint** at `https://api.recursion.labelbox.com/mcp` finds and runs Managed Agents operations through four tools. It authenticates with an API key and acts as you.

The same API key also lets code the agent writes call the REST API.

```mermaid theme={"theme":"css-variables"}
flowchart TD
  coder["Your coding agent"] -->|"reads"| docs["Docs MCP"]
  coder -->|"calls"| mcp["Recursion MCP"]
  coder -->|"writes"| code["Your script"]
  mcp -->|"API key"| api["Managed Agents API"]
  code -->|"API key"| api
```

<Note>
  You need a coding agent: Claude Code, Codex, or Cursor. The Recursion MCP endpoint and the REST API need an API key: create one under **Settings › API keys** in the console (see [API keys](/recursion/api-keys)). Scripts need `curl` and `jq`, or an HTTP client in your preferred language (see [REST client setup](/recursion/api#rest-client-setup)).
</Note>

<Tip>
  This page connects a local coding agent to Recursion. To give an agent that runs inside Recursion access to another MCP server, configure that server on the agent instead. See [MCP servers](/recursion/mcp-servers).
</Tip>

## Connect the docs MCP server

The docs server at `https://docs.labelbox.com/mcp` is public, so it needs no key. Apart from sending feedback, it's read-only.

<Tabs>
  <Tab title="Claude Code">
    ```bash theme={"theme":"css-variables"}
    claude mcp add --transport http --scope user recursion-docs https://docs.labelbox.com/mcp
    claude mcp list
    ```
  </Tab>

  <Tab title="Codex">
    ```bash theme={"theme":"css-variables"}
    codex mcp add recursion-docs --url https://docs.labelbox.com/mcp
    codex mcp list
    ```
  </Tab>

  <Tab title="Cursor">
    Add the server to `~/.cursor/mcp.json`, then restart Cursor:

    ```json theme={"theme":"css-variables"}
    {
      "mcpServers": {
        "recursion-docs": {
          "url": "https://docs.labelbox.com/mcp"
        }
      }
    }
    ```
  </Tab>
</Tabs>

Start a new session in your coding agent after changing its MCP configuration. The server covers the whole docs site, so tell your agent to stay within the `/recursion` pages.

<Accordion title="Docs server tools and other formats">
  The server offers three tools:

  | Tool | What it does |
  | - | - |
  | Search | Finds relevant pages and returns excerpts with their titles and links. |
  | Docs filesystem | Reads full pages and the API reference with read-only commands such as `cat`, `head`, and `rg`. |
  | Feedback | Reports a page that's wrong, outdated, or unclear. |

  Every page is also available as Markdown: append `.md` to its URL. For agents without MCP, the docs site root serves an index of every page at `/llms.txt` and the full text at `/llms-full.txt`.

  Every code sample on these pages is checked against the API contract whenever the docs change, so operation names, request fields, and paths match what the API accepts.
</Accordion>

## Connect the Recursion MCP endpoint

The authenticated endpoint is `https://api.recursion.labelbox.com/mcp`. Configure it as a Streamable HTTP MCP server that sends `Authorization: Bearer <key>`. Export the key as `RECURSION_API_KEY` in the shell that starts your client, and let the client read it from the environment, so the key never lands in a configuration file. Prefer an organization-scoped key; a tenant-scoped key must also send `x-organization-id` with the organization it should act in.

<Tabs>
  <Tab title="Claude Code">
    Add the server to `.mcp.json` in your project. Claude Code fills in `${RECURSION_API_KEY}` from the environment:

    ```json theme={"theme":"css-variables"}
    {
      "mcpServers": {
        "recursion": {
          "type": "http",
          "url": "https://api.recursion.labelbox.com/mcp",
          "headers": {
            "Authorization": "Bearer ${RECURSION_API_KEY}"
          }
        }
      }
    }
    ```
  </Tab>

  <Tab title="Codex">
    ```bash theme={"theme":"css-variables"}
    codex mcp add recursion --url https://api.recursion.labelbox.com/mcp --bearer-token-env-var RECURSION_API_KEY
    codex mcp list
    ```
  </Tab>

  <Tab title="Cursor">
    Add the server to `~/.cursor/mcp.json`, then restart Cursor. Cursor fills in `${env:RECURSION_API_KEY}` from the environment:

    ```json theme={"theme":"css-variables"}
    {
      "mcpServers": {
        "recursion": {
          "url": "https://api.recursion.labelbox.com/mcp",
          "headers": {
            "Authorization": "Bearer ${env:RECURSION_API_KEY}"
          }
        }
      }
    }
    ```
  </Tab>
</Tabs>

It exposes exactly four tools. Start with `search_docs`, pass its slug to `read_doc`, then use the operation's declared tool and input schema. Every operation runs with the connecting key's tenant, organization, role, and permissions.

<Accordion title="The four tools">
  | Tool | What it does |
  | - | - |
  | `search_docs` | Finds Managed Agents guides and API operations. |
  | `read_doc` | Reads the exact guide or generated operation schema for a discovered slug. |
  | `read_operation` | Executes a discovered read-only operation. |
  | `write_operation` | Executes a discovered create, update, or delete operation. |

  Path parameters in an operation's input use camelCase, such as `vaultId`, while request bodies keep the operation's `snake_case` fields. Follow the input schema `read_doc` returns.

  When an operation declares an `ETag`, its successful result includes `responseHeaders.etag`. If the mutation's discovered input schema declares `If-Match`, copy the complete opaque value from the resource read into that argument. Refresh it after each successful write; do not construct it from the body's `revision`.

  The endpoint rejects browser-origin requests and does not accept session cookies.
</Accordion>

<Accordion title="Operations to call through REST instead">
  The operation tools run only operations whose request and response bodies are JSON. Other operations stay discoverable and their schemas stay readable, but MCP marks them documentation-only. Call these through the REST API instead:

  * Skill bundle uploads and skill version bundle downloads. A skill made of a single `SKILL.md` can be created through MCP; create a skill with scripts or other files through the REST API or the console.
  * The multipart `uploadFile` and the binary `getFileContent`. `listFiles` and `getFile` are callable through `read_operation`.
  * Agent memory settings, learned memories, and memory runs are available through the REST API. The generated SDK does not yet include them. Memory operations are excluded from MCP discovery and operation tools.
</Accordion>

## Give the agent API access

Export the key in the shell that starts your coding agent. The agent and the scripts it runs read it from the environment, and the key never appears in a prompt or a file.

```bash theme={"theme":"css-variables"}
export RECURSION_API_KEY='rma_...'
```

Check the key works without printing it:

```bash theme={"theme":"css-variables"}
curl -sS -o /dev/null -w '%{http_code}\n' 'https://api.recursion.labelbox.com/managed-agents/v1/models' \
  -H "Authorization: Bearer $RECURSION_API_KEY"
```

`200` means the key works. `401` means it's missing, expired, or revoked.

<Warning>
  Never paste a key into a chat. Transcripts are stored and can be shared. If you're an AI agent and `RECURSION_API_KEY` isn't set, ask the person to export it and restart you. Don't ask for the value.
</Warning>

<Accordion title="Handle the key safely">
  * **Use a dedicated, short-lived key.** A key acts as you, with your full role, so give each coding agent its own key with a 7- or 30-day expiry and revoke it when you're done.
  * **Prefer an organization-scoped key.** It can reach only one organization and needs no extra header.
  * **Keep keys out of code and version control.** Read `process.env.RECURSION_API_KEY` or `os.environ["RECURSION_API_KEY"]`. Never write the key to a `.env` file that gets committed.
  * **Don't print it.** Tell the agent never to echo, log, or include the key in output.
</Accordion>

## Run a first task

Paste this prompt into your coding agent. It reads the docs first, then writes and runs code.

```text theme={"theme":"css-variables"}
Use the authenticated recursion MCP server. Search for the quickstart and the
operation that lists models, read both results, and call that read-only
operation. Then write a shell script that uses curl, jq, and the
RECURSION_API_KEY environment variable to create an environment and an agent,
start a session that asks the agent for a short summary, poll getSession until
execution_state is idle, and print the session id, stop_reason, and the agent's
last message. Never print the API key.
Run the script and report the results.
```

When it finishes, open **Sessions** in the console to see the same session and its transcript.

Good follow-ups to ask for:

* "Add an `Idempotency-Key` so a retried start can't create a second session."
* "Stream the session's events instead of polling, and resume from the last event id if the connection drops."
* "Read /recursion/errors and handle every retryable error with backoff."

## What can go wrong

The most common problems:

* **The tools don't appear.** The client hasn't reloaded its MCP configuration, or the address is wrong. For the Recursion MCP, `RECURSION_API_KEY` may not be set where the client started. Check both, then restart the client.
* **`401 unauthorized`.** The key isn't exported in the shell that started the client or agent, or it expired or was revoked. Export a valid key, restart, and run the `curl` check above.
* **`400 invalid_request` mentioning `x-organization-id`.** The key has tenant scope. Add the header, or use an organization-scoped key.

<Accordion title="Every connection problem">
  | Symptom | Cause | Fix |
  | - | - | - |
  | The docs tools don't appear | The client hasn't reloaded its MCP configuration, or the address is wrong. | Check the address, then start a new client session or restart the app. |
  | The Recursion MCP tools don't appear, or calls return `401 unauthorized` | `RECURSION_API_KEY` wasn't set in the environment that started the client, or the key expired or was revoked. | Export a valid key, restart the client, and run the `curl` check above. |
  | Search returns pages from other products | The docs server covers the whole site. | Ask the agent to read only paths under `/recursion`. |
  | Scripts get `401 unauthorized` | `RECURSION_API_KEY` isn't exported in the shell that started the agent, or the key expired. | Export it, restart the coding agent, and run the `curl` check above. |
  | Scripts get `400 invalid_request` mentioning `x-organization-id` | The key has tenant scope. | Add the header, or use an organization-scoped key. See [Tenant-scoped keys](/recursion/api#tenant-scoped-keys). |
  | The agent asks you to paste the key | Its instructions don't say how keys are provided. | Export the key, restart the agent, and tell it to read `RECURSION_API_KEY` from the environment. |
</Accordion>

## Next steps

<CardGroup cols={2}>
  <Card title="API conventions" href="/recursion/api">
    Authentication, retries, paging, and errors in one place.
  </Card>

  <Card title="Quickstart" href="/recursion/quickstart">
    Run the same flow yourself, step by step.
  </Card>

  <Card title="API keys" href="/recursion/api-keys">
    Scopes, expiry, revocation, and safe storage.
  </Card>

  <Card title="MCP servers" href="/recursion/mcp-servers">
    Give a hosted agent tools from another MCP server.
  </Card>
</CardGroup>
