# Connect your agent

> Add the fones MCP server to Claude Code, Cursor, Codex, Claude Desktop or any MCP client, with your API key in an environment variable.

Source: https://fones.ai/docs/connect

One MCP server for every client:

- URL: `https://api.fones.ai/mcp`
- Transport: streamable HTTP, stateless
- Auth: `Authorization: Bearer fones_...`

Create a key in the console under Developers and keep it in `FONES_API_KEY`. The blocks below read it from there, so it never lands in a file you commit. The tools a key can call follow its scopes: a key without `phones:buy` cannot buy.

## Claude Code

```bash
claude mcp add --transport http --scope user \
  fones https://api.fones.ai/mcp \
  --header "Authorization: Bearer $FONES_API_KEY"
```

Check it with `claude mcp list`, or `/mcp` inside a session. The shell expands the variable, so the key is saved in `~/.claude.json`. To keep it out of every file, add a project file instead; Claude Code reads `${FONES_API_KEY}` from the environment when it starts:

```json
{
  "mcpServers": {
    "fones": {
      "type": "http",
      "url": "https://api.fones.ai/mcp",
      "headers": {
        "Authorization": "Bearer ${FONES_API_KEY}"
      }
    }
  }
}
```

## Cursor

```json
{
  "mcpServers": {
    "fones": {
      "url": "https://api.fones.ai/mcp",
      "headers": {
        "Authorization": "Bearer ${env:FONES_API_KEY}"
      }
    }
  }
}
```

Put it in `~/.cursor/mcp.json` for every project, or `.cursor/mcp.json` for one. Cursor fills `${env:FONES_API_KEY}` from the environment it was started in. The server shows up under MCP in Cursor's settings.

## Codex

```toml
[mcp_servers.fones]
url = "https://api.fones.ai/mcp"
bearer_token_env_var = "FONES_API_KEY"
```

Or from the terminal:

```bash
codex mcp add fones --url https://api.fones.ai/mcp --bearer-token-env-var FONES_API_KEY
```

Codex sends the variable's value as the bearer token. It must be set in the shell that runs `codex`. Check with `codex mcp list`, or `/mcp` in a session.

## Claude Desktop

Claude Desktop reads `claude_desktop_config.json` (Settings, Developer, Edit config). It does not see your shell's variables, so the key goes in the file, and `mcp-remote` connects for it:

```json
{
  "mcpServers": {
    "fones": {
      "command": "npx",
      "args": [
        "-y",
        "mcp-remote",
        "https://api.fones.ai/mcp",
        "--header",
        "Authorization:${AUTH_HEADER}"
      ],
      "env": {
        "AUTH_HEADER": "Bearer fones_..."
      }
    }
  }
}
```

Restart Claude Desktop after saving. The file lives in `~/Library/Application Support/Claude/` on macOS and `%APPDATA%\Claude\` on Windows.

You can also add the server as a custom connector: Settings, Connectors, Add custom connector, with the URL above and an `Authorization` request header. Connectors connect from Anthropic's cloud, not from your computer.

## Any MCP client

Most clients take this shape. VS Code calls the top-level key `servers` instead of `mcpServers`.

```json
{
  "mcpServers": {
    "fones": {
      "type": "http",
      "url": "https://api.fones.ai/mcp",
      "headers": {
        "Authorization": "Bearer fones_..."
      }
    }
  }
}
```

Check the endpoint and your key without a client:

```bash
curl -s https://api.fones.ai/mcp \
  -H "Authorization: Bearer $FONES_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Accept: application/json, text/event-stream" \
  -d '{"jsonrpc":"2.0","id":1,"method":"tools/list"}'
```

## Or ask your agent

Paste this into an agent that can edit its own config:

```text
Add an MCP server named "fones": streamable HTTP at https://api.fones.ai/mcp, header "Authorization: Bearer <the value of FONES_API_KEY>". Keep the key in the environment, not in a file I commit. Then call list_phones and show me the result.
```

## Then

Ask for something small first: "Take a screenshot of my phone and tell me what is on it." Your agent will call `list_phones`, then `screenshot`. From there it can drive any app. The [MCP tools](https://fones.ai/docs/mcp) page lists what it can call.
