Trading 212 MCP Server

Local setup required. This server has to be cloned and prepared on your machine before you register it in Claude Code.
1

Set the server up locally

Run this once to clone and prepare the server before adding it to Claude Code.

Run in terminal
npm install
npm run build
2

Register it in Claude Code

After the local setup is done, run this command to point Claude Code at the built server.

Run in terminal
claude mcp add -e "TRADING212_API_KEY=${TRADING212_API_KEY}" trading212-mcp -- node "<FULL_PATH_TO_TRADING212_MCP>/dist/index.js"

Replace <FULL_PATH_TO_TRADING212_MCP>/dist/index.js with the actual folder you prepared in step 1.

Required:TRADING212_API_KEY+ 3 optional
README.md

Interact with Trading 212 investment accounts for portfolio and order management.

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.

Deployment Options:

  • Local installation with Node.js
  • Docker container (production-ready)
  • Docker Compose for easy orchestration

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 & Observability

  • Automatic rate limit tracking and headers
  • Zod schema validation for type safety
  • Comprehensive error handling with custom error classes
  • Production-grade structured logging (Pino)
  • Support for both demo and live environments
  • Debug mode for API request/response inspection

Installation

Prerequisites

  • Node.js 24+ installed
  • Trading 212 account (Invest or ISA)
  • Trading 212 API key (see Setup Guide)

Option 1: Docker (Recommended for Production)

The easiest way to deploy the MCP server is using Docker:

# Clone the repository
git clone https://github.com/enderekici/trading212-mcp.git
cd trading212-mcp

# Create .env file with your API key
echo "TRADING212_API_KEY=your_api_key_here" > .env
echo "TRADING212_ENVIRONMENT=demo" >> .env

# Start with Docker Compose
docker-compose up -d

See DOCKER.md for comprehensive Docker deployment guide.

Option 2: Local Installation

Install and build from source:

# Install dependencies
npm install

# Build the project
npm run build

Configuration

Getting Your API Key

  1. Open the Trading 212 app (mobile or web)
  2. Navigate to Settings → API (Beta)
  3. Click Generate API Key
  4. Configure permissions:
    • āœ… Account data (read) - View account information
    • āœ… History (read) - Access historical data
    • āœ… Orders (read/write) - View and place orders
    • āœ… Portfolio (read) - View positions
  5. (Optional) Set IP address whitelist for additional security
  6. 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:

# Required: Your Trading 212 API key
TRADING212_API_KEY=your_api_key_here

# Optional: Environment (demo or live), defaults to demo
TRADING212_ENVIRONMENT=demo

# Optional: Log level (trace, debug, info, warn, error, fatal), defaults to info
LOG_LEVEL=info

# Optional: Node environment (development or production), defaults to development
NODE_ENV=development

Environments:

  • demo - Paper trading environment (recommended for testing)
    • API Base URL: https://demo.trading212.com/api/v0
    • Uses paper trading account (no real money)
    • Safe for testing and development
    • Default value if not specified
  • live - Real money trading environment
    • API Base URL: https://live.trading212.com/api/v0
    • Uses real money trading account
    • Use with caution

āš ļø Important: Your API key is environment-specific. A demo API key only works with TRADING212_ENVIRONMENT=demo, and a live API key only works with TRADING212_ENVIRONMENT=live. You cannot mix them.

šŸ“– For detailed information about environments, see ENVIRONMENTS.md

Log Levels:

  • trace - Most

Tools (5)

get_account_infoRetrieve account information including currency, ID, and cash balances.
list_positionsList all open investment positions with real-time profit/loss tracking.
place_orderPlace market, limit, stop, or stop-limit orders for tradeable instruments.
list_piesList all investment pies and their current allocations.
get_historyRetrieve order, dividend, or transaction history for specified periods.

Environment Variables

TRADING212_API_KEYrequiredYour Trading 212 API key generated from the app settings.
TRADING212_ENVIRONMENTThe environment to connect to: demo or live.
LOG_LEVELLogging verbosity (trace, debug, info, warn, error, fatal).
NODE_ENVNode environment (development or production).

Configuration

claude_desktop_config.json
{"mcpServers": {"trading212": {"command": "node", "args": ["/path/to/trading212-mcp/build/index.js"], "env": {"TRADING212_API_KEY": "your_api_key_here", "TRADING212_ENVIRONMENT": "demo"}}}}

Try it

→What is the current total value of my Trading 212 portfolio and how much cash is available?
→List all my open positions and identify which ones have the highest profit percentage.
→Place a market order to buy 5 shares of AAPL.
→Show me my dividend payment history for the last 6 months.
→What are the current allocations in my 'Tech Growth' investment pie?

Frequently Asked Questions

What are the key features of Trading 212?

Real-time portfolio tracking and profit/loss monitoring. Support for market, limit, stop, and stop-limit order execution. Comprehensive account management including cash balance retrieval. Investment pie management including creation and allocation updates. Historical data access for orders, dividends, and transactions.

What can I use Trading 212 for?

Automating portfolio rebalancing based on custom AI-driven analysis. Generating detailed performance reports for tax or personal tracking. Executing trades via natural language commands during market hours. Monitoring dividend income and transaction history without manual app navigation.

How do I install Trading 212?

Install Trading 212 by running: docker-compose up -d

What MCP clients work with Trading 212?

Trading 212 works with any MCP-compatible client including Claude Desktop, Claude Code, Cursor, and other editors with MCP support.

Turn this server into reusable context

Keep Trading 212 docs, env vars, and workflow notes in Conare so your agent carries them across sessions.

Need the old visual installer? Open Conare IDE.
Open Conare