Skip to main content
Glama
Trading 212 MCP Server

Trading 212 MCP Server

Trading 212 MCP サーバー

MCP を介した Claude 用の安全な Trading 212 Public API アクセス

使用技術:

プロジェクト概要

このプロジェクトは、Trading 212 Public API の機能を MCP ツールとして公開し、Claude Desktop がアカウント、市場、注文、履歴、およびパイ(Pie)データを安全に照会できるようにします。カスタム UI を構築することなく、自然言語でポートフォリオのワークフローにアクセスしたいユーザーを対象としています。主な価値は、構造化されたエラー、厳格な環境処理、およびツールファーストの MCP 統合を備えた、モジュール式の機能ベースの TypeScript アーキテクチャにあります。

Related MCP server: Trading 212 MCP Server

主な機能

  • Claude 対応 MCP ツール - MCP を通じて Claude Desktop から直接 Trading 212 の操作を実行できます。

  • Public API 互換認証 - API キー + API シークレットを使用した Trading 212 の基本認証をサポートします。

  • パイ(Pie)の完全サポート - 一覧表示、ID による取得、作成、更新、複製、削除の各操作が含まれます。

  • 注文ワークフロー - 未決済注文、注文詳細、指値注文、成行注文、逆指値注文、逆指値指値注文の配置/キャンセルに対応しています。

  • 履歴 + エクスポート操作 - カーソルベースの履歴注文、配当、取引、および CSV エクスポートのリクエスト/一覧取得エンドポイント。

  • 型定義されたエラーモデル - 認証、バリデーション、レート制限、未検出、および API エラーの一貫した処理。

クイックスタートデモ

ローカルで実行し、MCP Inspector を使用してツールを検査します:

npx @modelcontextprotocol/inspector

stdio モードの場合、Inspector コマンドを次のように設定します:

bun run src/server.ts

技術スタック

  • 言語: TypeScript (strict モード)

  • ランタイム: Bun 1.x (Node.js 18+ 互換)

  • MCP: @modelcontextprotocol/sdk

  • バリデーション/スキーマ: zod

  • 設定: dotenv

  • テスト: Bun テストランナー (bun test src)

インストールとセットアップ

前提条件

  • Bun 1.0+

  • Node.js 18+

  • Trading 212 Public API 認証情報 (TRADING212_API_KEY, TRADING212_API_SECRET)

  • Claude Desktop (MCP 統合用)

セットアップ

  1. リポジトリのクローン

    git clone https://github.com/razeevascx/212mcp.git
  2. プロジェクトディレクトリへ移動

    cd 212mcp
  3. 依存関係のインストール

    bun install
  4. 環境設定

    cp .env.example .env
  5. .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. プロジェクトのビルド

    bun run build
  7. サーバーの起動

    bun run start

検証

  • ターミナル出力に Trading 212 MCP Server running と表示されるはずです。

  • Claude Desktop で MCP ツールを開き、Trading 212 ツールがリストされていることを確認してください。

Claude Desktop の設定

以下の MCP サーバー設定を使用してください:

{
  "mcpServers": {
    "trading212": {
      "command": "/absolute/path/to/212mcp/start.sh"
    }
  }
}

start.sh を作成し、実行権限を付与します:

#!/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 ツール

アカウント

  • fetch_account_cash

  • fetch_account_metadata

インストゥルメント

  • search_exchange

  • search_instrument

ポートフォリオ / ポジション

  • fetch_open_positions (オプションの ticker フィルターあり)

注文

  • fetch_all_orders

  • fetch_order

  • place_limit_order

  • place_market_order

  • place_stop_order

  • place_stop_limit_order

  • cancel_order

履歴

  • fetch_historical_order_data

  • fetch_paid_out_dividends

  • fetch_transaction_list

  • fetch_exports_list

  • request_export_csv

パイ(Pie)

  • fetch_pies

  • fetch_pie

  • create_pie

  • update_pie

  • duplicate_pie

  • delete_pie

サーバーユーティリティ

  • get_server_health

API 使用上の注意

  • 認証: Trading 212 Public API は基本認証 (API_KEY:API_SECRET) を使用し、BaseClient によって処理されます。

  • 環境ルーティング: ENVIRONMENT=demo|live は Trading 212 のデモ/ライブベース URL にマッピングされます。

  • ページネーション: 履歴エンドポイントは limit + cursor を使用し、nextPagePath を返します。

  • レート制限: API にはレート制限があり、429 は RATE_LIMIT_EXCEEDED として表面化されます。

開発

スクリプト

  • bun run build — TypeScript のコンパイル

  • bun run start — MCP サーバーの起動

  • bun run dev — ウォッチモード

  • bun test src — src 内のテスト実行

トラブルシューティング

  • 認証情報が不足している場合: TRADING212_API_KEY と TRADING212_API_SECRET を設定してください。

  • 認証エラー: API 認証情報を再生成し、サーバーを再起動してください。

  • Claude が接続できない場合: Bun のインストール、コマンドパス、および Claude MCP 設定を確認してください。

起動時に、サーバーは認証設定を検証し、認証情報が不完全な場合は即座に停止します。

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    Related MCP Connectors

    • Connect Claude, ChatGPT, Codex, Claude Code or another MCP client to your real multi-broker investment portfolio. Fortunest tracks stocks, ETFs and crypto across brokers and exchanges; its MCP server lets your agent read holdings, returns, allocation, risk, trades and tax lots, calculated by Fortunest rather than guessed by the model. Reads run on their own; every change waits for your approval in the Fortunest app, and no tool places an order or moves money. Sign-in is OAuth 2.1 and needs Fortunest Pro (14-day trial, no card). A free demo that needs no account is listed as Fortunest demo.

      https://app.fortunest.ai/mcp
    • Connect brokerage accounts to AI assistants: holdings, orders, asset lookup, and approved trading.

      https://mcp.tradeit.app/mcp
    • Build and backtest investing strategies from your AI assistant. Remote MCP with OAuth sign-in.

      https://tactfolio.com/mcp
    • OpenFinance gives any AI agent easy trading across every major market through one hosted MCP server. Trade crypto spot and perpetuals on Hyperliquid with market, limit and TWAP orders, leverage and margin control. Trade stocks, indices, commodities, forex and pre-IPO names as Hyperliquid HIP-3 perps. Trade Polymarket prediction markets with odds, order books, positions, PnL and trader leaderboards. Swap and bridge across 40+ EVM chains and Solana with Relay and Jupiter, find memecoins across 200+ chains, launch tokens on Robinhood Chain and Solana, and buy crypto with card, bank or UPI. Write actions are designed to ask for your confirmation first. Connect with OAuth (sign in to OpenFinance and approve) or an API key. Works with Claude, ChatGPT, Cursor, VS Code, Codex and any MCP client. No install. Home: https://openfinance.tech/agents · Docs: https://docs.openfinance.tech · GitHub: https://github.com/openfinance-tech/mcp

    Related MCP Servers

    • A
      license
      A
      quality
      D
      maintenance
      Enables AI assistants to interact with Trading 212 investment accounts for portfolio tracking, account management, and real-time order execution. It supports managing investment pies, analyzing historical data, and monitoring market performance across multiple instrument types.
      23
      2
      MIT
    • A
      license
      Not graded
      quality
      B
      maintenance
      Exposes Trading 212 trading account, instruments, orders, history, and pies as MCP tools. Allows placing and canceling real orders (defaults to demo/paper environment).
      Apache 2.0
    • A
      license
      Not graded
      quality
      D
      maintenance
      Enables AI assistants to read a Trading 212 portfolio (balances, positions, orders, history) and place trades via the public API, supporting both demo and live environments.
      MIT
    • F
      license
      Not graded
      quality
      C
      maintenance
      Exposes Trading212 account data (summary, portfolio, cash, order history, dividends) as MCP tools, intended for direct connection to Claude.ai.
      -