# For AI agents: Markdown docs, llms.txt, OpenAPI and MCP

The docs and the API are ready for AI: every page copies as Markdown, the specs are machine-readable, and agents can query events directly over MCP.

> Source: https://tokenearly.com/en/developers/ai · Docs index: https://tokenearly.com/en/developers/llms.txt · OpenAPI: https://api.tokenearly.com/v1/openapi.json

## What MCP is

MCP (Model Context Protocol) is an open protocol for AI clients to call external tools. It is an API too, but the caller is the AI: once Claude, Cursor or a similar client connects to the MCP server it receives the tool list and parameter docs and queries as needed during a conversation, with no request code from you.

|  | REST | MCP | WebSocket |
|---|---|---|---|
| Caller | Your code | AI clients (Claude, Cursor…) | Your code |
| What it does | Query history | Query history (same data) | Real-time push |
| Auth | Same API key | Same API key | Same API key |
| Limit | 1 every 3s | Shared with REST | 1 connection(s) per key |

Every MCP tool call (`get_events`, `get_event`, `get_alerts`, `whoami`) shares the key's REST limit, 1 call every 3 seconds in total; over the limit the tool returns a `rate_limited` error and the AI retries later. `list_topics` and `get_schema` do not count.

## MCP server

Endpoint `https://api.tokenearly.com/v1/mcp` (Streamable HTTP). Authenticate with the `Authorization: Bearer <key>` header; trial keys work too. Every tool is read-only.

**Claude Code**

```bash
claude mcp add --transport http tokenearly https://api.tokenearly.com/v1/mcp \
  --header "Authorization: Bearer YOUR_API_KEY"
```

**Cursor**

```json
{
  "mcpServers": {
    "tokenearly": {
      "url": "https://api.tokenearly.com/v1/mcp",
      "headers": {
        "Authorization": "Bearer YOUR_API_KEY"
      }
    }
  }
}
```

**Claude Desktop**

```json
{
  "mcpServers": {
    "tokenearly": {
      "command": "npx",
      "args": [
        "-y",
        "mcp-remote",
        "https://api.tokenearly.com/v1/mcp",
        "--header",
        "Authorization:${TOKENEARLY_AUTH}"
      ],
      "env": {
        "TOKENEARLY_AUTH": "Bearer YOUR_API_KEY"
      }
    }
  }
}
```

**cURL**

```bash
curl -s https://api.tokenearly.com/v1/mcp \
  -H "Content-Type: application/json" \
  -H "Accept: application/json, text/event-stream" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -d '{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"get_events","arguments":{"topics":"announcement.*","limit":3}}}'
```

| Tool | What it does |
|---|---|
| `list_topics` | List every subscribable topic (exchange announcements, news, signals and curated X (Twitter) KOL accounts) with `id`, `type`, `source_id` and `names`; with a key each topic also gets `accessible`. Same as REST `GET /v1/topics`; does not count against the rate limit. |
| `get_events` | Query structured events (exchange announcements, news, signals and posts from curated X (Twitter) KOLs), newest first by default. Same parameters as REST `GET /v1/events`; only the `limit` range differs. Shares the key's rate limit with REST. |
| `get_event` | Fetch the latest revision of one event by id, like REST `GET /v1/events/{id}`. Counts against the rate limit. |
| `get_alerts` | Query this account's my alerts: what was actually pushed to you after your source, keyword, alert-language and delay settings, newest first. Different from get_events (every event of a topic). Same parameters as REST `GET /v1/alerts`; only the `limit` range differs. Requires the Developer API switch in the dashboard. Counts against the rate limit. |
| `get_schema` | JSON Schema of the event envelope and each data type, like REST `GET /v1/schema`. No key needed; does not count against the rate limit. |
| `whoami` | The effective topics, limits, IP allowlist and access end date of the key in use, like REST `GET /v1/me`. Counts against the rate limit. |

## Tool arguments

Arguments are checked strictly against each tool's definition, as REST does: an undefined argument, a missing required one, a wrong type or a value out of range returns JSON-RPC error `-32602` (Invalid params) with the reason, without running the query or counting against the rate limit. `get_events` takes the same parameters as REST `GET /v1/events` except `limit`: over MCP it is 1–50, default 10.

### `list_topics`

No arguments.

### `get_events`

| Argument | Type | Required | Default | Range | Description |
|---|---|---|---|---|---|
| `topics` | string |  |  |  | Comma-separated, any combination (e.g. `announcement.binance,news.*`); each item is a topic or pattern: `announcement.binance`, `announcement.*`, `news.*`, `signal.*`, `twitter.*`, `*`. Omit for every topic your key can read. |
| `limit` | integer |  | `10` | 1–50 | How many events to return, 1–50, default 10 (REST allows 1–200). A value outside the range or not an integer is an invalid-params error (-32602). |
| `after` | string |  |  |  | Return events newer than this event id, oldest first. Use it to catch up after a disconnect. |
| `before` | string |  |  |  | Return events older than this event id, newest first. Use it to page backwards. |
| `listings_only` | boolean |  | `false` |  | Set to true to return only exchange announcements classified as new listings (`data.listing.is_listing = true`); topics of other types return nothing. Works with `after` / `before` / `updated_after`. Because it filters on the classification, a page can hold fewer than `limit` events while `has_more` is still true: keep paging with `next_cursor` until `has_more` is false. |
| `updated_after` | integer |  |  | ≥ 0 | Return events that got a new revision after this Unix time (seconds), even if the event itself is older, ordered by event id. Use it to pick up updates to older events missed while offline. To page, keep `updated_after` and pass the previous `next_cursor` as `after`. Cannot be combined with `before`. Omitting it or passing 0 means it is not used (a normal newest-first list). |

### `get_event`

| Argument | Type | Required | Default | Range | Description |
|---|---|---|---|---|---|
| `id` | string | ✓ |  |  | Event id, as returned by the list endpoint. |

### `get_alerts`

| Argument | Type | Required | Default | Range | Description |
|---|---|---|---|---|---|
| `limit` | integer |  | `10` | 1–50 | How many to return, 1–50, default 10; out of range is an invalid-params error. |
| `after` | string |  |  |  | Only alerts after this alert id, oldest first. |
| `before` | string |  |  |  | Only alerts before this alert id, newest first. |

### `get_schema`

No arguments.

### `whoami`

No arguments.

## Docs for AI to read

- Every page has Copy Markdown at the top; you can also append `.md` to any docs URL for the plain-text version.
- [llms.txt](https://tokenearly.com/en/developers/llms.txt): the docs index, for an AI to browse before reading what it needs.
- [llms-full.txt](https://tokenearly.com/en/developers/llms-full.txt): all docs in one file, read in one go.

## Machine-readable files: llms.txt, OpenAPI, AsyncAPI

These are the links at the bottom left of the docs. They are not pages for people but files for programs and AI: import them into tools to generate requests and client code, or let an AI understand the API.

| File | Use |
|---|---|
| [llms.txt](https://tokenearly.com/en/developers/llms.txt) | Docs index (a list of Markdown links); an AI reads it first, then opens pages as needed |
| [openapi.json](https://api.tokenearly.com/v1/openapi.json) | OpenAPI 3.1: import into Postman, generate clients, configure GPT Actions |
| [asyncapi.json](https://api.tokenearly.com/v1/asyncapi.json) | AsyncAPI 3.0: stream message definitions |
| [schema](https://api.tokenearly.com/v1/schema) | JSON Schema: validate events, generate types |

## Prompt template

Hand this to an AI coding assistant; it reads the docs before writing code:

```
You are my coding assistant. First read the Tokenearly Developer API docs: https://tokenearly.com/en/developers/llms-full.txt
Then write a Python service that subscribes to announcement.* over WebSocket, handles only events where data.listing.is_listing is true, deduplicates on (id, revision), resumes with after on reconnect, and forwards titles to my Telegram group. Test it first with the trial key I got from the dashboard.
```
