> For the complete documentation index, see [llms.txt](https://docs.tokenbot.com/home/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.tokenbot.com/home/api-docs/mcp/overview.md).

# Overview

The TokenBot MCP (Model Context Protocol) server lets AI assistants and LLMs interact with the TokenBot platform programmatically.

## What is MCP?

MCP is a protocol that lets AI models call tools and access data sources. The TokenBot MCP server exposes trading operations as tools, plus resources and prompts an assistant can use.

It provides:

* **25 tools** — exchanges, strategies, copiers, trades, and user context ([Tools Reference](/home/api-docs/mcp/tools.md))
* **6 resources** — read-only data under the `tokenbot://` scheme
* **4 prompts** — `onboarding`, `portfolio_summary`, `troubleshoot`, `optimize_strategy`

## Connection

The server runs locally and communicates over **stdio**. Its binary is `tokenbot-mcp`.

```jsonc
// Example Claude Desktop config (mcpServers entry)
{
  "mcpServers": {
    "tokenbot": {
      "command": "tokenbot-mcp",
      "env": {
        "GRAPHQL_ENDPOINT": "https://gql-api.tokenbot.com/graphql",
        "GRAPHQL_SERVICE_TOKEN": "your_service_token",
        "DEFAULT_USER_ID": "user_123"
      }
    }
  }
}
```

## Authentication

The server authenticates to the TokenBot GraphQL backend using header credentials supplied via environment variables:

| Variable                | Purpose                                                                                                                              |
| ----------------------- | ------------------------------------------------------------------------------------------------------------------------------------ |
| `GRAPHQL_ENDPOINT`      | Backend GraphQL URL. Defaults to `http://localhost:4000/graphql`, so set it to `https://gql-api.tokenbot.com/graphql` for production |
| `GRAPHQL_SERVICE_TOKEN` | Sent as the `X-Service-Token` header                                                                                                 |
| `DEFAULT_USER_ID`       | Sent as the `X-User-Id` header (the acting user)                                                                                     |

At runtime, an assistant can switch the acting user with the `set_user_context` tool, passing either a `userId` or a `tb_`-format API key (the user ID is extracted from the key).

## Resources

| URI                                     | Description            |
| --------------------------------------- | ---------------------- |
| `tokenbot://exchanges/list`             | Your exchange accounts |
| `tokenbot://strategies/list`            | Your strategies        |
| `tokenbot://copiers/list`               | Your copiers           |
| `tokenbot://trades/list`                | Recent trades          |
| `tokenbot://trades/analytics`           | Trade analytics        |
| `tokenbot://system/supported-exchanges` | Supported exchanges    |

See the [Tools Reference](/home/api-docs/mcp/tools.md) for the full tool list.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.tokenbot.com/home/api-docs/mcp/overview.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
