Logo Trading212 MCP Server

Trading212 MCP Server

Cộng đồng
RohanAnandPandit

The Trading212 MCP server is a Model Context Protocol server implementation that provides seamless data connectivity to the Trading212 trading platform enabling advanced interaction capabilities via the public beta API.

Nhà phát hànhRohanAnandPandit
Kho mãtrading212-mcp-server
Ngôn ngữPython
Bản fork
15
Sao
60
Công cụ có sẵn
0
Phương thức truyền tảistdio
Danh mục
Giấy phépMIT
Liên kết
  • Kết nối công cụ với quy trình làm việc AI

    Trading212 MCP Server cung cấp các chức năng MCP cho các ứng dụng khách AI và tác nhân AI tương thích.

  • 0 công cụ có sẵn

    Xem các thao tác có thể gọi bên dưới, kèm tên và mô tả nếu máy chủ cung cấp.

  • Mẫu cấu hình có thể sao chép ngay

    Dùng các đoạn cấu hình mẫu để thiết lập máy chủ này trong ứng dụng khách MCP bạn muốn dùng.

  • Mức độ quan tâm của cộng đồng đến kho mã

    60 sao và 15 bản fork từ kho mã được liên kết.

Trading 212 MCP Server

License: MIT Checks

A Model Context Protocol server for the Trading 212 public API. It exposes account data, positions, orders, pies, instrument metadata, and account history. It also includes an account-currency-aware analysis prompt. It does not provide independent market feeds, investment recommendations, or real-time streaming.

Python 3.11–3.14 is supported. The current source package version is 0.2.0; see the changelog for upgrade details. The project uses the official MCP Python SDK 2.x.

Install and run

Install uv, then:

sh
git clone https://github.com/RohanAnandPandit/trading212-mcp-server.git
cd trading212-mcp-server
uv sync --frozen
cp .env.example .env
# Edit .env with your own credentials.
uv run --frozen trading212-mcp-server

Alternatively, install the package from the checkout using pip install ., then run trading212-mcp-server. For a locked pip installation, use pip install --require-hashes -r requirements.txt followed by pip install --no-deps ..

Generate credentials in your Trading 212 account's API settings. Set TRADING212_API_KEY and, for Basic authentication, TRADING212_API_SECRET. API-key-only authentication remains available for existing integrations, where accepted by Trading 212. Use the demo environment for testing. Live credentials and ENVIRONMENT=live enable operations on the real account.

The server reads .env in its working directory at startup. Existing process environment variables take precedence. Imports and tool discovery do not make Trading 212 requests. No credentials are required merely to import the server.

Desktop MCP configuration

Use this configuration in your MCP client's server settings:

json
{
  "mcpServers": {
    "trading212": {
      "command": "uv",
      "args": ["run", "--frozen", "--directory", "/absolute/path/to/trading212-mcp-server", "trading212-mcp-server"],
      "env": {
        "TRADING212_API_KEY": "YOUR_API_KEY",
        "TRADING212_API_SECRET": "YOUR_API_SECRET",
        "ENVIRONMENT": "demo"
      }
    }
  }
}

Existing configurations pointing to src/server.py continue to work after uv sync --frozen. The script also remains the Inspector entry point:

sh
uv run --frozen mcp dev src/server.py

Inspector requires Node.js and npx. Tool calls in Inspector use the configured account, including mutations when you invoke those tools.

Docker

sh
docker build -t trading212-mcp-server .
docker run --rm -i --env-file .env trading212-mcp-server

For a desktop client, pass both credential variables through Docker:

json
{
  "mcpServers": {
    "trading212": {
      "command": "docker",
      "args": ["run", "--rm", "-i", "-e", "TRADING212_API_KEY", "-e", "TRADING212_API_SECRET", "-e", "ENVIRONMENT", "trading212-mcp-server"],
      "env": {
        "TRADING212_API_KEY": "YOUR_API_KEY",
        "TRADING212_API_SECRET": "YOUR_API_SECRET",
        "ENVIRONMENT": "demo"
      }
    }
  }
}

The image runs as UID/GID 10001. Credentials, local caches, and development files are excluded from the image. The default container cache is ephemeral; mount a private directory writable by UID 10001 at /home/app/.cache if you want persistence. Stdio does not require publishing a port.

Configuration

VariableDefaultMeaning
TRADING212_API_KEYRequiredAccount API key
TRADING212_API_SECRETUnsetSecret for Basic authentication
ENVIRONMENTdemodemo or live
TRANSPORTstdiostdio, sse, or streamable-http
TRADING212_CACHE_DIR.cache/trading212-v3Cache root; relative to working directory
TRADING212_ACCOUNT_TTL15Account, positions, orders, pies, export-status cache seconds
TRADING212_HISTORY_TTL300History cache seconds
TRADING212_METADATA_TTL3600Instrument and exchange cache seconds

A TTL of zero disables caching for that category. Values must be finite and non-negative. HTTP transports bind only to 127.0.0.1:8000, with explicit Host/Origin restrictions. This is a local single-account server; hosted access, public HTTP binding, and multi-user authentication are not provided. Do not expose it through a public proxy or tunnel. Tool annotations describe effects; they do not implement permissions. Use API permissions and your MCP client's approval controls to govern account mutations.

Tools

All previous tool names are retained:

AreaTools
Accountfetch_account_summary, fetch_account_cash, fetch_account_info
Positionsfetch_positions, fetch_position_by_ticker, fetch_all_open_positions, fetch_open_position_by_ticker, search_specific_position_by_ticker
Ordersfetch_all_orders, fetch_order, place_market_order, place_limit_order, place_stop_order, place_stop_limit_order, cancel_order
Piesfetch_pies, fetch_a_pie, create_pie, update_pie, duplicate_pie, delete_pie
Metadatasearch_instrument, search_exchange
Historyfetch_historical_order_data, fetch_paid_out_dividends, fetch_transaction_list, fetch_exports_list, request_csv_export

Positive order quantities buy; negative quantities sell. Zero/non-finite quantities, non-positive prices, and empty tickers are rejected. Pie updates may include any documented field independently; name is optional. Export dates must include a timezone and be ordered. Pies are deprecated upstream, but their tools are retained.

fetch_account_info aliases fetch_account_summary. The older position tools remain compatibility aliases. Historical tools return a single page with nextPagePath; pass its cursor and other query parameters to fetch the next page. Limits retain their existing clamp to 1–50. Requests do not automatically traverse all pages or follow export download links.

Resources and prompt

Resources retain their existing URIs:

  • trading212://account/summary, trading212://account/cash
  • trading212://positions, trading212://positions/{ticker}
  • trading212://orders, trading212://orders/{order_id}
  • trading212://pies, trading212://pies/{pie_id}
  • trading212://instruments, trading212://exchanges
  • trading212://history/exports

Compatibility URIs: trading212://account/info, trading212://account/portfolio, trading212://account/positions, trading212://account/portfolio/{ticker}, and trading212://account/positions/{ticker}.

The analyse_trading212_data prompt includes account currency when available and explains GBX/GBP units. If account retrieval fails, it still returns the base prompt and writes a generic diagnostic to stderr.

Cache and request guarantees

Private data remains cached. Credential/base-URL fingerprints isolate SQLite storage across accounts, secret rotations, environments, and API versions. Authorization and cookies never enter the cache layer. Cache responses contain financial data in plaintext; private filesystem permissions are not encryption. Use a private local disk, not a shared or network-mounted cache directory.

Only successful GETs are cached, and expired responses are never served. Mutations are never cached or automatically retried. After any attempted mutation, private-cache generations advance, including when the outcome is uncertain. A cross-process file lock covers reads, writes, body consumption, and invalidation, preventing older in-flight reads from repopulating the current generation. Different credential namespaces remain independent; external trades or writes using another API key may remain invisible until the TTL expires.

MCP tool results and resource contents carry freshness details under _meta["io.github.RohanAnandPandit.trading212/cache"]: an array of cacheHit, retrievedAt (UTC), and ttlSeconds records. Existing data fields remain intact.

Transient GET failures may be retried twice within a 30-second retry budget, respecting Retry-After and rate-reset headers. Individual HTTP operations have explicit timeouts. Waiting for another process's cache lock is bounded separately at 30 seconds. A failed mutation can have an unknown outcome: check the account before deciding whether to issue it again.

Upgrading from 0.1.x

Stop older server processes, update the checkout, and run uv sync --frozen. The new server never reads or migrates .cache/hishel or .cache/trading212-v2. Those directories may contain private responses and Authorization headers. After confirming the paths belong to this application, explicitly remove old cache directories yourself. The upgrade does not delete user data. Rebuild Docker images and replace any older images that may have included local files.

Development and security

See CONTRIBUTING.md for architecture and verification commands, SECURITY.md for private reporting, and the modernization validation report for checked behavior.

Keeping the Trading 212 schema in sync

Trading 212's live OpenAPI description is the authority. docs/api.json is the reviewable checked-in snapshot. Before making API-facing changes or preparing a release, check it without account credentials:

sh
uv run --with PyYAML python .agents/skills/trading212-api-sync/scripts/sync_api_schema.py --check

If the command reports drift, refresh the snapshot:

sh
uv run --with PyYAML python .agents/skills/trading212-api-sync/scripts/sync_api_schema.py --update

Review the resulting diff rather than treating regeneration as sufficient. Update endpoints, parameters, request and response models, enums, deprecations, tests, and documentation where relevant, then run the full verification suite. The repository-local trading212-api-sync agent skill contains the complete workflow. The schema check only downloads public documentation; it must never make authenticated account requests or trading mutations.

This project is independently maintained and is not affiliated with or endorsed by Trading 212. Consult the provider's current documentation and terms. Licensed under MIT.

Cài đặt

TypingMind
Yêu cầu:

Node.js 18+

{
  "mcpServers": {
    "rohananandpandit-trading212-mcp-server": {
      "command": "npx",
      "args": [
        "-y",
        "trading212-mcp-server"
      ]
    }
  }
}

Dùng MCP Trading212 MCP Server với nhiều mô hình AI

TypingMind kết nối các công cụ MCP ở cấp không gian làm việc, nên sau khi kết nối Trading212 MCP Server, bạn có thể dùng với nhiều mô hình AI khác nhau trong TypingMind thay vì phải thiết lập riêng cho từng mô hình. MCP này chạy cục bộ thông qua trình kết nối MCP của TypingMind trên thiết bị của bạn.

Hướng dẫn thiết lập để dùng trình kết nối cục bộ

Dùng cách này khi máy chủ MCP cần truy cập các tệp, ứng dụng hoặc tài nguyên riêng tư trên máy tính của bạn.

1

Mở cài đặt MCP

Trong TypingMind, vào Cài đặt, Cài đặt nâng cao, rồi đến Giao thức ngữ cảnh mô hình và chọn Thiết lập trình kết nối.

  1. Mở TypingMind trong trình duyệt của bạn.
  2. Nhấp vào biểu tượng Cài đặt.
  3. Vào Cài đặt nâng cao.
  4. Mở mục Giao thức ngữ cảnh mô hình.
  5. Nhấp vào Thiết lập trình kết nối rồi chọn Thiết bị này.
Màn hình thiết lập trình kết nối MCP của TypingMind với tùy chọn Thiết bị này được chọn
2

Chạy lệnh thiết lập trình kết nối

Chọn Thiết bị này, sao chép lệnh từ TypingMind và chạy trong Terminal. Để tiến trình tiếp tục chạy trong khi bạn dùng MCP.

  1. Sao chép lệnh thiết lập hiển thị trong TypingMind.
  2. Mở Terminal trên macOS hoặc Windows Terminal trên Windows.
  3. Dán và chạy lệnh.
  4. Xác nhận cài đặt gói nếu Terminal hỏi bạn có muốn tiếp tục không.
  5. Để tiến trình tiếp tục chạy trong cửa sổ Terminal khi bạn dùng các công cụ MCP.
3

Thêm Trading212 MCP Server làm máy chủ

Khi trạng thái trình kết nối là Sẵn sàng, nhấp vào Sửa máy chủ và dán cấu hình máy chủ MCP.

  1. Đợi đến khi trạng thái trình kết nối hiển thị Sẵn sàng.
  2. Nhấp vào Sửa máy chủ.
  3. Dán cấu hình máy chủ MCP của Trading212 MCP Server.
  4. Lưu danh sách máy chủ.
  5. Làm mới nếu bạn muốn xác nhận trình kết nối vẫn sẵn sàng.
Cài đặt MCP của TypingMind hiển thị máy chủ đang hoạt động và nút Sửa máy chủ
{
  "mcpServers": {
    "rohananandpandit-trading212-mcp-server": {
      "command": "npx",
      "args": [
        "-y",
        "trading212-mcp-server"
      ]
    }
  }
}
4

Dùng kết nối với nhiều mô hình

Lưu danh sách máy chủ, mở Plugin, bật các công cụ MCP của Trading212 MCP Server, sau đó chọn bất kỳ mô hình AI nào được hỗ trợ trong TypingMind và dùng các công cụ trong cuộc trò chuyện hoặc gán chúng cho một tác nhân AI.

  1. Mở trang Plugin trong TypingMind.
  2. Bật các công cụ MCP của Trading212 MCP Server.
  3. Bắt đầu cuộc trò chuyện và chọn mô hình AI bạn muốn dùng.
  4. Dùng các công cụ MCP trong cuộc trò chuyện hoặc gán chúng cho một tác nhân AI.
  5. Chuyển sang mô hình AI khác bất cứ khi nào cần mà không phải kết nối lại MCP.
Cuộc trò chuyện trên TypingMind dùng các công cụ MCP đã bật với mô hình AI đã chọn
Bạn có thể dùng Trading212 MCP Server giúp tôi làm việc này không?
Trading212 MCP Server
Được. Tôi đọc rồi.
Đây là kết quả tôi tìm được bằng Trading212 MCP Server.

Câu hỏi thường gặp

Máy chủ MCP Trading212 MCP Server dùng để làm gì?

Trading212 MCP Server là máy chủ MCP cho phép các ứng dụng AI tương thích kết nối với công cụ và ngữ cảnh bên ngoài. Trong TypingMind, bạn chỉ cần thêm máy chủ MCP này một lần để các công cụ của nó có sẵn trong không gian làm việc AI của bạn.

Bạn có thể dùng MCP Trading212 MCP Server với nhiều mô hình AI trong TypingMind không?

Có. TypingMind kết nối các công cụ MCP ở cấp không gian làm việc, nên bạn có thể dùng Trading212 MCP Server với nhiều mô hình AI như Claude, ChatGPT, Gemini hoặc các mô hình khác đã cấu hình trong TypingMind mà không cần thiết lập máy chủ MCP riêng cho từng mô hình.

Vì sao nên dùng MCP Trading212 MCP Server với TypingMind?

TypingMind là một trong những giao diện trò chuyện với LLM tốt nhất vì tập hợp nhiều mô hình AI, prompt, plugin, tác nhân AI, khóa API và công cụ MCP vào một không gian làm việc. Khi kết nối Trading212 MCP Server, bạn có thể dùng các công cụ MCP của dịch vụ này với những mô hình ưa thích, đồng thời giữ quy trình trò chuyện gọn gàng trong TypingMind.

Làm cách nào để kết nối MCP Trading212 MCP Server với TypingMind?

Trading212 MCP Server hoạt động thông qua trình kết nối MCP cục bộ của TypingMind. Đây là lựa chọn phù hợp nhất khi máy chủ MCP cần truy cập tệp cục bộ, ứng dụng máy tính, công cụ dòng lệnh hoặc tài nguyên riêng trên máy tính của bạn.

MCP Trading212 MCP Server cung cấp những công cụ nào trong TypingMind?

Trading212 MCP Server cung cấp các chức năng MCP mà bạn có thể bật từ trang Plugin của TypingMind để dùng trong trò chuyện hoặc gán cho tác nhân AI.

Bạn có cần chia sẻ khóa API với TypingMind để dùng MCP Trading212 MCP Server không?

Không. TypingMind ưu tiên xử lý cục bộ và cho phép bạn kiểm soát nhà cung cấp mô hình, khóa API, prompt và cấu hình MCP. Nếu Trading212 MCP Server yêu cầu xác thực, hãy thêm các header, cài đặt OAuth hoặc cấu hình cục bộ cần thiết cho máy chủ MCP đó khi tạo kết nối.

Máy chủ MCP liên quan

Xem tất cả

Tạo ngay không gian làm việc AI riêng

Đăng ký bản tin của chúng tôi để nhận thông báo về tính năng mới và các đợt tặng quà sắp tới 👇