Skip to main content
Glama
joshua-repo

t212-mcp

by joshua-repo

t212-mcp

一个 MCP 服务器,将您的 Trading212 账户(摘要、投资组合、现金、订单历史、股息)作为工具暴露出来,旨在作为自定义远程连接器直接连接到 claude.ai。

由于 claude.ai 通过公共互联网访问此服务器,而您的 T212 账户是 live 的,因此服务器在提供任何工具调用之前要求进行 OAuth 登录(您设置的单一密码)——参见 auth.py

0. 将代码获取到 VPS 上,并安装先决条件

git clone <this-repo-url> t212-mcp && cd t212-mcp

您需要在 VPS 上安装:gitrsyncuv,并且要系统级安装(不能只安装在您自己的 $HOME 下,因为应用稍后将以自己的专用系统用户身份运行,且没有主目录):

curl -LsSf https://astral.sh/uv/install.sh | sh
sudo cp "$HOME/.local/bin/uv" /usr/local/bin/uv

Related MCP server: Trading212 MCP Server

1. 配置

python3 setup_wizard.py

它会以交互方式引导您完成配置:您的 T212 API 密钥/机密、一个域名(如果您没有自己的域名,它会提供一个免费的 <ip>.sslip.io 域名),以及登录密码——然后以 chmod 600 权限写入 .env。您可以随时重新运行它以从头重新生成 .env(覆盖前会询问)。

更喜欢手动编辑?cp .env.example .env 然后填写:

  • T212_API_KEY / T212_API_SECRET — 来自 Trading212 → Settings → API(Key/Secret 对,Basic auth)。

  • T212_ENVlivedemo

  • MCP_PUBLIC_URL — 此服务器可被访问的 HTTPS URL,例如 https://mcp.example.com(无尾部斜杠)。必须与您的 DNS + 反向代理设置匹配。

  • MCP_DOMAIN — 与上述相同的主机,不带协议方案(Caddy 使用它来请求 TLS 证书)。

  • MCP_AUTH_PASSWORD — 只有您知道的密码;连接 Claude 时,您需要在浏览器中输入一次。

2. 将 DNS 指向您的 VPS

MCP_DOMAIN 中的域名创建指向您 VPS IP 的 A/AAAA 记录。端口 80 和 443 必须可从互联网访问。

在下面安装 TLS 反向代理之前,请检查此机器上是否已有内容绑定到 80/443(例如为其他站点提供服务的现有 nginx/Caddy):

sudo ss -tlnp | grep -E ':80|:443'

3. 运行它

sudo useradd --system --no-create-home --shell /usr/sbin/nologin t212mcp
sudo mkdir -p /opt/t212-mcp
sudo rsync -a --exclude .venv --exclude __pycache__ --exclude .git ./ /opt/t212-mcp/
sudo chown -R t212mcp:t212mcp /opt/t212-mcp
cd /opt/t212-mcp
# t212mcp has no home dir, so point uv's cache somewhere it can write:
sudo -u t212mcp env HOME=/opt/t212-mcp UV_CACHE_DIR=/opt/t212-mcp/.cache/uv \
    uv sync --frozen --no-dev

sudo cp deploy/t212-mcp.service /etc/systemd/system/
sudo systemctl daemon-reload
sudo systemctl enable --now t212-mcp

然后根据上面 ss -tlnp 显示的内容,在端口 8000 前配置 TLS:

  • 80/443 上没有运行任何内容 — 安装 Caddy(单个静态二进制文件,空闲时约 10-20MB 内存)并将其指向 deploy/Caddyfile

    sudo apt install -y debian-keyring debian-archive-keyring apt-transport-https
    curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key' | sudo gpg --dearmor -o /usr/share/keyrings/caddy-stable-archive-keyring.gpg
    curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt' | sudo tee /etc/apt/sources.list.d/caddy-stable.list
    sudo apt update && sudo apt install -y caddy
    set -a; source .env; set +a
    sudo bash -c "sed 's/{\$MCP_DOMAIN}/'\"$MCP_DOMAIN\"'/' deploy/Caddyfile > /etc/caddy/Caddyfile"
    sudo systemctl reload caddy
  • nginx 已在运行 为其他站点提供服务 — 将 deploy/nginx.conf.example 复制到 /etc/nginx/sites-available/t212-mcp,将其中的 mcp.example.com 替换为您的真实 $MCP_DOMAIN,将其符号链接到 sites-enabled,执行 nginx -t && systemctl reload nginx,然后执行 sudo certbot --nginx -d $MCP_DOMAIN(不会影响您现有的 server 块)。

检查它是否已启动:

curl https://$MCP_DOMAIN/.well-known/oauth-authorization-server

4. 将其连接到 Claude

在 claude.ai 中:Settings → Connectors → Add custom connector,将 https://<MCP_DOMAIN>/mcp 粘贴为 URL。Claude 将打开一个浏览器标签页,转到此服务器的登录页面——输入 MCP_AUTH_PASSWORD——然后您将被重定向回来,完成连接。

本地开发

uv run python server.py 在本地 HOST:PORT(默认 0.0.0.0:8000)上运行相同的 streamable-HTTP + OAuth 服务器——即使本地运行,MCP_PUBLIC_URLMCP_AUTH_PASSWORD 也是必需的环境变量,因为 OAuth 提供程序是无条件接入的。将 MCP_PUBLIC_URL 指向 http://127.0.0.1:8000 以进行仅限本地的测试(无 TLS,无 Claude 连接器,仅用于使用 curl 测试工具代码和 OAuth 流程)。

Maintenance

ActivityMaintained
ResponsivenessSyncing

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Connectors

  • Brazilian Open Finance MCP — 30+ banks (Itaú, Nubank, etc.) to Claude/Cursor. Read-only.

  • Real SEC, 13F, insider, congress & macro data your AI agent can cite. Hosted MCP, 24 tools.

  • MCP server exposing the Backtest360 engine API as tools for AI agents.

  • SmartMoney77 MCP v0.6.0 — 14 public tools that turn financial questions into exact numbers and citable links. New: historical_investment_return and compare_investments, which compute "what if I had invested" results from real yearly price data. Also compound interest, FIRE number, credit-card payoff, emergency fund, inflation, latte factor, investment fees, cost of waiting, plus discovery/deep-link/share-pack tools for a catalog of calculators in 6 languages (he/en/ar/es/pt/in). Public, no login. Endpoint: https://smartmoney77.com/mcp

Related MCP Servers

  • F
    license
    Not graded
    quality
    D
    maintenance
    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.
  • A
    license
    Not graded
    quality
    D
    maintenance
    Enables AI agents to manage Trading212 brokerage accounts, including portfolio analysis, order placement (demo mode), and investment pie management.
    5
    MIT
  • F
    license
    A
    quality
    D
    maintenance
    An MCP server that wraps the Trading 212 Public API, enabling AI agents to interact with your Trading 212 brokerage account through natural language.
    16
  • 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

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/joshua-repo/t212-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server