t212-mcp
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@t212-mcpshow me my current positions"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
t212-mcp
An MCP (Model Context Protocol) server for the Trading 212 public API. It lets Claude Code or Claude Desktop read a Trading 212 Stocks ISA and place orders with your approval.
This project is not affiliated with or endorsed by Trading 212. It can place real trades with real money. It comes with no warranty (see LICENSE); you are responsible for every order it places.
Tools
Tool | Endpoint | Scope |
|
| account |
|
| portfolio |
|
| orders:read |
|
| history:orders |
|
| metadata |
|
| orders:read |
| none | portfolio, metadata |
| none | portfolio, metadata |
| none | portfolio, metadata |
| none | portfolio, metadata |
|
| orders:execute |
|
| orders:execute |
get_positions adds priceInAccountCurrency, the price per share in GBP (walletImpact.currentValue / quantity). currentPrice is in the instrument's own currency, often pence for London shares.
The instrument list is cached for 24 hours in ~/.cache/t212-mcp/instruments-<env>.json, since the endpoint allows one request per 50 seconds. The client spaces calls to each endpoint to stay inside its rate limit.
Related MCP server: Trading212 MCP Server
Orders
Placing an order takes two calls. A preview_* tool checks the order and returns the ticker, name, side, quantity, estimated GBP value and a token. confirm_order with that token asks you to approve the order, then places it. A token works once and expires after 5 minutes.
The approval question comes from the server through MCP elicitation, so Claude cannot answer it for you. It works with clients on older and newer MCP protocol versions. cancel_order asks the same way. If you decline or dismiss the question, nothing is sent. If the MCP client cannot show the question, the order is refused.
Approval is only as strong as your MCP client. A client set to accept server questions automatically, or one that lets the model answer them, defeats it.
The server enforces these rules:
Live order tools are off unless
T212_LIVE_TRADING=1is set. WithT212_ENV=demothey are always on.Order tools only work on a GBP account.
Each order has a GBP cap (default £1,000), and so does each day (default £2,000). Both apply to buys and sells.
There is no price quote endpoint, so a value is only estimated where it can be bounded. A market order needs a position already held, priced at
walletImpact.currentValue / quantityplus 5% for price movement. A limit or stop-limit order is valued at quantity times the limit price, converted to GBP.A holding worth less than £1 is not used for pricing, since its rounded value gives an unreliable price.
A stop buy is refused, because its fill price has no bound. Use a stop-limit order.
A limit price in USD or another foreign currency is converted at the rate implied by the largest held position in that currency. With no such position, the order is refused. A limit price for a London share quoted in pence (GBX) is in pence.
A sell larger than the quantity available for trading is refused.
An order request is never retried. On a timeout, a 408 or a 5xx response, or an unreadable response, the tool says the outcome is unknown, and the order counts toward the daily cap. Check
get_pending_ordersandget_order_historybefore trying again. A cancellation with no answer is reported the same way.Every preview, request, response and cancellation is appended to
~/.local/state/t212-mcp/orders-<env>.jsonl. The daily cap is read from this log, per local calendar day. On macOS and Linux the log is locked while the daily cap is checked, so two sessions cannot both pass it at once. Windows has no such lock.
To change the caps, create ~/.config/t212-mcp/config.toml. The server refuses to start if the file is not valid TOML, names an unknown setting, or sets a cap that is not a positive number:
max_order_gbp = 1000
max_daily_gbp = 2000Setup
uv syncCreate an API key in the Trading 212 app (Settings, API). A key for reading only needs account, portfolio, metadata, orders:read and history:orders. Placing orders also needs orders:execute. Restrict the key to your home IP address. Demo and live need separate keys.
The server reads the key and secret from environment variables first, then from the OS keychain.
Variable | Meaning |
|
|
| demo credentials |
| live credentials |
|
|
| caps file, default |
| instrument cache directory |
| order log file |
To keep the secrets in the macOS keychain instead:
uv run keyring set t212-mcp live_api_key
uv run keyring set t212-mcp live_api_secretClaude Code
claude mcp add trading212 -s user --env T212_ENV=live -- uv --directory /path/to/t212-mcp run t212-mcpAdd --env T212_LIVE_TRADING=1 to enable live orders.
Claude Desktop
Add this to ~/Library/Application Support/Claude/claude_desktop_config.json:
{
"mcpServers": {
"trading212": {
"command": "uv",
"args": ["--directory", "/path/to/t212-mcp", "run", "t212-mcp"],
"env": {"T212_ENV": "live"}
}
}
}Claude Desktop does not inherit your shell environment, so use the keychain or put the variables in env. Never commit them.
Tests
uv run pytestHTTP calls are mocked with respx. The code follows Trading 212's OpenAPI spec, which is not included here. To download it for reference:
mkdir -p spec && curl -sfL https://docs.trading212.com/_spec/api.json -o spec/api.jsonThis server cannot be deployed
Maintenance
Related MCP Connectors
Agentic brokerage access to a US brokerage account: quotes, orders, positions, cash and documents.
- Trade ItOAuthapp.tradeit
Connect brokerage accounts to AI assistants: holdings, orders, asset lookup, and approved trading.
Broad, OAuth-protected provider and financial-domain API tools for research agents.
Trades, stats, playbooks and notes from your Trandence trading journal. Read-only by default.
Related MCP Servers
- AlicenseAqualityDmaintenanceEnables AI assistants to interact with Trading 212 investment accounts for portfolio tracking, account management, and real-time order execution. It supports managing investment pies, analyzing historical data, and monitoring market performance across multiple instrument types.232MIT
- AlicenseNot gradedqualityDmaintenanceEnables AI agents to manage Trading212 brokerage accounts, including portfolio analysis, order placement (demo mode), and investment pie management.5MIT
- AlicenseNot gradedqualityBmaintenanceExposes Trading 212 trading account, instruments, orders, history, and pies as MCP tools. Allows placing and canceling real orders (defaults to demo/paper environment).Apache 2.0
- AlicenseNot gradedqualityDmaintenanceEnables AI assistants to read a Trading 212 portfolio (balances, positions, orders, history) and place trades via the public API, supporting both demo and live environments.MIT