trading212-mcp
This server integrates the Trading 212 public API into MCP, enabling account monitoring, portfolio management, market data access, and opt-in trading for equities and ETFs on Invest and Stocks ISA accounts.
Account & Portfolio
Retrieve account summaries: cash breakdown (available, reserved, in pies), investments, realized/unrealized P&L, and total value
List all open positions with quantity, average/current price, unrealized P&L, and FX impact
Fetch details for a single position by ticker
Orders
List all pending equity orders (market, limit, stop, stop-limit) with status, quantities, and prices
Fetch details of a single pending order by ID
Browse executed (historical) orders with fill details and wallet impact (cursor-paginated, newest first)
Pies (Automated Portfolios)
List all pies with money-in, goal progress, performance, and dividend details
Fetch full pie definitions including per-instrument breakdown, weights, and issues (e.g. delisted instruments)
Market Data
List exchanges with working schedules and session open/close times
Search ~17,000 tradable instruments by ticker/name and filter by type (STOCK, ETF, WARRANT, etc.)
History & Reporting
List paid-out dividends with amounts and gross per share (cursor-paginated)
List cash transactions: deposits, withdrawals, fees, and transfers (cursor-paginated)
Check status of CSV export reports and retrieve download links
Write/Trading Tools (opt-in via T212_MCP_ENABLE_TRADING=true)
Place market, limit, stop, and stop-limit orders (positive quantity = BUY, negative = SELL)
Cancel pending equity orders by ID
Create, update, delete, and duplicate investment pies
Request asynchronous CSV export reports of account history
Safety & Configuration
Defaults to demo (paper trading) environment; set
T212_ENV=livefor live tradingTrading tools are hidden unless explicitly enabled via environment flag
Handles HTTP 429 rate limits with automatic retries
HTTP transport binds to
127.0.0.1by default; no built-in authentication on HTTP endpoint (use a reverse proxy)Requires a Trading 212 API key for authentication
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., "@trading212-mcp show my portfolio 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.
trading212-mcp
MCP server for the Trading 212 public API — equities and ETF investing on Invest and Stocks ISA accounts. It exposes the account, portfolio, order, pie, and history endpoints as MCP tools, defaults to the demo (paper trading) environment, and keeps trading tools hidden unless explicitly enabled.
Features
Read coverage of the whole public API: account summary, instrument universe, exchange schedules, open positions, pending orders, pies, historical orders, dividends, cash transactions, and CSV exports.
Trading tools (order placement/cancellation, pie management, export requests) are opt-in via an environment flag and stay invisible to the MCP client otherwise.
Demo environment by default; live is an explicit choice.
Responses are trimmed to the fields a trader acts on, and list tools accept a
limitparameter to keep payloads small.One automatic retry on HTTP 429, honouring the
Retry-Afterheader capped at 30 seconds (Trading 212 rate limits are strict and per-endpoint).stdio transport by default, HTTP (
/mcp) on request.
Related MCP server: tastytrade-mcp
Tools
Read tools (always registered):
Tool | Description |
| Account summary: cash breakdown, investments, and overall result |
| Exchanges with working schedules trimmed to session open/close events |
| Search the tradable instrument universe by ticker/name substring and type |
| List all open positions with quantity, prices, and unrealized P/L |
| Fetch a single open position by its Trading 212 ticker |
| List all pending equity orders |
| Fetch one pending equity order by its id |
| List all pies with money-in, progress, and performance |
| Fetch one pie's full definition and per-instrument breakdown |
| List executed equity orders, newest first (cursor-paginated) |
| List paid-out dividends (cursor-paginated) |
| List cash transactions: deposits, withdrawals, fees, transfers (cursor-paginated) |
| List requested CSV export reports and their processing status |
Write tools (registered only when T212_MCP_ENABLE_TRADING is truthy):
Tool | Description |
| Place a market order (positive quantity = BUY, negative = SELL) |
| Place a limit order with a limit price and DAY/GTC validity |
| Place a stop order that triggers a market order at the stop price |
| Place a stop-limit order (limit order placed once the stop triggers) |
| Cancel a pending equity order by its id |
| Create a new pie from a ticker-to-weight allocation map |
| Replace an existing pie's definition (name and full allocation) |
| Delete a pie by ID (irreversible) |
| Duplicate an existing pie under a new name |
| Request an asynchronous CSV export report of account history |
Configuration
All configuration is via environment variables — never commit credentials.
Variable | Default | Purpose |
| — (required) | API key (Basic auth username), generated in the Trading 212 app |
| — (required) | API secret (Basic auth password) |
|
| Target environment: |
| off | Set to |
Getting started
Run straight from the repository with uv:
uvx --from git+https://github.com/florinel-chis/trading212-mcp trading212-mcpThe server speaks stdio by default; add --transport http --port 8000 to
serve MCP over HTTP at /mcp instead. HTTP binds 127.0.0.1 by default,
and a non-loopback --host is refused unless --allow-remote is also
passed — read the Safety section before using that flag.
MCP client configuration
Add the server to your MCP client's configuration (stdio, via uvx):
{
"mcpServers": {
"trading212": {
"command": "uvx",
"args": ["--from", "git+https://github.com/florinel-chis/trading212-mcp", "trading212-mcp"],
"env": {
"T212_API_KEY": "your-api-key",
"T212_API_SECRET": "your-api-secret"
}
}
}
}Or run the Docker image (build it first, see below):
{
"mcpServers": {
"trading212": {
"command": "docker",
"args": [
"run", "-i", "--rm",
"-e", "T212_API_KEY",
"-e", "T212_API_SECRET",
"trading212-mcp"
],
"env": {
"T212_API_KEY": "your-api-key",
"T212_API_SECRET": "your-api-secret"
}
}
}
}Docker
docker build -t trading212-mcp .
# stdio (what MCP clients spawn)
docker run -i --rm -e T212_API_KEY -e T212_API_SECRET trading212-mcp
# HTTP at http://127.0.0.1:8000/mcp — publish the port on loopback only:
# the MCP endpoint is unauthenticated (see Safety)
docker run --rm -p 127.0.0.1:8000:8000 -e T212_API_KEY -e T212_API_SECRET \
trading212-mcp --transport http --host 0.0.0.0 --port 8000 --allow-remote(--host 0.0.0.0 binds inside the container so the port mapping works —
which is why --allow-remote is needed; the 127.0.0.1: prefix on -p
keeps the endpoint reachable from this machine only.)
Safety
The HTTP transport has no authentication: anyone who can reach the
/mcpendpoint can call every registered tool — read the account, and place/cancel orders or delete pies ifT212_MCP_ENABLE_TRADINGis set — all signed with your API key. Keep it bound to127.0.0.1(the CLI default; with Docker, publish as-p 127.0.0.1:8000:8000) or put it behind an authenticating reverse proxy. Never expose it directly on a public or shared network.The server defaults to the demo (paper trading) environment; set
T212_ENV=livedeliberately.Trading tools are not registered — invisible to the MCP client — unless
T212_MCP_ENABLE_TRADINGis truthy.The Trading 212 API is v0 beta: order endpoints are not idempotent (resending a request may create duplicate orders), and rate limits are strict and per-endpoint (each tool documents its limit).
Use at your own risk. Nothing here is investment advice.
Development
uv sync
uv run pytest -q
uv run ruff check .License
MIT
Available Tools
13 toolsget_account_summaryARead-only
Get the account summary: cash breakdown, investments, and overall result.
Returns a dict with:
id: primary trading account number.currency: ISO 4217 primary account currency; every monetary value below is denominated in it.totalValue: total account value (cash plus investments).cash:availableToTrade(free funds),reservedForOrders(held for pending orders),inPies(uninvested cash inside pies).investments:currentValue,totalCost(cost basis of the current holdings),realizedProfitLoss(all-time realized P/L),unrealizedProfitLoss.
Rate limit: 1 request per 5 seconds.
Inputs: no named parameters. Returns: object
get_orderARead-only
Fetch one pending equity order by its id.
Returns the order's id, ticker, type (LIMIT|STOP|MARKET|STOP_LIMIT), side (BUY|SELL), status, quantity, filledQuantity, limitPrice / stopPrice (when applicable), timeInForce, currency, extendedHours and createdAt. Responds HTTP 404 if no pending order has that id. Rate limit: 1 request per 1 second.
Inputs: order_id (required). Returns: object
get_pieARead-only
Fetch one pie's full definition and per-instrument breakdown.
Returns the pie settings (id, name, icon, goal in account currency, creationDate, endDate, dividendCashAction, initialInvestment, instrumentShares as a ticker-to-weight map, publicUrl) plus an instruments list with each holding's ticker, ownedQuantity, currentShare vs expectedShare (weights, 0..1), result, and any issues (e.g. DELISTED, SUSPENDED) with severity. Raises HTTP 404 if the pie does not exist. Rate limit: 1 request per 5 seconds.
Inputs: pie_id (required). Returns: object
get_portfolioARead-only
List all open positions in the account.
Returns up to limit positions, each with: ticker (Trading 212
identifier, e.g. "AAPL_US_EQ"), quantity (shares held, fractional
allowed), averagePrice and currentPrice (per share, instrument
currency), ppl (unrealized profit/loss, account currency), fxImpact
(currency-conversion component of ppl, account currency; null when
the instrument trades in the account currency), and initialFillDate
(ISO 8601 timestamp the position was opened).
Rate limit: 1 request per 1 second.
Inputs: limit. Returns: Generic wrapper for non-object return types.
get_positionARead-only
Fetch a single open position by its Trading 212 ticker.
Returns the same trimmed fields as get_portfolio: ticker, quantity (shares, fractional allowed), averagePrice and currentPrice (per share, instrument currency), ppl (unrealized profit/loss, account currency), fxImpact (nullable, account currency), initialFillDate (ISO 8601). Errors if there is no open position for the ticker.
Rate limit: 1 request per 1 second.
Inputs: ticker (required). Returns: object
list_dividendsARead-only
List paid-out dividends.
Returns {"items": [...], "next_cursor": str | None}. Each item:
ticker, paidOn (ISO 8601), amount (net, in the account currency),
grossAmountPerShare (in the instrument currency), quantity (shares
held), type (e.g. ORDINARY, INTEREST, CAPITAL_GAINS), reference.
Pass next_cursor back as cursor for the next page; it is null on
the last page. Rate limit: 6 requests per 1 minute.
Inputs: limit, cursor, ticker. Returns: object
list_exchangesARead-only
List exchanges with working schedules trimmed to session open/close events.
Returns one entry per exchange: id, name (e.g. "NYSE"), and
workingSchedules. Each schedule carries its id (instruments
reference it via workingScheduleId) and events — the time
events filtered down to OPEN and CLOSE (pre-market,
after-hours, overnight, and break events are dropped). Event date
values are ISO 8601 timestamps.
Rate limit: 1 request per 30 seconds (data refreshes server-side every 10 minutes).
Inputs: limit. Returns: Generic wrapper for non-object return types.
list_exportsARead-only
List requested CSV export reports and their processing status.
Returns {"items": [...]} where each report has: reportId, timeFrom, timeTo, dataIncluded (the four include* flags), status, downloadLink (populated once the report is finished). Status values are Mixed-Case, not upper-case: "Queued", "Processing", "Running", "Canceled", "Failed", "Finished". Poll this after request_export until the report's status is "Finished", then fetch the CSV from downloadLink. Rate limit: 1 request per 1 minute.
Inputs: limit. Returns: object
list_historical_ordersARead-only
List executed (historical) equity orders, newest first.
Returns {"items": [...], "next_cursor": str | None}. Each item has an
"order" part (id, ticker, type LIMIT|STOP|MARKET|STOP_LIMIT, side
BUY|SELL, status, quantity, filledQuantity, limitPrice, stopPrice,
timeInForce DAY|GOOD_TILL_CANCEL, currency, createdAt) and a "fill"
part (filledAt, price, quantity, type e.g. TRADE, tradingMethod
TOTV|OTC) plus a "walletImpact" with netValue and realisedProfitLoss
in the account currency. Pass next_cursor back as cursor to fetch
the next page; next_cursor is null on the last page.
Rate limit: 6 requests per 1 minute.
Inputs: limit, cursor, ticker. Returns: object
list_instrumentsARead-only
Search the tradable instrument universe.
The API returns the full universe (roughly 17,000 instruments) in one
response with no server-side filtering, so search,
instrument_type, and limit are applied client-side here.
Rate limit: 1 request per 50 seconds — strict. Every call fetches the whole universe, so batch your lookups into one broad search rather than issuing several calls in quick succession.
Returns per instrument: ticker (unique T212 identifier such as
"AAPL_US_EQ"; may contain "/" like "BRK/A_US_EQ"), type, name,
shortName (exchange symbol, may contain dots), isin,
currencyCode (ISO 4217, except "GBX" — pence — for some LSE
lines), maxOpenQuantity (fractional allowed), and
extendedHours (whether it trades outside the regular session).
Inputs: limit, search, instrument_type. Returns: Generic wrapper for non-object return types.
list_ordersARead-only
List all pending (not yet filled/cancelled/expired) equity orders.
Returns a list of order objects with: id, ticker (e.g. 'AAPL_US_EQ'),
type (LIMIT|STOP|MARKET|STOP_LIMIT), side (BUY|SELL), status,
quantity, filledQuantity, limitPrice/stopPrice (when applicable),
timeInForce (DAY|GOOD_TILL_CANCEL), currency, extendedHours,
createdAt. The API returns every pending order; limit truncates
the list locally. Rate limit: 1 request per 5 seconds.
Inputs: limit. Returns: Generic wrapper for non-object return types.
list_piesARead-only
List all pies in the account with money-in, progress, and performance.
Returns a list of pie summaries: id (use with get_pie), cash (money put into the pie, in the account currency), progress (fraction of the goal reached, 0..1), status ("AHEAD" | "ON_TRACK" | "BEHIND"), dividendDetails (gained/inCash/reinvested), and result (invested value, absolute result, result coefficient, current value). The API returns all pies; the limit is applied after fetching. Rate limit: 1 request per 30 seconds.
Inputs: limit. Returns: Generic wrapper for non-object return types.
list_transactionsARead-only
List cash transactions (deposits, withdrawals, fees, transfers).
Returns {"items": [...], "next_cursor": str | None}. Each item:
type (WITHDRAW | DEPOSIT | FEE | TRANSFER), amount (in the
transaction currency), currency, dateTime (ISO 8601), reference
(transaction ID). Unlike the other history endpoints the cursor here
is a string, not a number. Pass next_cursor back as cursor for the
next page; it is null on the last page.
Rate limit: 6 requests per 1 minute.
Inputs: time, limit, cursor. Returns: object
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 13 tools
Each tool targets a distinct resource or action (e.g., orders vs. positions vs. pies), and similar operations are differentiated by scope (list vs. single item) or state (pending vs. historical). No overlapping purposes exist.
All tools follow a consistent `verb_noun` pattern with snake_case: `get_*` for single items and `list_*` for collections. No mixed conventions or vague verbs.
13 tools cover the major facets of a trading account (overview, orders, positions, pies, dividends, exchanges, exports, instruments, transactions) without being excessive. Each tool earns its place.
The server is entirely read-only; it lacks tools for creating, modifying, or canceling orders, managing pies (create/update), or initiating trading actions. For a trading platform, these are critical gaps that will limit agent functionality.
Maintenance
Related MCP Connectors
Trading MCP server for AI agents, with live market data, account reads and controlled execution.
MCP server for Financial Modeling Prep API with 250+ financial data tools
MCP server exposing the Backtest360 engine API as tools for AI agents.
Hosted MCP server for MT4 and MT5: read accounts, prices and candles, and place or close orders.
Related MCP Servers
- AlicenseAqualityCmaintenanceMCP server for the Trading 212 API. Provides 28 tools for portfolio management, trading, pies, dividends, market data, and analytics.28125 PyPI10MIT
- AlicenseAqualityDmaintenanceMCP server for the tastytrade brokerage API, providing tools for account management, market data, and order execution.18MIT
- AlicenseAqualityDmaintenanceAn MCP server that wraps the Trading 212 Public API, enabling AI agents to interact with your Trading 212 brokerage account through natural language.16MIT
- 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