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

> ## Agent Instructions
> These docs moved from docs.flintai.dev to docs.switchagents.ai. Use docs.switchagents.ai for every link and request.
> To search these docs from an AI tool, connect the MCP server at https://docs.switchagents.ai/mcp. The page index is at https://docs.switchagents.ai/llms.txt.

# Connect your coding agent to Switch Trust

> Add the Switch Trust MCP server to Claude Code, Cursor, or VS Code and confirm it reads your workspace

**Add the Switch Trust MCP server to your coding agent and confirm it reaches your workspace.** Claude Code, Cursor, and VS Code each include an *MCP client*, the part of the coding agent that connects to MCP servers like this one. Setup takes an API key, an entry in the MCP client configuration, and a question to your coding agent.

## Before you begin

You'll need:

* A Switch Trust account that can create API keys, which needs the **Editor** role or higher.
* [uv](https://docs.astral.sh/uv/getting-started/installation/) installed. The server runs with `uvx`, which needs no clone and no build step. The server needs Python 3.11 or later.
* Your Switch Trust instance URL, such as `https://app.switchagents.ai`. The server sends your key only to an `https://` address on `switchagents.ai`.

## Connect the server

<Steps>
  <Step title="Create an API key">
    In Switch Trust, select **Settings**, then under **Admin** select **API keys**, and create a key. Copy the token when it's shown. You can't see it again. See [API keys](/switch-trust/admin/api-keys) for roles and expiration.

    Give the key the **Viewer** role or higher. The server only reads, so **Viewer** is enough.
  </Step>

  <Step title="Add the server to your MCP client">
    Add this entry to the MCP configuration for your client, with your token and instance URL in place of the examples.

    <Tabs>
      <Tab title="Claude Code">
        In `.mcp.json` at the root of your project:

        ```json theme={null}
        {
          "mcpServers": {
            "switch-trust-mcp": {
              "command": "uvx",
              "args": ["switch-trust-mcp"],
              "env": {
                "SWITCH_TRUST_API_KEY": "sk_...",
                "SWITCH_TRUST_INSTANCE": "https://app.switchagents.ai"
              }
            }
          }
        }
        ```
      </Tab>

      <Tab title="Cursor">
        In `.cursor/mcp.json` in your project, or `~/.cursor/mcp.json` for every project:

        ```json theme={null}
        {
          "mcpServers": {
            "switch-trust-mcp": {
              "command": "uvx",
              "args": ["switch-trust-mcp"],
              "env": {
                "SWITCH_TRUST_API_KEY": "sk_...",
                "SWITCH_TRUST_INSTANCE": "https://app.switchagents.ai"
              }
            }
          }
        }
        ```
      </Tab>

      <Tab title="VS Code">
        In `.vscode/mcp.json` in your workspace:

        ```json theme={null}
        {
          "servers": {
            "switch-trust-mcp": {
              "type": "stdio",
              "command": "uvx",
              "args": ["switch-trust-mcp"],
              "env": {
                "SWITCH_TRUST_API_KEY": "sk_...",
                "SWITCH_TRUST_INSTANCE": "https://app.switchagents.ai"
              }
            }
          }
        }
        ```
      </Tab>
    </Tabs>

    Restart your client or reload its MCP servers. The `switch-trust-mcp` tools now appear in its tool list.

    <Warning>
      **These files hold your API key in plain text.** Don't commit them. Add the file you edited, `.mcp.json`, `.cursor/mcp.json`, or `.vscode/mcp.json`, to `.gitignore`. If your client supports it, have it read the key from an environment variable instead.
    </Warning>
  </Step>

  <Step title="Confirm the server reaches your workspace">
    Ask your coding agent:

    ```text theme={null}
    Use switch-trust-mcp to show which Switch Trust instance and workspace you're connected to.
    ```

    Your coding agent calls `get_context` and reports the instance URL with a tenant ID and a workspace ID. The workspace is the one your API key belongs to. You don't configure it.
  </Step>
</Steps>

You now have a coding agent that can read your Switch Trust workspace.

## If the server doesn't connect

The server starts even when its configuration is wrong. It reports the problem the first time your coding agent calls a tool, in an `error` field in the tool result. Find what you see below.

| What you see | What it means | What to do |
| - | - | - |
| The `switch-trust-mcp` tools don't appear at all | Your client couldn't start `uvx` | Check that uv is installed and on the `PATH` your client sees, then restart the client. |
| An error starting `No API key set` | `SWITCH_TRUST_API_KEY` is missing from the `env` block for the server | Add it and reload the server. |
| An error starting `No valid instance URL set` | `SWITCH_TRUST_INSTANCE` is missing, doesn't start with `https://`, or isn't on `switchagents.ai` | Use the URL you open Switch Trust at, such as `https://app.switchagents.ai`. |
| An error that includes `GET /tenants -> HTTP 401` or `HTTP 403` | Switch Trust rejected the API key, which may be expired or revoked | Check that the key is active on the **API keys** page, or create a new one. |
| An error starting `Could not resolve tenant_id/active_workspace_id` | The organization behind the key isn't fully set up | Contact your Switch Trust administrator. |

## Next steps

<CardGroup cols={2}>
  <Card title="Optimize agents" icon="gauge-high" href="/switch-trust/mcp/index">
    Find what's driving the cost of an agent, change it, and prove quality and safety held
  </Card>

  <Card title="MCP tools" icon="list" href="/switch-trust/mcp/tools">
    Every tool the server offers and what it returns
  </Card>
</CardGroup>
