> 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))
* **7 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_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_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    |
| `tokenbot://system/health`              | Platform health        |

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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
