Trading 212 MCP Server

Trading 212 MCP Server

trading212-mcp-server•byrohananandpandit

A Model Context Protocol server for the Trading 212 public API that exposes account data, positions, orders, pies, instrument metadata, and account history, plus an account-currency-aware analysis prompt.

License: MIT•Runtime: Awaiting documentation review•Category: finance crypto

WHAT IT DOES

  • •Exposes account tools such as fetch_account_summary, fetch_account_cash, and fetch_account_info.
  • •Provides position and order tools, including placing market, limit, stop, and stop-limit orders as well as cancelling orders.
  • •Offers pie management tools and instrument/exchange search, plus history tools for dividends, transactions, exports, and CSV export requests.
  • •Caches successful GET responses in a private SQLite store with account-scoped fingerprints, while never caching or retrying mutations.

BEST FOR

  • •Reviewing an account's portfolio, positions, orders, and pies through an MCP client.
  • •Placing and cancelling trades on a Trading 212 account with tools governed by API permissions and client approval controls.
  • •Analysing account data with an account-currency-aware prompt that explains GBX/GBP units.

ABOUT TRADING212-MCP-SERVER

Trading 212 MCP Server is cataloged as an MCP server attributed to rohananandpandit. A Model Context Protocol server for the Trading 212 public API that exposes account data, positions, orders, pies, instrument metadata, and account history, plus an account-currency-aware analysis prompt. It is categorized under finance crypto. See the capability inspector for recorded interfaces and their independent review status; consult upstream documentation for the current interface.

HOW TO INSTALL

Installation configuration is not reviewed. No executable setup is offered for this entry; inspect the source repository before proceeding.

LICENSE

Catalog license label: MIT. Check the source repository's current license and terms before using, modifying or distributing this software.

Capability inspector

Capability definitions are not reviewed. Unreviewed imports are not exposed as trusted interfaces.

Tools (0)

No reviewed records to display. This does not establish that upstream lacks this capability.

Resources (0)

No reviewed records to display. This does not establish that upstream lacks this capability.

Prompts (0)

No reviewed records to display. This does not establish that upstream lacks this capability.

NEWSLETTER - COMING LATER

Newsletter subscriptions are not open yet

Email delivery is not connected. This page does not collect email addresses or create subscriptions.

Browse the registry for current listings instead.

Community Reviews

Coming later

Reviews for Trading 212 MCP Server are not available yet

Review publishing and storage are not connected. This page does not collect or publish ratings or comments, including after sign-in.

FREQUENTLY ASKED QUESTIONS

Does the server provide market data or investment recommendations?

No. The server states it does not provide independent market feeds, investment recommendations, or real-time streaming.

Can I use it against a demo account before live trading?

Yes. The ENVIRONMENT setting defaults to demo, and the server supports demo or live environments.

Which transport options does the server support?

It supports stdio, SSE, and streamable HTTP transports.

Upstream README

View this exact version on GitHub

README.md · b824a5f93725 · Fetched 2026-11-13 13:04:16 UTC

Original upstream text, without AI rewriting. Scripts, forms and unsafe links are filtered for safety.

Showing the last retrieved documentation snapshot; check the source for current changes.

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

You can follow the setup below yourself or ask a coding agent such as Codex or Claude Code to do it. Paste this prompt into the agent's chat:

Read https://github.com/RohanAnandPandit/trading212-mcp-server/blob/main/README.md#setup
and follow the setup process.

Setup

  1. Install prerequisites and dependencies. You need Git, uv, and Python 3.11–3.14. Choose a stable installation folder, then run:

    git clone https://github.com/RohanAnandPandit/trading212-mcp-server.git
    cd trading212-mcp-server
    uv sync --frozen
    

    If you already have a checkout, reuse it without overwriting local changes. 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 ..

  2. Configure credentials locally. Create an ignored .env file from .env.example if one does not already exist:

    cp .env.example .env
    

    Generate credentials in your Trading 212 account's API settings, granting only the permissions you need. Edit .env yourself to 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; remove the example secret value if using it. Start with ENVIRONMENT=demo and TRANSPORT=stdio. Use the live environment only when you explicitly choose to enable operations on your real account.

    Keep credentials out of chat, commands, logs, and MCP client configuration. If an agent is helping, enter the values yourself; the agent must wait for you and must not read, display, log, or repeat them.

    The server reads .env in its working directory at startup. Existing process environment variables take precedence.

  3. Connect your MCP client. Use your client's supported method to register a local stdio server named trading212. Choose whether the connection should be available only in this workspace or across your projects before saving it. Clients that accept mcpServers JSON can use:

    {
      "mcpServers": {
        "trading212": {
          "command": "uv",
          "args": ["run", "--frozen", "--directory", "/absolute/path/to/trading212-mcp-server", "trading212-mcp-server"],
          "env": {
            "ENVIRONMENT": "demo",
            "TRANSPORT": "stdio"
          }
        }
      }
    }
    

    Replace the example path with your checkout's absolute path. Credentials stay in the checkout's .env file. To launch the server directly from the checkout, run uv run --frozen trading212-mcp-server.

  4. Verify the connection. Restart your MCP client if needed and check that it connects to the server and discovers its tools. Setup is complete only when discovery succeeds. Imports and tool discovery do not make Trading 212 requests, and no credentials are required merely to import the server. Do not call account or trading tools during setup. Record where the MCP configuration was saved and any steps that remain.

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

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

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:

{
  "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.

Successful responses are validated against their endpoint models before caching. 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:

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

If the command reports drift, refresh the snapshot:

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.

Install configuration

Are you the maintainer?

Claim this server with your GitHub account to request manual ownership verification.

README Embed Badge
Markdown

Link to the catalog listing for Trading 212 MCP Server from your README. This badge does not certify ownership, compatibility or security.

[![MCP catalog listing](https://img.shields.io/badge/MCP-awesome--mcp-orange?style=flat-square)](https://awesome-mcp.com/servers/trading212-mcp-server)

REPOSITORY STATS

GitHub StarsUnavailable
ForksUnavailable

Public repository statistics could not be verified. Check the configured source address; unavailable counts are not zero.

Downloads and pulls

Separate sources, scopes and periods. Never combined or treated as installations, active users or security reviews.

No reviewed package or image identity; download statistics are not listed yet.

Related finance crypto MCP Servers

Alternative and complementary servers in the same category

View all in finance crypto →
USA Spending MCP Server
usaspending-mcp-server•thsmale

A stateless streamable HTTP MCP server for interacting with the official source of government spending data.

Repository stats unavailable
Finance & Analytics
Fortnox MCP server — More AI
more-ai-chatgpt-claude-mcp-fortnox•amor3

A hosted, remote MCP server for Fortnox that lets AI assistants answer questions from a company's bookkeeping and propose changes for approval before writing them.

0
Finance & Analytics

OptimistFi is a read-only remote MCP server that provides perpetual futures market data, perps prop firm rules and pricing, and US equity investment research.

Repository stats unavailable
Finance & Analytics