> The index of all pages is at https://docs.afffast.com/llms.txt.

# MCP server

Use the API as tools in Claude Code and Claude Desktop.

The API has a hosted MCP server. An AI client uses it to read and write your data. For example, you can ask "revenue by network" and the client calls the stats tool.

The URL is `https://api.afffast.com/mcp`. It uses the Streamable HTTP transport. Use an API key in the `Authorization` header. A key in the query string is not accepted.

## Connect Claude Code

Run this command. Use a test key (`sk_test_...`) first.

```bash
claude mcp add --transport http afffast https://api.afffast.com/mcp \
  --header "Authorization: Bearer sk_test_..."
```

Then ask: "Query the revenue by network for this year."

The [AI tools guide](https://docs.afffast.com/docs/ai.md) has one page for each tool. It has the steps for Claude Code, Codex, Cursor, VS Code, Windsurf and Claude Desktop. Each page keeps the key in an environment variable.

## Connect Claude Desktop

Add the server to the file `claude_desktop_config.json`. The `mcp-remote` package gives the HTTP server to Claude Desktop.

```json
{
  "mcpServers": {
    "afffast": {
      "command": "npx",
      "args": [
        "mcp-remote",
        "https://api.afffast.com/mcp",
        "--header",
        "Authorization: Bearer ${AFFFAST_API_KEY}"
      ],
      "env": { "AFFFAST_API_KEY": "sk_test_..." }
    }
  }
}
```

## What the tools do

- Each tool is one API operation. For example, `list_sites` is `GET /v1/sites`, and `get_stats` is `GET /v1/stats`.
- A tool call has the same scopes, rate limits, request logs and errors as the REST request. The call appears in the request logs.
- The key decides what the client sees. A read-only key has no write tools. A test key reads test data only.
- Two more tools read these docs. They need no scope and read no workspace data. The call still needs a valid API key. See [Docs tools](#docs-tools).
- Operations that only the dashboard can do (API keys, members, billing) are not tools. A file upload is not a tool.
- A new API operation becomes a tool with no other work.

## Docs tools

The server has two tools for these docs. An agent can read the docs without a web browser.

- `search_docs` takes `query` (words to search for) and an optional `limit` (1 to 10, default 5). It returns a list. Each item has the `title`, the `url` of the Markdown copy of the page, and a short `snippet`. Pages with a matching title come first.
- `read_doc` takes `path`, the path of a docs page, for example `/docs/quickstart`. It returns the Markdown of the page. An unknown path gives a tool error that tells the client to use `search_docs`.

Both tools are read-only. They need no scope, and every valid key sees them. A call without a valid key fails, as for all MCP calls. The docs come from the docs build, so they are the same as the pages of this site.
