# MCP server

Layer runs an [MCP](https://modelcontextprotocol.io) server at `https://uselayer.sh/mcp`. Add it to your AI assistant and it can find matched markets, look one up and check a trade's profit after fees, without you writing any code.

The tools only read. None of them places an order: orders go from the [Python SDK](https://uselayer.sh/docs/sdk.md) on your machine to each venue, with your own keys.

## Connect

You need a Layer API key from [your dashboard](https://uselayer.sh/dashboard/keys). The server uses Streamable HTTP and takes your key as a header.

**Claude Code**

```bash
claude mcp add --transport http layer https://uselayer.sh/mcp --header "Authorization: Bearer lyr_your_key"
```

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

```json
{
  "mcpServers": {
    "layer": {
      "url": "https://uselayer.sh/mcp",
      "headers": { "Authorization": "Bearer lyr_your_key" }
    }
  }
}
```

**Clients that only run local commands** can go through [`mcp-remote`](https://www.npmjs.com/package/mcp-remote):

```json
{
  "mcpServers": {
    "layer": {
      "command": "npx",
      "args": ["-y", "mcp-remote", "https://uselayer.sh/mcp", "--header", "Authorization: Bearer lyr_your_key"]
    }
  }
}
```

Then ask it something like "which NBA games are matched on Kalshi and Polymarket US tonight, and is any of them profitable after fees?"

## Tools

| Tool | What it does | Same as |
|---|---|---|
| `find_matches` | Lists markets that are the same bet on Kalshi and another venue, earliest event day first, with both venues' live prices and the best trade. Filters: `q`, `series`, `category`, `venue`, `from`, `to`, `limit`, `offset`; page with `next_offset` while `has_more` is true. | [`GET /v0/matches`](https://uselayer.sh/docs/api.md#get-v0-matches) |
| `lookup_match` | Finds one market's twin on another venue from its `venue` and `market_id`, with the confidence, the rule differences and live prices. Once it has settled, says how both venues settled it. | [`GET /v0/match`](https://uselayer.sh/docs/api.md#get-v0-match) |
| `check_profit` | Works out a trade's profit after both venues' fees from `contracts` and each side's price. | [`POST /v0/profit`](https://uselayer.sh/docs/api.md#post-v0-profit) |

Each tool answers with the same JSON as its endpoint, so the [API reference](https://uselayer.sh/docs/api.md) describes every field.

## Keys, limits and errors

A tool call counts as an API call on your key: the same 60 requests per minute, and the same access to live prices as your account has.

When a call fails, the tool gives your assistant the API's own error, with `detail` (what's wrong) and `hint` (how to fix it), so it can correct itself. Without a key, your assistant can still connect and see the tools; calling one answers with where to get a key.

No account? An agent can also [pay per call](https://uselayer.sh/docs/pay-per-call.md) over x402, with no key.
