Trading 212 MCP Server

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.

Category
访问服务器

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

  1. Clone the Repository

    git clone https://github.com/razeevascx/212mcp.git
    
  2. Navigate to Project

    cd 212mcp
    
  3. Install Dependencies

    bun install
    
  4. Configure Environment

    cp .env.example .env
    
  5. Set Credentials in .env

    TRADING212_API_KEY=your_api_key_here
    TRADING212_API_SECRET=your_api_secret_here
    ENVIRONMENT=live
    TRANSPORT=stdio
    LOG_LEVEL=info
    DEBUG=false
    
  6. Build Project

    bun run build
    
  7. Start Server

    bun run start
    

Verification

  • You should see Trading 212 MCP Server running in 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_cash
  • fetch_account_metadata

Instruments

  • search_exchange
  • search_instrument

Portfolio / Positions

  • fetch_open_positions (optional ticker filter)

Orders

  • fetch_all_orders
  • fetch_order
  • place_limit_order
  • place_market_order
  • place_stop_order
  • place_stop_limit_order
  • cancel_order

History

  • fetch_historical_order_data
  • fetch_paid_out_dividends
  • fetch_transaction_list
  • fetch_exports_list
  • request_export_csv

Pies

  • fetch_pies
  • fetch_pie
  • create_pie
  • update_pie
  • duplicate_pie
  • delete_pie

Server Utility

  • get_server_health

API Usage Notes

  • Authentication: Trading 212 Public API uses Basic auth (API_KEY:API_SECRET), handled by BaseClient.
  • Environment Routing: ENVIRONMENT=demo|live maps to Trading 212 demo/live base URLs.
  • Pagination: History endpoints use limit + cursor and return nextPagePath.
  • Rate Limits: The API is rate-limited; 429 is surfaced as RATE_LIMIT_EXCEEDED.

Development

Scripts

  • bun run build — Compile TypeScript
  • bun run start — Start MCP server
  • bun run dev — Watch mode
  • bun test src — Run tests in src

Troubleshooting

  • Credentials missing: set TRADING212_API_KEY and TRADING212_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.

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选