Trading 212 MCP Server

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.15 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
Using Claude Code? Install the Claude Code plugin
instead; it needs no clone or manual MCP configuration.
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
-
Install prerequisites and dependencies. You need Git,
uv, and Python
3.11–3.15. 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 ..
-
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.
-
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.
-
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: