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

# Connect Your AI Client

> Attach any MCP client to the AGI server - setup and authentication.

One server URL connects every client:

```text theme={null}
https://api.agi.tech/v1/mcp
```

OAuth-capable clients need nothing else - add the URL and complete the browser sign-in. Clients without OAuth send an API key in the `Authorization` header instead. Pick your client below.

## Client setup

<Tabs>
  <Tab title="Claude Code">
    Run this command in your terminal to add the AGI devices MCP server:

    ```bash theme={null}
    claude mcp add --transport http agi-devices https://api.agi.tech/v1/mcp
    ```

    Then open Claude Code, run `/mcp`, select `agi-devices`, and complete the
    browser sign-in. Verify the connection:

    ```bash theme={null}
    claude mcp list
    ```

    <Tip>
      Claude Code stores and refreshes the OAuth credentials. Use **Clear
      authentication** from `/mcp` if you need to sign in with another AGI
      account.
    </Tip>
  </Tab>

  <Tab title="Claude Desktop">
    Claude Desktop's `claude_desktop_config.json` only launches local (stdio)
    servers. Use the [`mcp-remote`](https://www.npmjs.com/package/mcp-remote)
    bridge to connect it to the remote AGI server and complete OAuth in your
    browser:

    ```json theme={null}
    {
      "mcpServers": {
        "agi-devices": {
          "command": "npx",
          "args": [
            "mcp-remote",
            "https://api.agi.tech/v1/mcp"
          ]
        }
      }
    }
    ```

    Common config locations:

    | Platform | Config file                                                       |
    | -------- | ----------------------------------------------------------------- |
    | macOS    | `~/Library/Application Support/Claude/claude_desktop_config.json` |
    | Windows  | `%APPDATA%\Claude\claude_desktop_config.json`                     |

    Restart Claude Desktop after saving the config.

    <Note>
      `mcp-remote` requires Node.js 18+ on your machine. If the browser does not
      open automatically, copy the authorization URL from the bridge output.
    </Note>
  </Tab>

  <Tab title="Cursor">
    Add this to `.cursor/mcp.json` (or Cursor's MCP settings):

    ```json theme={null}
    {
      "mcpServers": {
        "agi-devices": {
          "url": "https://api.agi.tech/v1/mcp",
          "headers": {
            "Authorization": "Bearer YOUR_API_KEY"
          }
        }
      }
    }
    ```

    Save the config, then restart Cursor or refresh MCP servers from Cursor settings. Create your API key at [platform.agi.tech/me/api-keys](https://platform.agi.tech/me/api-keys).
  </Tab>

  <Tab title="ChatGPT">
    ChatGPT can connect directly through the server's OAuth flow. In ChatGPT on
    the web:

    1. Enable developer mode under **Settings > Apps > Advanced settings**. Your
       workspace administrator may need to enable access first.
    2. Go to **Settings > Apps > Create**.
    3. Enter `https://api.agi.tech/v1/mcp` as the MCP server URL and choose OAuth.
    4. Select **Scan tools**, sign in to AGI when prompted, and finish creating
       the app.

    <Note>
      Full MCP actions are currently available through ChatGPT developer mode on
      supported plans and on the web. Availability and workspace permissions are
      controlled by OpenAI and may vary by account.
    </Note>
  </Tab>

  <Tab title="IDE Extensions">
    If you are using an IDE or editor extension that supports remote MCP servers with custom headers (VS Code MCP, Windsurf, Zed, etc.), add a remote MCP server with these values:

    | Field        | Value                         |
    | ------------ | ----------------------------- |
    | Name         | `agi-devices`                 |
    | URL          | `https://api.agi.tech/v1/mcp` |
    | Transport    | HTTP                          |
    | Header name  | `Authorization`               |
    | Header value | `Bearer YOUR_API_KEY`         |

    After saving, reload the extension or reconnect the MCP server so it can fetch the available tools.
  </Tab>

  <Tab title="Other clients">
    Use these details to connect any MCP-compatible client:

    | Field         | Value                                                        |
    | ------------- | ------------------------------------------------------------ |
    | **Endpoint**  | `https://api.agi.tech/v1/mcp`                                |
    | **Transport** | Streamable HTTP (JSON responses) or SSE                      |
    | **Auth**      | OAuth 2.1 discovery, or `Authorization: Bearer YOUR_API_KEY` |
    | **Protocol**  | MCP `2024-11-05` (JSON-RPC 2.0)                              |

    OAuth-capable clients discover the AGI authorization server automatically
    after connecting: add the URL with no token and complete the browser
    sign-in. Clients without OAuth support can send an API key in the
    `Authorization` header instead.

    <Note>
      Claude Desktop does not support `url`-style entries in its config file.
      See the **Claude Desktop** tab for the `mcp-remote` setup instead.
    </Note>
  </Tab>
</Tabs>

## Authentication

The server supports two authentication methods. OAuth is recommended for every client that supports remote MCP authorization; API keys remain available for clients that cannot complete a browser sign-in.

### OAuth 2.1 (recommended)

The server implements the [MCP authorization specification](https://modelcontextprotocol.io/specification/2025-06-18/basic/authorization), which is built on OAuth 2.1:

* **Authorization code flow with PKCE** (`S256`): the only supported grant, alongside refresh tokens. No client secret is required for public clients.
* **Automatic discovery**: an unauthenticated request returns a `401` with a `WWW-Authenticate` challenge pointing at the server's protected resource metadata (RFC 9728), which names the authorization server. Clients fetch the authorization server metadata (RFC 8414) from there.
* **Dynamic client registration** (RFC 7591): compatible clients register themselves automatically; there is nothing to pre-configure.
* **Scope**: the server requires the `email` scope. Grants missing it fail with `insufficient_scope`.
* **Token lifecycle**: clients store and refresh access tokens automatically. Revoke a grant by clearing the connection's saved authentication in your client, or via the authorization server's revocation endpoint.

In practice: add `https://api.agi.tech/v1/mcp` to an OAuth-capable client with no token or custom header, and the client walks the whole flow (discovery, registration, browser sign-in) on its own.

<Note>
  OAuth access tokens are accepted only by the MCP endpoint. They do not replace
  API-key or session authentication on other AGI REST APIs. Authorization is
  negotiated independently of the MCP protocol version: the `2024-11-05`
  protocol and the `2025-06-18` authorization specification work together.
</Note>

### API keys

If your MCP client does not support OAuth, create an API key at
[platform.agi.tech/me/api-keys](https://platform.agi.tech/me/api-keys) and send it
on every MCP request:

```http theme={null}
Authorization: Bearer YOUR_API_KEY
```

<Warning>
  Keep your API key private. Anyone with your key can connect to and control your
  registered Android devices. Revoke and regenerate it immediately at
  [platform.agi.tech/me/api-keys](https://platform.agi.tech/me/api-keys) if it is
  ever exposed.
</Warning>

## Verify the connection

After connecting, ask your assistant to list your devices - it should call [`list_devices`](/api-reference/tools/list-devices) and report your phone as `online`. Two quick checks if it doesn't:

* **Tool call fails** → an auth or client problem:
  [Authentication](/guides/troubleshooting/authentication) ·
  [MCP clients](/guides/troubleshooting/mcp-clients)
* **Call works, no device** → a phone-side problem:
  [Phone setup](/android-mcp/phone-setup) ·
  [Devices & Connectivity](/guides/troubleshooting/devices)

<Note>
  Sign in with the **same AGI account** everywhere: the Android app, the OAuth
  browser flow, and the dashboard where you created your API key. Account
  mismatches present as an empty device list, not as an auth error.
</Note>

## Next

<CardGroup cols={2}>
  <Card title="Quickstart" icon="rocket" href="/api-reference/quickstart">
    Run your first task end to end
  </Card>

  <Card title="Tool reference" icon="code" href="/api-reference/introduction">
    Every tool, parameter, and outcome
  </Card>
</CardGroup>
