trading212-mcp-server
Trading 212 MCP Server
Connect your AI assistant to your Trading 212 brokerage account. Ask questions about your portfolio, place trades, manage pies, and analyze dividends - all through natural language.
Works with Claude Desktop, Claude Code, ChatGPT, Gemini, Cursor, Windsurf, and any client that supports the Model Context Protocol (MCP).
Why this server?
32 tools covering the full Trading 212 API, plus 4 analytics tools that combine multiple API calls into actionable insights
Smart rate limiting - reads T212's rate limit headers, auto-waits, and retries on 429 (up to 3 times). No rate limit errors leak to your AI
Zero config - install from PyPI, add your API key, done. No Docker, no database, no Redis
Typed responses - every tool returns structured Pydantic models, not raw JSON
Paper trading - set
ENVIRONMENT=demoto test with virtual money first
Related MCP server: trading-mcp
What can it do?
Category | Tools | Examples |
Analytics | Portfolio summary, performance, dividends, activity | "Show me my portfolio P&L" |
Trading | Market, limit, stop, stop-limit orders | "Buy 5 shares of AAPL" |
Portfolio | Positions, cash balance, account info | "What's my cash balance?" |
Pies | Create, update, duplicate, delete pies | "Show my pie allocations" |
Market Data | Instrument search, exchange schedules | "Search for Tesla" |
History | Past orders, dividends, transactions, CSV exports | "Show my dividend history" |
Analytics tools
These combine multiple API calls into single high-level responses:
fetch_portfolio_summary- Complete snapshot: total value, P&L, cash, top holdings, allocationfetch_portfolio_performance- Per-position returns with dividends, best/worst performersfetch_dividend_summary- Income analysis grouped by ticker and monthfetch_recent_activity- Combined timeline of trades and transactions
Quick start
Install
uvx trading212-mcp-serverOr via pip:
pip install trading212-mcp-serverGet your API credentials
From the Trading 212 app: Settings > API (Beta). You need both the API Key and Secret - the server uses Basic Auth.
Connect to Claude Desktop
Add to claude_desktop_config.json (Windows: %APPDATA%\Claude\, Mac: ~/Library/Application Support/Claude/):
{
"mcpServers": {
"trading212": {
"command": "uvx",
"args": ["trading212-mcp-server"],
"env": {
"TRADING212_API_KEY": "<your-api-key>",
"TRADING212_API_SECRET": "<your-api-secret>",
"ENVIRONMENT": "live"
}
}
}
}Connect to Claude Code
claude mcp add trading212 -- uvx trading212-mcp-serverThen set the environment variables in your shell or .env file.
Other clients (Cursor, Windsurf, ChatGPT, etc.)
Same command and env vars - configure per your client's MCP docs. Set ENVIRONMENT to demo for paper trading.
From source
git clone https://github.com/KyuRish/trading212-mcp-server.git
cd trading212-mcp-server
cp .env.example .env # fill in your API keys
uv sync
uv run -m trading212_mcp_server.server{
"mcpServers": {
"trading212": {
"command": "uv",
"args": ["run", "--directory", "<path-to-repo>", "-m", "trading212_mcp_server.server"],
"env": {
"TRADING212_API_KEY": "<your-api-key>",
"TRADING212_API_SECRET": "<your-api-secret>",
"ENVIRONMENT": "live"
}
}
}
}All 32 tools
Analytics (composite)
Tool | Description |
| Complete portfolio snapshot with P&L and allocations |
| Per-position returns, dividends, best/worst performers |
| Dividend income by ticker and month |
| Combined timeline of trades and transactions |
Account
Tool | Description |
| Account metadata (currency, ID) |
| Cash balance, invested value, P&L |
| All portfolio positions with live prices |
| Single position lookup by ticker |
Trading
Tool | Description |
| Buy/sell at current market price |
| Buy/sell at specified price or better |
| Trigger order at stop price |
| Stop trigger with limit execution |
| List all pending orders |
| Get specific order by ID |
| Cancel a pending order |
Pies
Tool | Description |
| List all investment pies |
| Pie details with instrument allocations |
| Create a new pie with target weights |
| Update pie settings and allocations |
| Clone an existing pie |
| Remove a pie |
Market Data
Tool | Description |
| Search tradeable instruments by ticker or name |
| Search available exchanges |
History
Tool | Description |
| Past orders with pagination |
| Dividend payment history |
| Deposits and withdrawals |
| List CSV export reports |
| Request a new CSV export |
Compatibility
Tested with these MCP clients:
Client | Status |
Claude Desktop | Supported |
Claude Code | Supported |
Cursor | Supported |
Windsurf | Supported |
Any MCP-compatible client | Supported |
Author
Built by Rishabh Dogra.
Support
If this server saves you time, a coffee would mean a lot.
License
MIT
Available Tools
28 toolscancel_orderADestructiveIdempotent
Cancel a pending order and remove it from the order book. This is irreversible -
once cancelled, the order cannot be reinstated and must be placed again.
Use fetch_all_orders or fetch_order first to confirm the order is still
active before attempting to cancel.
Args:
order_id: Numeric ID of the pending order to cancel (e.g., 12345678).
Get this from fetch_all_orders or from the response when the order was placed.
Inputs: order_id (required). Returns: result
create_pieA
Create a new investment pie with the given instruments and target weights.
This creates a real pie in your account - instruments will be purchased
when you fund the pie.
Use search_instrument to find valid ticker symbols before creating. Weights
must sum to 1.0 (100%). See also: duplicate_pie to clone an existing pie.
Args:
name: Display name for the pie (e.g., 'Tech Growth')
instrument_shares: Mapping of ticker to target weight, must sum to 1.0.
Example: {'AAPL_US_EQ': 0.5, 'MSFT_US_EQ': 0.3, 'NVDA_US_EQ': 0.2}
dividend_cash_action: REINVEST (buy more shares) or TO_ACCOUNT_CASH (withdraw to cash).
Defaults to REINVEST if not specified.
end_date: Optional target date in ISO 8601 (e.g., '2029-12-31T23:59:59Z')
goal: Optional target value in account currency (e.g., 20000.0)
icon: Optional pie icon identifier (e.g., 'Coins', 'Education')
Returns:
PieDetails: Full details of the newly created pie
Inputs: name (required), instrument_shares (required), dividend_cash_action, end_date, +2 more. Returns: settings, instruments
delete_pieADestructiveIdempotent
Permanently delete a pie. This is irreversible. Instruments inside the pie
become standalone positions in your portfolio - they are not sold.
Use fetch_a_pie first to review the pie contents before deleting. Consider
whether you want to sell the positions separately after deletion.
Args:
pie_id: Numeric ID of the pie to delete (e.g., 6894572). Get this from fetch_pies.
Inputs: pie_id (required).
duplicate_pieA
Clone an existing pie into a new one with identical instrument allocations
and settings. The new pie starts with zero invested value.
Use this to create a variation of an existing pie without rebuilding it
from scratch. See also: create_pie for building a pie from scratch.
Args:
pie_id: ID of the source pie to copy (e.g., 6894572). Get this from fetch_pies.
name: Optional custom name for the clone. Defaults to the original name with a suffix.
icon: Optional icon for the clone.
Returns:
PieDetails: Full details of the newly cloned pie
Inputs: pie_id (required), name, icon. Returns: settings, instruments
fetch_account_cashARead-onlyIdempotent
Get a detailed breakdown of the account balance including available cash,
invested capital, profit/loss, blocked funds, and pie cash.
Use this to check buying power before placing orders, or to understand
the overall account health. See also: fetch_portfolio_summary for a
richer overview that includes individual positions.
Returns:
Cash with free, invested, total, ppl (profit/loss), result, blocked, pieCash
Inputs: no named parameters. Returns: free, invested, total, ppl, +3 more
fetch_account_infoARead-onlyIdempotent
Retrieve account metadata such as the account currency and unique identifier.
Use this as a starting point to determine the account's base currency before
interpreting monetary values from other tools. Safe to call frequently.
Returns:
Account with id (int) and currencyCode (e.g., 'EUR', 'GBP', 'USD')
Inputs: no named parameters. Returns: id, currencyCode
fetch_all_open_positionsARead-onlyIdempotent
Retrieve every open position in the portfolio with live prices, quantities,
cost basis, and unrealised gains.
Use this to get a complete view of current holdings. Each position includes
the ticker, quantity, averagePrice, currentPrice, and ppl (profit/loss).
Positions held inside pies show a non-zero pieQuantity field.
See also: search_specific_position_by_ticker for a single position lookup,
or fetch_portfolio_summary for an aggregated portfolio view.
Returns:
List of Position objects, one per held instrument
Inputs: no named parameters. Returns: result
fetch_all_ordersARead-onlyIdempotent
List all active pending orders (limit, stop, stop-limit) waiting to be filled.
Use this to review open orders before placing new ones or to check if a
previously placed order is still active. Does not include filled or
cancelled orders - use fetch_historical_order_data for those.
Returns:
List of Order objects with id, ticker, type, status, quantity, limitPrice, stopPrice
Inputs: no named parameters. Returns: result
fetch_a_pieARead-onlyIdempotent
Get full details for a single pie including every instrument allocation,
current vs target weights, per-instrument P/L, and pie settings.
Use fetch_pies first to get the list of pie IDs, then call this for
detailed breakdown of a specific pie.
Args:
pie_id: Numeric ID of the pie (e.g., 6894572). Get this from fetch_pies.
Returns:
PieDetails with settings (name, goal, endDate, dividendCashAction) and
instruments (ticker, expectedShare, currentShare, ownedQuantity, result)
Inputs: pie_id (required). Returns: settings, instruments
fetch_dividend_summaryARead-onlyIdempotent
Analyse dividend income history by collecting up to 200 dividend records
and breaking them down by ticker and by calendar month.
Use this to identify which holdings generate the most income and to spot
monthly income trends. For raw dividend records with pagination control,
use fetch_paid_out_dividends instead.
Returns:
dict with currency, total_dividends, dividend_count, average_monthly,
by_ticker (sorted highest-paying first), by_month (chronological)
Inputs: no named parameters.
fetch_exports_listARead-onlyIdempotent
List all previously generated CSV account exports with their status and
download links.
Use this to check if an export requested via request_csv_export is ready
for download. Completed reports include a downloadLink field.
Returns:
List of Report objects with reportId, status, and downloadLink (when complete)
Inputs: no named parameters. Returns: result
fetch_historical_order_dataARead-onlyIdempotent
Retrieve past orders (filled, cancelled, rejected) with execution details,
fill prices, and timestamps. Supports pagination and ticker filtering.
Use this to review trade history or to analyze past execution quality.
For currently active orders, use fetch_all_orders instead.
Args:
cursor: Pagination cursor from a previous response. Omit for the first page.
ticker: Filter results to a specific instrument (e.g., 'AAPL_US_EQ'). Omit for all.
limit: Number of orders per page, 1-50. Defaults to 20.
Returns:
List of HistoricalOrder with ticker, type, status, filledQuantity, fillPrice,
dateCreated, dateExecuted, and more
Inputs: cursor, ticker, limit. Returns: result
fetch_orderARead-onlyIdempotent
Retrieve a single pending order by its ID to check its current status,
fill progress, and price parameters.
Use this after placing an order to monitor its status, or before cancelling
to confirm the order is still active. See also: fetch_all_orders to list
all pending orders at once.
Args:
order_id: Numeric order ID returned when the order was placed (e.g., 12345678)
Returns:
Order with id, ticker, type, status, quantity, filledQuantity, limitPrice, stopPrice
Inputs: order_id (required). Returns: id, ticker, type, status, +8 more
fetch_paid_out_dividendsARead-onlyIdempotent
Retrieve dividend payments received, including per-share amounts, payment dates,
and total payouts. Supports pagination and ticker filtering.
Use this to track income from dividend-paying stocks. For a summarized view
grouped by ticker and month, use fetch_dividend_summary instead.
Args:
cursor: Pagination cursor from a previous response. Omit for the first page.
ticker: Filter to a specific instrument (e.g., 'AAPL_US_EQ'). Omit for all.
limit: Number of records per page, 1-50. Defaults to 20.
Returns:
PaginatedDividends with items (ticker, amount, paidOn, quantity) and nextPagePath
Inputs: cursor, ticker, limit. Returns: items, nextPagePath
fetch_piesARead-onlyIdempotent
List all investment pies with their cash balances, dividend details,
goal progress, and overall investment performance.
Use this to get an overview of all pies before drilling into a specific one
with fetch_a_pie. Each pie includes its numeric ID needed for other pie operations.
Returns:
List of PieSummary objects with id, status, cash, progress, result, dividendDetails
Inputs: no named parameters. Returns: result
fetch_portfolio_performanceARead-onlyIdempotent
Build a detailed performance report across all positions by combining
current holdings, recent order history, and dividend payouts.
Calculates per-position total returns (price P/L + dividends) and identifies
best and worst performers. Use this for deeper analysis than fetch_portfolio_summary
provides, especially when dividend income matters.
Returns:
dict with currency, total_price_ppl, total_dividends, total_return,
best_performer, worst_performer, positions (each with invested, current_value,
price_ppl, dividends, total_return, return_pct, held_since), recent_filled_orders
Inputs: no named parameters.
fetch_portfolio_summaryARead-onlyIdempotent
Produce a complete portfolio snapshot in one call by combining account info,
cash balance, and all open positions into a single aggregated response.
This is the recommended starting point for portfolio analysis. It calculates
total value, P/L percentages, and ranks holdings by current value. For
per-position performance with dividends, use fetch_portfolio_performance instead.
Returns:
dict with currency, total_value, cash_available, invested, profit_loss,
profit_loss_pct, position_count, positions (sorted by value descending),
and top_holdings (top 5)
Inputs: no named parameters.
fetch_recent_activityARead-onlyIdempotent
Get a unified timeline of recent trades and account movements by merging
order history with deposit/withdrawal transactions into a single
chronologically sorted feed.
Use this for a quick "what happened recently" overview. Each entry is tagged
as either 'order' (trade) or 'transaction' (cash movement). For separate
access, use fetch_historical_order_data or fetch_transaction_list.
Args:
limit: How many items to pull from each source (orders and transactions
separately), 1-50. Defaults to 20. Total activity items may be up to 2x this.
Returns:
dict with currency, activity (sorted newest-first, each tagged as 'order' or
'transaction'), order_count, transaction_count
Inputs: limit.
fetch_transaction_listARead-onlyIdempotent
Retrieve account cash movements such as deposits, withdrawals, fees,
interest payments, and internal transfers. Supports cursor-based pagination.
Use this to audit account cash flow or to reconcile deposits/withdrawals.
For a combined view of orders and transactions together, use fetch_recent_activity.
Args:
cursor: Pagination cursor from a previous response. Omit for the first page.
time: Filter transactions from this ISO 8601 timestamp onward
(e.g., '2024-06-01T00:00:00Z'). Omit for all.
limit: Number of records per page, 1-50. Defaults to 20.
Returns:
PaginatedTransactions with items (type, dateTime, amount, reference) and nextPagePath
Inputs: cursor, time, limit. Returns: items, nextPagePath
place_limit_orderA
Submit a limit order that executes only when the instrument reaches your
target price. The order stays open until filled, cancelled, or expired.
Use this instead of a market order when you want to control the execution
price. Check fetch_all_orders afterward to monitor fill status.
Args:
ticker: Instrument ticker (e.g., 'AAPL_US_EQ'). Use search_instrument to find valid tickers.
quantity: Number of shares. Positive to buy, negative to sell.
limit_price: Maximum price to pay (buy) or minimum to accept (sell).
For example, 150.00 means "buy at 150 or lower".
time_validity: How long the order stays active. DAY (expires end of trading day)
or GOOD_TILL_CANCEL (stays open until filled or manually cancelled). Defaults to DAY.
Returns:
Order: The newly created limit order with its pending status
Inputs: ticker (required), quantity (required), limit_price (required), time_validity. Returns: id, ticker, type, status, +8 more
place_market_orderA
Execute a market order at the current price. This creates a real trade that
affects your portfolio immediately. The order fills at the best available
market price.
Use search_instrument first to find the correct ticker symbol. Check
fetch_account_cash to verify sufficient buying power before placing.
Args:
ticker: Instrument ticker to trade (e.g., 'AAPL_US_EQ', 'MSFT_US_EQ').
Use search_instrument to find valid tickers.
quantity: Number of shares. Positive to buy, negative to sell.
Fractional shares are supported (e.g., 0.5).
Returns:
Order: The newly created order with its initial status
Inputs: ticker (required), quantity (required). Returns: id, ticker, type, status, +8 more
place_stop_limit_orderA
Submit a combined stop-limit order: once the stop price is hit, a limit order
is placed at your specified limit price instead of executing at market.
This gives more control than a plain stop order by preventing execution at
an unfavourable price during fast market moves, but the order may not fill
if the price moves through the limit. See also: place_stop_order for a
simpler stop that guarantees execution.
Args:
ticker: Instrument ticker (e.g., 'AAPL_US_EQ'). Use search_instrument to find valid tickers.
quantity: Number of shares. Positive to buy, negative to sell.
stop_price: Trigger price that activates the limit order (e.g., 140.00).
limit_price: Price at which the resulting limit order is placed (e.g., 139.50).
Typically set slightly below the stop price for sells.
time_validity: DAY or GOOD_TILL_CANCEL. Defaults to DAY.
Returns:
Order: The newly created stop-limit order
Inputs: ticker (required), quantity (required), stop_price (required), limit_price (required), +1 more. Returns: id, ticker, type, status, +8 more
place_stop_orderA
Submit a stop order that triggers a market execution once the instrument
reaches the specified stop price. Commonly used as a stop-loss to limit
downside risk on an existing position.
When the stop price is hit, the order becomes a market order and fills at
the best available price (which may differ from the stop price in fast markets).
For more control over the fill price, use place_stop_limit_order instead.
Args:
ticker: Instrument ticker (e.g., 'AAPL_US_EQ'). Use search_instrument to find valid tickers.
quantity: Number of shares. Positive to buy, negative to sell.
stop_price: Trigger price that activates the order (e.g., 140.00).
time_validity: DAY or GOOD_TILL_CANCEL. Defaults to DAY.
Returns:
Order: The newly created stop order
Inputs: ticker (required), quantity (required), stop_price (required), time_validity. Returns: id, ticker, type, status, +8 more
request_csv_exportA
Queue a CSV export of your account history. The export runs asynchronously -
check fetch_exports_list to monitor progress and get the download link.
This creates a server-side export job. Each call generates a new report.
Use the time range parameters to limit the export to a specific period.
Args:
include_dividends: Include dividend payment records. Defaults to True.
include_interest: Include interest payment records. Defaults to True.
include_orders: Include trade/order history. Defaults to True.
include_transactions: Include deposit/withdrawal records. Defaults to True.
time_from: Start of the reporting window in ISO 8601 (e.g., '2024-01-01T00:00:00Z').
Omit for all history.
time_to: End of the reporting window in ISO 8601 (e.g., '2024-12-31T23:59:59Z').
Omit for up to now.
Returns:
EnqueuedReport with the reportId for tracking via fetch_exports_list
Inputs: include_dividends, include_interest, include_orders, include_transactions, +2 more. Returns: reportId
search_exchangeARead-onlyIdempotent
Search for stock exchanges by name or numeric ID. Returns exchange details
including trading hours and working schedules.
Use this to check when a specific exchange is open for trading, or to
look up exchange information by its numeric ID from an instrument's
workingScheduleId field.
Args:
search_term: Case-insensitive text to match against exchange names
(e.g., 'NASDAQ', 'London'), or an exact numeric exchange ID
(e.g., '71'). Omit to return all exchanges.
Returns:
List of Exchange objects with id, name, and workingSchedules
Inputs: search_term. Returns: result
search_instrumentARead-onlyIdempotent
Search for tradeable instruments by ticker symbol or company name.
Returns matching instruments with their ticker, ISIN, currency, and type.
Use this before placing orders or creating pies to find the correct Trading 212
ticker format (e.g., 'AAPL_US_EQ' for Apple). Omit the search term to retrieve
the full instrument catalogue.
The search is case-insensitive and matches partial strings against both
ticker symbols and instrument names.
Args:
search_term: Text to match against tickers and names (e.g., 'Apple', 'AAPL',
'silver ETC'). Omit to return every available instrument.
Returns:
List of Instrument objects with ticker, name, type (STOCK/ETF), currencyCode,
isin, shortName, and maxOpenQuantity
Inputs: search_term. Returns: result
search_specific_position_by_tickerARead-onlyIdempotent
Look up a single open position by its exact ticker symbol.
Use this when you need details on one specific holding without fetching the
entire portfolio. Returns the same Position data as fetch_all_open_positions
but for a single instrument.
Args:
ticker: The exact Trading 212 ticker symbol (e.g., 'AAPL_US_EQ', 'IGLDd_EQ').
Use search_instrument to find the correct ticker if unsure.
Returns:
Position with ticker, quantity, averagePrice, currentPrice, ppl, and more
Inputs: ticker (required). Returns: ticker, quantity, averagePrice, currentPrice, +7 more
update_pieA
Modify an existing pie's settings, instrument allocations, or target weights.
Only provided fields are updated - omitted fields remain unchanged.
Use fetch_a_pie first to see the current configuration before making changes.
The API requires providing a name even if you are not changing it.
Args:
pie_id: Numeric ID of the pie to modify (e.g., 6894572). Get this from fetch_pies.
name: Updated name for the pie. Required by the API even if unchanged.
instrument_shares: New ticker-to-weight mapping, must sum to 1.0.
Example: {'AAPL_US_EQ': 0.5, 'MSFT_US_EQ': 0.5}
dividend_cash_action: REINVEST or TO_ACCOUNT_CASH
end_date: Revised end date in ISO 8601 (e.g., '2029-12-31T23:59:59Z')
goal: Revised target value in account currency (e.g., 25000.0)
icon: Updated icon identifier
Returns:
PieDetails: The pie after applying your changes
Inputs: pie_id (required), name, instrument_shares, dividend_cash_action, +3 more. Returns: settings, instruments
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 28 tools
Most tools target a distinct resource and action (orders vs pies vs positions vs dividends), and cross-references clarify when to use aggregate vs granular tools. A few composite tools like fetch_portfolio_summary and fetch_recent_activity overlap with underlying fetch_* endpoints, but the descriptions explicitly disambiguate them.
The set is largely consistent: fetch_* for reads, place_* for order creation, create/update/delete for pies, and search_* for lookups. Minor deviations like search_specific_position_by_ticker instead of fetch_position_by_ticker, and request_csv_export instead of create/fetch_csv_export, prevent a perfect score.
At 28 tools, this exceeds the 25+ heavy threshold. Several composite tools such as fetch_portfolio_summary, fetch_portfolio_performance, fetch_recent_activity, and fetch_dividend_summary duplicate data available from more granular endpoints, inflating the surface beyond what is strictly necessary.
The tool surface covers the core account lifecycle well: orders can be placed, listed, fetched, cancelled, and reviewed historically; pies have full CRUD; positions, dividends, transactions, and exports are all readable. Minor gaps exist, such as no standalone price/quote lookup and no order modification, but agents can work around these with search_instrument or cancel+recreate.
Maintenance
Related MCP Connectors
MCP server for Financial Modeling Prep API with 250+ financial data tools
Trading MCP server for AI agents, with live market data, account reads and controlled execution.
MCP server exposing the Backtest360 engine API as tools for AI agents.
Official Intrinio MCP server. US stock prices, options and fundamentals for AI agents.
Related MCP Servers
- AlicenseBqualityDmaintenanceProvides a comprehensive suite of 20 tools for cryptocurrency trading and technical analysis across 100+ exchanges like Binance and MEXC via CCXT. It enables users to execute orders, track positions, and scan for market opportunities through Claude Desktop using natural language.2037 npmMIT
- FlicenseNot gradedqualityDmaintenanceProvides foundational trading utilities by fetching market data through Akshare and computing technical indicators like RSI and MACD using TA-Lib. It enables users to retrieve candlestick data and technical analysis series via a standardized MCP interface.9-
- AlicenseAqualityBmaintenanceRenders 45+ interactive chart types, dashboards, and KPI widgets directly inside AI conversations. Supports drill-down, live API polling, 20 themes, and one-click export to PNG, PowerPoint, and A4 documents.40137 npm54Functional Source , Version 1.1, MIT Future

Purple Flea Tradingofficial
AlicenseNot gradedqualityDmaintenancePerpetual futures trading API for AI agents. Access 275+ markets (crypto, stocks, commodities, forex) via Hyperliquid. Copy trading, leaderboard, up to 50x leverage. No KYC. 20% referral commissions.56 npmMIT