# Connect to Trading API over MCP

You are an AI agent helping a person connect their MCP client to Trading API, an exchange for AI agents: perpetual futures on crypto and US stocks, in US dollars. This page says what to set up, what only the person can do, and how to check that it worked. Follow it step by step, and tell the person what you are doing.

This page is the whole integration: there is no plugin or app to search for. Setup takes a few commands or clicks. If a step does not work as described here, stop and tell the person what you saw; don't work around it with scripts, internal or undocumented client APIs, or by driving their browser.

## The server

- URL: `https://tradingapi.dev/mcp`
- Transport: Streamable HTTP (remote only; there is nothing to install or run locally)
- Authentication: OAuth. The client gets the credentials when the person signs in; no API key is needed.
- Suggested name: `tradingapi`

## 1. Add the server to the client

Use the way your client adds a remote MCP server over HTTP: a command, a settings screen, or a configuration file. If you are not sure how your client does it, check its own help or documentation; don't guess at a command.

Some clients, as examples:

| Client | How |
|---|---|
| Claude Code | `claude mcp add --scope user --transport http tradingapi https://tradingapi.dev/mcp` |
| Codex | `codex mcp add tradingapi --url https://tradingapi.dev/mcp` |
| Cursor | Add `"tradingapi": { "url": "https://tradingapi.dev/mcp" }` under `mcpServers` in `~/.cursor/mcp.json` |
| Claude (web or desktop) | The person adds it under Settings > Connectors > Add custom connector |

Add it for the person only, not to a shared project file: the connection trades with their account. If a server with this name or URL is already configured, ask the person before replacing or changing it.

## 2. Load the server, if the client needs it

Some clients connect to a new server at once. Many load servers only when a session starts, so the conversation that adds the server cannot use its tools. That is expected, not a failure, and you should not try to fix it.

If the Trading API tools are not available to you after the sign-in (step 3), tell the person, in so many words: "It's connected. Your client loads new servers when a session starts: start a new session (or reload its MCP servers, if it has that option) and ask me to call get_account." Then stop.

## 3. Sign in: the person does this

Signing in is the person's step; you cannot do it for them. The client opens a browser, or shows a way to start it (for example a sign-in command, or an authenticate action in its MCP settings). In Claude Code it is `/mcp`, then `tradingapi`, then Authenticate; in Codex, `codex mcp login tradingapi`. If you start the sign-in, tell the person a browser page has opened for them, and leave the page to them: don't read, fill in or click it.

Tell the person what to expect:

1. They sign in to Trading API with their email and a one-time code. If they have no account, signing in creates one.
2. A consent screen asks what this connection may do:
   - **Read only**: markets, balances, positions, orders and fills.
   - **Trade**: also place and close orders, within limits they choose: the markets, the largest order, and the total per 24 hours.
   - Optionally, **Ask me to confirm each order**: the client then asks them before every order.
3. They approve, and the browser returns to the client.

Never ask the person for their one-time code, a password, or any secret in the conversation.

## 4. Check that it works

If the Trading API tools are available to you, call `get_account`. It answers with the account's balances and this connection's limits.

If they are not available yet (step 2), you can still check the sign-in finished where your client shows it: a status command or its MCP settings (for example `codex mcp list`, or `/mcp` in Claude Code, shows the server as signed in). Then tell the person to start a new session, as in step 2.

- If it says the connection is read-only, the person chose Read only. They can give it limits on their account page at https://tradingapi.dev/account, without connecting again.
- If it says trading is not active, or the balance is zero, the account needs setting up or funding on the same page: they deposit USDC on Arbitrum to the deposit address `get_account` gives, then activate trading.

Then tell the person what they can ask you to do, for example: "find the Tesla market", "preview a $20 BTC buy", "show my positions".

## Without a browser

On a server or anywhere the person cannot sign in through a browser, the client can authenticate with an API key instead. The person creates one on https://tradingapi.dev/account, with its own limits, and puts it in the client's configuration as the header `Authorization: Bearer tapi_…`. Ask them to put it there themselves, not to paste it into the conversation.

## If something goes wrong

- **HTTP 401 with no sign-in prompt.** The client did not start OAuth. Check that it supports OAuth for remote servers, and that the URL is exactly `https://tradingapi.dev/mcp`.
- **The sign-in page says the app is not one it knows, or sends the person back with an error.** Remove the server from the client, add it again, and retry the sign-in.
- **No Trading API tools appear.** The client has not loaded the server yet (step 2), or the sign-in did not finish (step 3).
- **An order is refused.** The tool's error has a `hint`; follow it.

More: https://docs.tradingapi.dev/guides/mcp
