# MCP server

> Connect Claude, Cursor or any MCP client to Market History. Add the URL and sign in in the browser.

Source: https://getmarkethistory.com/docs/mcp

Market History runs a remote [MCP](https://modelcontextprotocol.io) server at
`https://getmarkethistory.com/mcp` (Streamable HTTP). An AI agent connected to it can look up
markets and symbols and pull bars on your account. It is the same API underneath:
every tool call is billed exactly like the matching `/query/v1/` request, against the same balance,
under the same [limits](https://getmarkethistory.com/docs/limits).

## Connect

Add `https://getmarkethistory.com/mcp` to your client. The first time it connects, a browser
window opens: sign in with Google or GitHub (a new account is created on the spot), check the app
name, and press **Allow**. No key to copy. Disconnect an app any time from the
[dashboard](https://getmarkethistory.com/dashboard) (Keys tab, Connected apps).

**Claude (claude.ai and Claude Desktop):** Settings → Connectors → Add custom connector, paste the
URL, then Connect.

**Claude Code**

```sh
claude mcp add --transport http market-history https://getmarkethistory.com/mcp
```

then run `/mcp` in Claude Code and pick `market-history` to sign in.

**Cursor and other clients** that take a JSON config (`.cursor/mcp.json`):

```json
{
  "mcpServers": {
    "market-history": { "url": "https://getmarkethistory.com/mcp" }
  }
}
```

### With an API key instead

For a client without browser sign-in, or a headless agent, create a key on the
[dashboard](https://getmarkethistory.com/dashboard) and send it as a header:

```sh
claude mcp add --transport http market-history https://getmarkethistory.com/mcp \
  --header "Authorization: Bearer $MARKET_HISTORY_KEY"
```

```json
{
  "mcpServers": {
    "market-history": {
      "url": "https://getmarkethistory.com/mcp",
      "headers": { "Authorization": "Bearer mh_live_..." }
    }
  }
}
```

A client that only speaks stdio can bridge with `npx mcp-remote https://getmarkethistory.com/mcp`
(it handles the sign-in too), or add `--header "Authorization: Bearer mh_live_..."`.

## Tools

| Tool                    | What it returns                                           | Cost                             |
| ----------------------- | --------------------------------------------------------- | -------------------------------- |
| `get_coverage`          | Markets, what each holds, timeframes, first and last date | Free                             |
| `search_symbols`        | Tickers in one market containing a substring              | Free                             |
| `get_bars`              | OHLCV bars of one symbol, CSV, up to 2,000 rows a call    | Bars returned, rounded up to 100 |
| `get_funding`           | Funding rate events of one perpetual, CSV                 | Rows returned, rounded up to 100 |
| `get_corporate_actions` | Splits, dividends, symbol changes and mergers, CSV        | Free                             |

Each billed result ends with `bars_charged` (the same number as the API's `X-Bars-Charged`) and
`next_cursor`: pass it back as `cursor` to fetch the next page. Free monthly bars pay for 1h bars
only; other timeframes and funding rates spend bought bars, and a call that your balance cannot
pay for is refused with the API's own message and a top-up link (`/buy?bars=…`) for the agent to
hand you: open it, pay, and tell the agent to retry.

The free tools still count toward the per-account request limits.
