Trading212 MCP Server
Use this MCP server to access Trading 212 account data, manage orders and pies, search instruments/exchanges, and retrieve account history and exports.
Fetch account summary, cash balance, and open positions, including position lookup by ticker.
List/fetch/cancel orders and place market, limit, stop, and stop-limit orders.
Create, update, duplicate, delete, and fetch pies.
Search tradeable instruments and exchanges.
Fetch historical order data, dividends, and transactions with pagination.
List and request CSV account exports.
Access MCP resources for account, positions, orders, pies, instruments, exchanges, and exports, plus an account-currency-aware analysis prompt.
It does not provide independent market feeds, investment recommendations, or real-time streaming.
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 Server show my portfolio"
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.
Trading 212 MCP Server
A Model Context Protocol server for the Trading 212 public API. It exposes account data, positions, orders, pies, instrument metadata, and account history. It also includes an account-currency-aware analysis prompt. It does not provide independent market feeds, investment recommendations, or real-time streaming.
Python 3.11–3.14 is supported. The current source package version is 0.2.0; see the changelog for upgrade details. The project uses the official MCP Python SDK 2.x.
Install and run
You can follow the setup below yourself or ask a coding agent such as Codex or Claude Code to do it. Paste this prompt into the agent's chat:
Read https://github.com/RohanAnandPandit/trading212-mcp-server/blob/main/README.md#setup
and follow the setup process.Setup
Install prerequisites and dependencies. You need Git, uv, and Python 3.11–3.14. Choose a stable installation folder, then run:
git clone https://github.com/RohanAnandPandit/trading212-mcp-server.git cd trading212-mcp-server uv sync --frozenIf you already have a checkout, reuse it without overwriting local changes. Alternatively, install the package from the checkout using
pip install ., then runtrading212-mcp-server. For a locked pip installation, usepip install --require-hashes -r requirements.txtfollowed bypip install --no-deps ..Configure credentials locally. Create an ignored
.envfile from.env.exampleif one does not already exist:cp .env.example .envGenerate credentials in your Trading 212 account's API settings, granting only the permissions you need. Edit
.envyourself to setTRADING212_API_KEYand, for Basic authentication,TRADING212_API_SECRET. API-key-only authentication remains available for existing integrations, where accepted by Trading 212; remove the example secret value if using it. Start withENVIRONMENT=demoandTRANSPORT=stdio. Use the live environment only when you explicitly choose to enable operations on your real account.Keep credentials out of chat, commands, logs, and MCP client configuration. If an agent is helping, enter the values yourself; the agent must wait for you and must not read, display, log, or repeat them.
The server reads
.envin its working directory at startup. Existing process environment variables take precedence.Connect your MCP client. Use your client's supported method to register a local stdio server named
trading212. Choose whether the connection should be available only in this workspace or across your projects before saving it. Clients that acceptmcpServersJSON can use:{ "mcpServers": { "trading212": { "command": "uv", "args": ["run", "--frozen", "--directory", "/absolute/path/to/trading212-mcp-server", "trading212-mcp-server"], "env": { "ENVIRONMENT": "demo", "TRANSPORT": "stdio" } } } }Replace the example path with your checkout's absolute path. Credentials stay in the checkout's
.envfile. To launch the server directly from the checkout, runuv run --frozen trading212-mcp-server.Verify the connection. Restart your MCP client if needed and check that it connects to the server and discovers its tools. Setup is complete only when discovery succeeds. Imports and tool discovery do not make Trading 212 requests, and no credentials are required merely to import the server. Do not call account or trading tools during setup. Record where the MCP configuration was saved and any steps that remain.
Existing configurations pointing to src/server.py continue to work after
uv sync --frozen. The script also remains the Inspector entry point:
uv run --frozen mcp dev src/server.pyInspector requires Node.js and npx. Tool calls in Inspector use the configured
account, including mutations when you invoke those tools.
Docker
docker build -t trading212-mcp-server .
docker run --rm -i --env-file .env trading212-mcp-serverFor a desktop client, pass both credential variables through Docker:
{
"mcpServers": {
"trading212": {
"command": "docker",
"args": ["run", "--rm", "-i", "-e", "TRADING212_API_KEY", "-e", "TRADING212_API_SECRET", "-e", "ENVIRONMENT", "trading212-mcp-server"],
"env": {
"TRADING212_API_KEY": "YOUR_API_KEY",
"TRADING212_API_SECRET": "YOUR_API_SECRET",
"ENVIRONMENT": "demo"
}
}
}
}The image runs as UID/GID 10001. Credentials, local caches, and development
files are excluded from the image. The default container cache is ephemeral;
mount a private directory writable by UID 10001 at /home/app/.cache if you
want persistence. Stdio does not require publishing a port.
Related MCP server: trading212-mcp-server
Configuration
Variable | Default | Meaning |
| Required | Account API key |
| Unset | Secret for Basic authentication |
|
|
|
|
|
|
|
| Cache root; relative to working directory |
|
| Account, positions, orders, pies, export-status cache seconds |
|
| History cache seconds |
|
| Instrument and exchange cache seconds |
A TTL of zero disables caching for that category. Values must be finite and
non-negative. HTTP transports bind only to 127.0.0.1:8000, with explicit
Host/Origin restrictions. This is a local single-account server; hosted access,
public HTTP binding, and multi-user authentication are not provided. Do not
expose it through a public proxy or tunnel. Tool annotations describe effects;
they do not implement permissions. Use API permissions and your MCP client's
approval controls to govern account mutations.
Tools
All previous tool names are retained:
Area | Tools |
Account |
|
Positions |
|
Orders |
|
Pies |
|
Metadata |
|
History |
|
Positive order quantities buy; negative quantities sell. Zero/non-finite
quantities, non-positive prices, and empty tickers are rejected. Pie updates may
include any documented field independently; name is optional. Export dates
must include a timezone and be ordered. Pies are deprecated upstream, but their
tools are retained.
fetch_account_info aliases fetch_account_summary. The older position tools
remain compatibility aliases. Historical tools return a single page with
nextPagePath; pass its cursor and other query parameters to fetch the next
page. Limits retain their existing clamp to 1–50. Requests do not automatically
traverse all pages or follow export download links.
Resources and prompt
Resources retain their existing URIs:
trading212://account/summary,trading212://account/cashtrading212://positions,trading212://positions/{ticker}trading212://orders,trading212://orders/{order_id}trading212://pies,trading212://pies/{pie_id}trading212://instruments,trading212://exchangestrading212://history/exports
Compatibility URIs: trading212://account/info,
trading212://account/portfolio, trading212://account/positions,
trading212://account/portfolio/{ticker}, and
trading212://account/positions/{ticker}.
The analyse_trading212_data prompt includes account currency when available
and explains GBX/GBP units. If account retrieval fails, it still returns the
base prompt and writes a generic diagnostic to stderr.
Cache and request guarantees
Private data remains cached. Credential/base-URL fingerprints isolate SQLite storage across accounts, secret rotations, environments, and API versions. Authorization and cookies never enter the cache layer. Cache responses contain financial data in plaintext; private filesystem permissions are not encryption. Use a private local disk, not a shared or network-mounted cache directory.
Successful responses are validated against their endpoint models before caching. Only successful GETs are cached, and expired responses are never served. Mutations are never cached or automatically retried. After any attempted mutation, private-cache generations advance, including when the outcome is uncertain. A cross-process file lock covers reads, writes, body consumption, and invalidation, preventing older in-flight reads from repopulating the current generation. Different credential namespaces remain independent; external trades or writes using another API key may remain invisible until the TTL expires.
MCP tool results and resource contents carry freshness details under
_meta["io.github.RohanAnandPandit.trading212/cache"]: an array of cacheHit,
retrievedAt (UTC), and ttlSeconds records. Existing data fields remain intact.
Transient GET failures may be retried twice within a 30-second retry budget,
respecting Retry-After and rate-reset headers. Individual HTTP operations have
explicit timeouts. Waiting for another process's cache lock is bounded separately
at 30 seconds. A failed mutation can have an unknown outcome: check the account
before deciding whether to issue it again.
Upgrading from 0.1.x
Stop older server processes, update the checkout, and run uv sync --frozen.
The new server never reads or migrates .cache/hishel or .cache/trading212-v2.
Those directories may contain private responses and Authorization headers.
After confirming the paths belong to this application, explicitly remove old
cache directories yourself. The upgrade does not delete user data. Rebuild
Docker images and replace any older images that may have included local files.
Development and security
See CONTRIBUTING.md for architecture and verification commands, SECURITY.md for private reporting, and the modernization validation report for checked behavior.
Keeping the Trading 212 schema in sync
Trading 212's live
OpenAPI description is the
authority. docs/api.json is the reviewable checked-in snapshot. Before making
API-facing changes or preparing a release, check it without account credentials:
uv run --with PyYAML python .agents/skills/trading212-api-sync/scripts/sync_api_schema.py --checkIf the command reports drift, refresh the snapshot:
uv run --with PyYAML python .agents/skills/trading212-api-sync/scripts/sync_api_schema.py --updateReview the resulting diff rather than treating regeneration as sufficient.
Update endpoints, parameters, request and response models, enums, deprecations,
tests, and documentation where relevant, then run the full verification suite.
The repository-local trading212-api-sync agent skill contains the complete
workflow. The schema check only downloads public documentation; it must never
make authenticated account requests or trading mutations.
This project is independently maintained and is not affiliated with or endorsed by Trading 212. Consult the provider's current documentation and terms. Licensed under MIT.
Available Tools
28 toolscancel_orderC
Cancel an existing order.
Inputs: order_id (required).
create_pieB
Create a new pie with the specified parameters.
Args:
name: Name of the pie
instrument_shares: Dictionary mapping instrument tickers to their
weights in the pie
(e.g., {'AAPL_US_EQ': 0.5, 'MSFT_US_EQ': 0.5})
dividend_cash_action: How dividends are handled. Defaults to REINVEST.
Possible values: REINVEST, TO_ACCOUNT_CASH
end_date: Optional end date for the pie in ISO 8601 format
(e.g., '2024-12-31T23:59:59Z')
goal: Total desired value of the pie in account currency
icon: Optional icon identifier for the pie
Returns:
AccountBucketInstrumentsDetailedResponse: Details of the created pie
Inputs: name (required), instrument_shares (required), dividend_cash_action, end_date, +2 more.
delete_pieC
Delete a pie.
Inputs: pie_id (required).
duplicate_pieA
Create a duplicate of an existing pie.
Args:
pie_id: ID of the pie to duplicate
name: Optional new name for the duplicated pie
icon: Optional new icon for the duplicated pie
Returns:
AccountBucketInstrumentsDetailedResponse: Details of the duplicated pie
Inputs: pie_id (required), name, icon.
fetch_account_cashA
Fetch account cash balance.
Inputs: no named parameters.
fetch_account_infoC
Fetch the account summary.
Inputs: no named parameters.
fetch_account_summaryB
Fetch the account summary.
Inputs: no named parameters.
fetch_all_open_positionsA
Deprecated alias for fetch_positions().
Inputs: no named parameters.
fetch_all_ordersB
Fetch all equity orders.
Inputs: no named parameters.
fetch_a_pieB
Fetch a specific pie by ID.
Inputs: pie_id (required).
fetch_exports_listA
Lists detailed information about all csv account exports.
Inputs: no named parameters.
fetch_historical_order_dataC
Fetch historical order data with pagination.
Inputs: cursor, ticker, limit.
fetch_open_position_by_tickerB
Deprecated alias for fetch_position_by_ticker().
Inputs: ticker (required).
fetch_orderC
Fetch a specific order by ID.
Inputs: order_id (required).
fetch_paid_out_dividendsC
Fetch historical dividend data with pagination.
Inputs: cursor, ticker, limit.
fetch_piesA
Fetch all pies.
Inputs: no named parameters.
fetch_position_by_tickerC
Fetch a single open position by ticker.
Inputs: ticker (required).
fetch_positionsA
Fetch open positions, optionally filtered by ticker.
Inputs: ticker.
fetch_transaction_listC
Fetch superficial information about movements to and from your account.
Inputs: cursor, time, limit.
place_limit_orderA
Place a limit order to buy or sell an instrument at a specified price or better.
Args:
ticker: Ticker symbol of the instrument to trade (e.g., 'AAPL_US_EQ')
quantity: Number of shares/units to trade
limit_price: Limit price for the order
time_validity: Time validity of the order. Defaults to DAY.
Possible values: DAY, GOOD_TILL_CANCEL
Returns:
Order: Details of the placed order
Inputs: ticker (required), quantity (required), limit_price (required), time_validity.
place_market_orderB
Place a market order to buy or sell an instrument at the current market price.
Args:
ticker: Ticker symbol of the instrument to trade (e.g., 'AAPL_US_EQ')
quantity: Number of shares/units to trade
extended_hours: Whether the order can execute outside regular trading
hours when the instrument supports it
Returns:
Order: Details of the placed order
Inputs: ticker (required), quantity (required), extended_hours.
place_stop_limit_orderA
Place a stop-limit order to buy or sell an instrument when the market
price reaches a specified stop price, then execute at a specified limit
price or better.
Args:
ticker: Ticker symbol of the instrument to trade (e.g., 'AAPL_US_EQ')
quantity: Number of shares/units to trade
stop_price: Stop price that triggers the limit order
limit_price: Limit price for the order
time_validity: Time validity of the order. Defaults to DAY.
Possible values: DAY, GOOD_TILL_CANCEL
Returns:
Order: Details of the placed order
Inputs: ticker (required), quantity (required), stop_price (required), limit_price (required), +1 more.
place_stop_orderA
Place a stop order to buy or sell an instrument when the market price
reaches a specified stop price.
Args:
ticker: Ticker symbol of the instrument to trade (e.g., 'AAPL_US_EQ')
quantity: Number of shares/units to trade
stop_price: Stop price that triggers the order
time_validity: Time validity of the order. Defaults to DAY.
Possible values: DAY, GOOD_TILL_CANCEL
Returns:
Order: Details of the placed order
Inputs: ticker (required), quantity (required), stop_price (required), time_validity.
request_csv_exportA
Request a CSV export of the account's orders, dividends and transactions
history.
Once the export is complete it can be accessed from the download link in the
exports list.
Args:
include_dividends: Whether to include dividend information in the export.
Defaults to True
include_interest: Whether to include interest information in the export.
Defaults to True
include_orders: Whether to include order history in the export.
Defaults to True
include_transactions: Whether to include transaction history in the export.
Defaults to True
time_from: Start time for the report in ISO 8601 format
(e.g., '2023-01-01T00:00:00Z')
time_to: End time for the report in ISO 8601 format
(e.g., '2023-12-31T23:59:59Z')
Returns:
EnqueuedReportResponse: Response containing the report ID and status
Inputs: include_dividends, include_interest, include_orders, include_transactions, +2 more.
search_exchangeA
Fetch exchanges, optionally filtered by name or ID.
Args:
search_term: Optional search term to filter exchanges by name or ID
(case-insensitive)
Returns:
List of matching Exchange objects, or all exchanges if no search term
is provided
Inputs: search_term.
search_instrumentA
Fetch instruments, optionally filtered by ticker or name.
Args:
search_term: Search term to filter instruments by ticker or name
(case-insensitive)
Returns:
List of matching TradeableInstrument objects, or all instruments if no
search term is provided
Inputs: search_term.
search_specific_position_by_tickerB
Deprecated alias for fetch_position_by_ticker().
Inputs: ticker (required).
update_pieA
Update an existing pie with new parameters. The pie must be renamed when
updating it.
Args:
pie_id: ID of the pie to update
name: New name for the pie. Required when updating a pie.
instrument_shares: Dictionary mapping instrument tickers to their new
weights in the pie
(e.g., {'AAPL_US_EQ': 0.5, 'MSFT_US_EQ': 0.5})
dividend_cash_action: How dividends should be handled.
Possible values: REINVEST, TO_ACCOUNT_CASH
end_date: New end date for the pie in ISO 8601 format
(e.g., '2024-12-31T23:59:59Z')
goal: New total desired value of the pie in account currency
icon: New icon identifier for the pie
Returns:
AccountBucketInstrumentsDetailedResponse: Updated details of the pie
Inputs: pie_id (required), name, instrument_shares, dividend_cash_action, +3 more.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 28 tools
Multiple deprecated aliases (e.g., fetch_all_open_positions, fetch_open_position_by_ticker, search_specific_position_by_ticker) overlap with main tools. fetch_account_info and fetch_account_summary have identical descriptions, causing direct ambiguity.
Most tools follow a verb_noun pattern (fetch_, place_, create_, etc.), but deprecated aliases like search_specific_position_by_ticker break consistency, and fetch_account_info vs fetch_account_summary are inconsistently named.
28 tools is slightly above typical range but still reasonable for a trading platform covering account, orders, positions, pies, and searches. No tool feels superfluous, though deprecated aliases add clutter.
CRUD-like coverage for orders and pies, plus account info, positions, dividends, exports, and searches. Minor gaps like lack of order modification or position closing tools, but core workflows are covered.
Maintenance
Related MCP Connectors
Trading MCP server for AI agents, with live market data, account reads and controlled execution.
Hosted MCP server for MT4 and MT5: read accounts, prices and candles, and place or close orders.
Connect any MCP client to MetaTrader 4/5 to read prices, manage positions, and place trades.
MCP server for Financial Modeling Prep API with 250+ financial data tools
Related MCP Servers
- -licenseNot gradedqualityNot gradedmaintenanceAn MCP server that exposes the XTB trading API, allowing users to interact with their XTB trading accounts through the Model Context Protocol to perform operations like account management, market data retrieval, and trade execution.7 npm1-
- AlicenseAqualityCmaintenanceMCP server for the Trading 212 API. Provides 28 tools for portfolio management, trading, pies, dividends, market data, and analytics.28125 PyPI10MIT
- 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
- AlicenseAqualityCmaintenanceMCP server for the Trading 212 public API, enabling account, portfolio, order, pie, and history access with read tools always available and trading tools opt-in.131MIT