Trading 212 MCP Server
Provides secure access to Trading 212 Public API through MCP, enabling Claude Desktop users to manage portfolios, execute trades, and analyze market data using natural language commands.
README
<div align="center">
Trading 212 MCP Server
Secure Trading 212 Public API access for Claude via MCP
<img height="30" src="https://img.shields.io/badge/MCP-Server-4f46e5?style=flat-square" alt="MCP Server" /> <img height="30" src="https://img.shields.io/badge/TypeScript-Strict-3178c6?style=flat-square&logo=typescript&logoColor=white" alt="TypeScript" /> <img height="30" src="https://img.shields.io/badge/Bun-1.x-000000?style=flat-square&logo=bun&logoColor=white" alt="Bun" /> <img height="30" src="https://img.shields.io/badge/Trading%20212-Public%20API-059669?style=flat-square" alt="Trading 212 API" />
Built with:
<img height="36" src="https://img.shields.io/badge/-TypeScript-3178c6?style=flat-square&logo=typescript&logoColor=white" alt="TypeScript" /> <img height="36" src="https://img.shields.io/badge/-Bun-000000?style=flat-square&logo=bun&logoColor=white" alt="Bun" /> <img height="36" src="https://img.shields.io/badge/-Node.js-339933?style=flat-square&logo=nodedotjs&logoColor=white" alt="Node.js" /> <img height="36" src="https://img.shields.io/badge/-MCP%20SDK-111827?style=flat-square" alt="MCP SDK" /> <img height="36" src="https://img.shields.io/badge/-Zod-3b82f6?style=flat-square" alt="Zod" />
</div>
Project Overview
This project exposes Trading 212 Public API capabilities as MCP tools so Claude Desktop can securely query account, market, order, history, and pie data. It targets users who want natural-language access to their portfolio workflows without building a custom UI. The main value is a modular feature-based TypeScript architecture with structured errors, strict environment handling, and tool-first MCP integration.
Key Features
- Claude-Ready MCP Tools - Use Trading 212 operations directly from Claude Desktop through MCP.
- Public API-Compatible Auth - Supports Trading 212 Basic auth with API key + API secret.
- Complete Pies Coverage - Includes list, fetch by id, create, update, duplicate, and delete pie operations.
- Order Workflows Included - Pending orders, order details, place/cancel limit, market, stop, and stop-limit orders.
- History + Export Operations - Cursor-based historical orders, dividends, transactions, and CSV export request/list endpoints.
- Typed Error Model - Consistent authentication, validation, rate-limit, not-found, and API error handling.
Quick Start Demo
Run locally, then inspect tools using MCP Inspector:
npx @modelcontextprotocol/inspector
For stdio mode, configure Inspector command as:
bun run src/server.ts
Tech Stack
- Language: TypeScript (strict mode)
- Runtime: Bun 1.x (Node.js 18+ compatible)
- MCP:
@modelcontextprotocol/sdk - Validation/Schema:
zod - Config:
dotenv - Testing: Bun test runner (
bun test src)
Installation & Setup
Prerequisites
- Bun 1.0+
- Node.js 18+
- Trading 212 Public API credentials (
TRADING212_API_KEY,TRADING212_API_SECRET) - Claude Desktop (for MCP integration)
Setup
-
Clone the Repository
git clone https://github.com/razeevascx/212mcp.git -
Navigate to Project
cd 212mcp -
Install Dependencies
bun install -
Configure Environment
cp .env.example .env -
Set Credentials in
.envTRADING212_API_KEY=your_api_key_here TRADING212_API_SECRET=your_api_secret_here ENVIRONMENT=live TRANSPORT=stdio LOG_LEVEL=info DEBUG=false -
Build Project
bun run build -
Start Server
bun run start
Verification
- You should see
Trading 212 MCP Server runningin terminal output. - In Claude Desktop, open MCP tools and confirm Trading 212 tools are listed.
Claude Desktop Configuration
Use this MCP server config:
{
"mcpServers": {
"trading212": {
"command": "/absolute/path/to/212mcp/start.sh"
}
}
}
Create start.sh and make it executable:
#!/bin/bash
set -euo pipefail
set -a
source /absolute/path/to/212mcp/.env
set +a
exec bun run /absolute/path/to/212mcp/src/server.ts
MCP Tools
Accounts
fetch_account_cashfetch_account_metadata
Instruments
search_exchangesearch_instrument
Portfolio / Positions
fetch_open_positions(optionaltickerfilter)
Orders
fetch_all_ordersfetch_orderplace_limit_orderplace_market_orderplace_stop_orderplace_stop_limit_ordercancel_order
History
fetch_historical_order_datafetch_paid_out_dividendsfetch_transaction_listfetch_exports_listrequest_export_csv
Pies
fetch_piesfetch_piecreate_pieupdate_pieduplicate_piedelete_pie
Server Utility
get_server_health
API Usage Notes
- Authentication: Trading 212 Public API uses Basic auth (
API_KEY:API_SECRET), handled byBaseClient. - Environment Routing:
ENVIRONMENT=demo|livemaps to Trading 212 demo/live base URLs. - Pagination: History endpoints use
limit+cursorand returnnextPagePath. - Rate Limits: The API is rate-limited;
429is surfaced asRATE_LIMIT_EXCEEDED.
Development
Scripts
bun run build— Compile TypeScriptbun run start— Start MCP serverbun run dev— Watch modebun test src— Run tests insrc
Troubleshooting
- Credentials missing: set
TRADING212_API_KEYandTRADING212_API_SECRET. - Auth errors: regenerate API credentials and restart server.
- Claude cannot connect: verify Bun install, command path, and Claude MCP config.
On startup, the server validates auth configuration and fails fast if credentials are incomplete.
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.