Click on "Install 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., "@Trading 212 MCP ServerShow my open positions and total portfolio performance"
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 comprehensive Model Context Protocol (MCP) server for seamless integration with the Trading 212 API. This server enables AI assistants like Claude to interact with your Trading 212 investment account, providing full access to account management, portfolio tracking, order execution, and historical data analysis.
Features
π¦ Account Management
Get account information (currency, ID)
View cash balances (free, invested, blocked, total)
Retrieve comprehensive account summaries
π Portfolio Management
List all open positions
Get detailed position information by ticker
Real-time profit/loss tracking
π Order Management
View all active orders
Place market, limit, stop, and stop-limit orders
Cancel pending orders
Support for DAY and GTC (Good Till Cancelled) orders
Extended hours trading support
π Market Data & Instruments
Search and filter thousands of tradeable instruments
Access instrument metadata (ISIN, currency, type, trading schedules)
View exchange information and trading hours
π₯§ Investment Pies
List all investment pies (portfolio buckets)
Create new pies with custom allocations
Update and delete existing pies
Configure dividend reinvestment settings
π Historical Data
Access order history with pagination
Retrieve dividend payment records
View complete transaction history
Export data to CSV for specified time periods
β‘ Performance Features
Automatic rate limit tracking and headers
Zod schema validation for type safety
Comprehensive error handling
Support for both demo and live environments
Installation
Prerequisites
Node.js 18+ installed
Trading 212 account (Invest or ISA)
Trading 212 API key (see Setup Guide)
Install Dependencies
Build the Project
Configuration
Getting Your API Key
Open the Trading 212 app (mobile or web)
Navigate to Settings β API (Beta)
Click Generate API Key
Configure permissions:
β Account data (read) - View account information
β History (read) - Access historical data
β Orders (read/write) - View and place orders
β Portfolio (read) - View positions
(Optional) Set IP address whitelist for additional security
Copy your API key and store it securely
β οΈ Security Warning: Never commit your API key to version control or share it publicly.
Environment Variables
Create a .env file in the project root:
Environments:
demo- Paper trading environment (recommended for testing)live- Real money trading environment
Usage with Claude Desktop
Configure Claude Desktop
Add this server to your Claude Desktop configuration file:
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
Windows: %APPDATA%/Claude/claude_desktop_config.json
Restart Claude Desktop
After updating the configuration, restart Claude Desktop to load the MCP server.
Available Tools
Account Management
get_account_info
Retrieve account metadata including currency code and account ID.
Example:
get_account_cash
Get detailed cash balance information.
Returns: Free cash, total, invested, blocked amounts, and more.
Example:
get_account_summary
Get comprehensive account summary with all balances and P&L.
Example:
Portfolio Management
get_portfolio
List all open positions with current values and profit/loss.
Example:
get_position
Get detailed information about a specific position.
Parameters:
ticker(string, required) - The ticker symbol (e.g., "AAPL", "TSLA")
Example:
Order Management
get_orders
Retrieve all active orders.
Example:
get_order
Get detailed information about a specific order.
Parameters:
orderId(number, required) - The order ID
Example:
cancel_order
Cancel an active order.
Parameters:
orderId(number, required) - The order ID to cancel
Example:
place_market_order
Place a market order to execute immediately at the current market price.
Parameters:
ticker(string, required) - Ticker symbolquantity(number, required) - Quantity to buy (positive) or sell (negative)timeValidity(string, optional) - "DAY" or "GTC" (default: "DAY")
Example:
place_limit_order
Place a limit order to execute at a specified price or better.
Parameters:
ticker(string, required) - Ticker symbolquantity(number, required) - Quantity to buy/selllimitPrice(number, required) - Maximum buy price or minimum sell pricetimeValidity(string, optional) - "DAY" or "GTC"
Example:
place_stop_order
Place a stop order that becomes a market order when triggered.
Parameters:
ticker(string, required) - Ticker symbolquantity(number, required) - Quantity to buy/sellstopPrice(number, required) - Price that triggers the ordertimeValidity(string, optional) - "DAY" or "GTC"
Example:
place_stop_limit_order
Place a stop-limit order that becomes a limit order when triggered.
Parameters:
ticker(string, required) - Ticker symbolquantity(number, required) - Quantity to buy/sellstopPrice(number, required) - Price that triggers the orderlimitPrice(number, required) - Limit price once triggeredtimeValidity(string, optional) - "DAY" or "GTC"
Example:
Instruments & Market Data
get_instruments
List all tradeable instruments with optional search filtering.
Parameters:
search(string, optional) - Filter by ticker, name, or ISIN
Example:
get_exchanges
Get information about exchanges and trading schedules.
Example:
Investment Pies
get_pies
List all investment pies with their configurations.
Example:
get_pie
Get detailed information about a specific pie.
Parameters:
pieId(number, required) - The pie ID
Example:
create_pie
Create a new investment pie.
Parameters:
name(string, required) - Pie name (1-50 characters)icon(string, required) - Icon identifierinstrumentShares(object, required) - Ticker to allocation mappingdividendCashAction(string, required) - "REINVEST" or "TO_ACCOUNT_CASH"goal(number, optional) - Investment goal amount
Example:
update_pie
Update an existing pie configuration.
Parameters:
pieId(number, required) - The pie IDOther parameters same as create_pie (all optional)
Example:
delete_pie
Delete an investment pie.
Parameters:
pieId(number, required) - The pie ID to delete
Example:
Historical Data
get_order_history
Get historical orders with pagination support.
Parameters:
cursor(number, optional) - Pagination cursorlimit(number, optional) - Results per page (default: 50)ticker(string, optional) - Filter by ticker
Example:
get_dividends
Get dividend payment history.
Parameters:
cursor(number, optional) - Pagination cursorlimit(number, optional) - Results per pageticker(string, optional) - Filter by ticker
Example:
get_transactions
Get complete transaction history.
Parameters:
cursor(number, optional) - Pagination cursorlimit(number, optional) - Results per page
Example:
request_export
Request a CSV export of account data.
Parameters:
timeFrom(string, required) - Start date (ISO 8601 format)timeTo(string, required) - End date (ISO 8601 format)includeDividends(boolean, optional) - Include dividends (default: true)includeInterest(boolean, optional) - Include interest (default: true)includeOrders(boolean, optional) - Include orders (default: true)includeTransactions(boolean, optional) - Include transactions (default: true)
Example:
Example Conversations
Portfolio Analysis
Order Placement
Historical Analysis
Rate Limits
Trading 212 API enforces rate limits on a per-endpoint basis. This MCP server automatically tracks rate limit information via response headers:
x-ratelimit-limit- Maximum requests allowedx-ratelimit-remaining- Requests remainingx-ratelimit-reset- Unix timestamp when limit resets
Known Limits:
Account Summary: 1 request / 5 seconds
Market Orders: 1 request / 2 seconds
Limit Orders: 1 request / 2 seconds
The server will throw an error if you exceed rate limits. Always check the error messages for rate limit information.
Error Handling
All errors are returned with descriptive messages:
Common errors:
401 Unauthorized - Invalid API key
403 Forbidden - Insufficient permissions
404 Not Found - Resource doesn't exist
429 Too Many Requests - Rate limit exceeded
500 Internal Server Error - Trading 212 service issue
Development
Run in Development Mode
Build for Production
Watch Mode (Auto-rebuild)
API Documentation
For complete API documentation, visit:
Supported Account Types
β Invest Accounts (General trading accounts)
β ISA Accounts (UK tax-advantaged accounts)
β CFD Accounts (Not supported by Trading 212 API)
Limitations
API is currently in BETA and under active development
No WebSocket/streaming support (REST only)
Pies API is deprecated and won't receive further updates
CFD accounts are not supported
Rate limits apply per account (not per API key)
Security Best Practices
Never commit API keys to version control
Use environment variables for sensitive configuration
Enable IP whitelisting if possible
Test in demo environment before using live
Use minimal permissions needed for your use case
Rotate API keys regularly
Monitor API usage through rate limit headers
Troubleshooting
Server Not Appearing in Claude Desktop
Verify the path in
claude_desktop_config.jsonis absoluteEnsure the project is built (
npm run build)Check that
dist/index.jsexistsRestart Claude Desktop completely
Check Claude Desktop logs for errors
Authentication Errors
Verify API key is correct in
.envor configCheck that API key has required permissions
Ensure you're using the correct environment (demo/live)
Verify IP whitelist settings if enabled
Rate Limit Errors
Wait for the rate limit window to reset
Check
x-ratelimit-resetheader for reset timeReduce frequency of API calls
Implement caching where appropriate
Contributing
Contributions are welcome! Please:
Fork the repository
Create a feature branch
Make your changes with tests
Submit a pull request
License
MIT License - see LICENSE file for details
Disclaimer
This is an unofficial integration. Always test thoroughly in the demo environment before using with real money. Trading involves risk, and you should only invest what you can afford to lose.
Support
For issues with this MCP server:
Open an issue on GitHub
For Trading 212 API issues:
Acknowledgments
Built with:
Zod for schema validation
Made with β€οΈ for the Trading 212 and AI community