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

# Claude Code

> Set up Trilo's MCP server in Claude Code with OAuth or Personal Access Token authentication

<img src="https://mintcdn.com/trilo/Sn4xCqXfS0z4bBRK/images/mcp/claude-code.svg?fit=max&auto=format&n=Sn4xCqXfS0z4bBRK&q=85&s=50960779364739c112c26c3991e73753" alt="Claude Code" width="48" noZoom data-path="images/mcp/claude-code.svg" />

[Claude Code](https://docs.anthropic.com/en/docs/claude-code) is Anthropic's agentic coding tool for the terminal. It supports both **OAuth** (recommended) and **PAT** authentication for MCP connections.

## Setup with OAuth (Recommended)

The fastest way to connect — no token needed.

<Steps>
  <Step title="Add the MCP server">
    In your terminal, run:

    ```bash theme={null}
    claude mcp add --transport http --scope user trilo https://api.trilo.chat/mcp
    ```

    <Tip>
      The `--scope user` flag makes Trilo available across all your projects. Use `--scope local` (default) to limit it to the current project only.
    </Tip>
  </Step>

  <Step title="Authenticate">
    Inside Claude Code, run the `/mcp` command. Select **Authenticate** for the Trilo server — this will open your browser to authorize access to your Trilo account.
  </Step>

  <Step title="Verify the connection">
    Back in Claude Code, ask:

    ```
    List my Trilo workspaces
    ```

    If it returns your workspace data, you're all set.
  </Step>
</Steps>

## Setup with PAT (Alternative)

If you prefer a Personal Access Token instead of OAuth:

<Steps>
  <Step title="Create a token">
    In Trilo, go to **Profile Settings** > **API** > **Create Token**. Select the scopes you need (`mcp:read`, `mcp:write`) and copy the token.
  </Step>

  <Step title="Add the MCP server">
    **Option A — CLI command:**

    ```bash theme={null}
    claude mcp add --transport http --scope user \
      --header "Authorization: Bearer YOUR_TOKEN_HERE" \
      trilo https://api.trilo.chat/mcp
    ```

    **Option B — Config file** (`~/.claude.json`):

    ```json theme={null}
    {
      "mcpServers": {
        "trilo": {
          "type": "http",
          "url": "https://api.trilo.chat/mcp",
          "headers": {
            "Authorization": "Bearer YOUR_TOKEN_HERE"
          }
        }
      }
    }
    ```

    You can also use `.mcp.json` in your project root to share the config with your team (supports environment variable expansion like `${TRILO_PAT}`).
  </Step>

  <Step title="Verify the connection">
    Ask Claude Code:

    ```
    List my Trilo workspaces
    ```
  </Step>
</Steps>

## Options

You can append query parameters to the MCP URL for additional control:

| Parameter      | Description                      | Example                                           |
| -------------- | -------------------------------- | ------------------------------------------------- |
| `workspace_id` | Restrict to a specific workspace | `https://api.trilo.chat/mcp?workspace_id=abc-123` |
| `read_only`    | Force read-only mode             | `https://api.trilo.chat/mcp?read_only=true`       |

## Troubleshooting

<AccordionGroup>
  <Accordion title="OAuth browser doesn't open">
    Make sure you run `/mcp` inside Claude Code to trigger the authentication flow. If the browser still doesn't open, check that you have a default browser configured.
  </Accordion>

  <Accordion title="401 Unauthorized (PAT)">
    * Verify your token starts with `trilo_pat_` and is copied correctly
    * Check that the `Authorization` header uses the `Bearer` prefix
    * Confirm the token hasn't been revoked in **Profile Settings** > **API**
  </Accordion>

  <Accordion title="Tools not appearing">
    Try restarting Claude Code. Run `/mcp` to check the server status. Also verify the URL is exactly `https://api.trilo.chat/mcp` with no trailing slash.
  </Accordion>

  <Accordion title="Session expired (error -32002)">
    MCP sessions expire after 30 minutes of inactivity. Claude Code usually reconnects automatically. If not, run `/mcp` and re-authenticate.
  </Accordion>
</AccordionGroup>
