Model Context Protocol server for the Capital.com Open API (built on capitalcom-cli)
Project description
Capital.com MCP Server
Model Context Protocol server for the Capital.com Open API. Built on the tested
capitalcom-cli broker engine
(SDK), it exposes safe, guarded trading + market-data tools to MCP clients.
⚠️ Unofficial & educational. Not affiliated with Capital.com. Trading is risky and this is not financial advice. Trading is disabled by default; all trades are two-phase (preview → confirm → execute) with allowlists and size/rate limits. Start on a demo account. Apache-2.0 licensed.
Install
No clone required — uvx runs it in an isolated, throwaway environment and
always fetches the latest tested release:
uvx capitalcom-mcp --help # smoke test
Or install a persistent command with pipx:
pipx install capitalcom-mcp
1. Add your credentials (once)
Get an API key in the Capital.com app: Settings → API integrations (make a
demo key first). Then run the wizard — it writes a 0600 file and prints
the exact client snippet:
uvx capitalcom-mcp init
This writes ~/.config/capital-mcp/.env. Verify any time (no secrets printed):
uvx capitalcom-mcp doctor
Prefer a secret manager? Set CAP_API_KEY_CMD / CAP_IDENTIFIER_CMD /
CAP_API_PASSWORD_CMD to a command that prints the secret (e.g.
op read op://vault/..., pass ...). The secret is fetched at launch and never
written to disk or to your client config.
2. Add the server to your client
Every client uses the same command/args/env shape. Pasting
"CAP_ENV_FILE": "<path from init>" keeps secrets out of the client file; or
put CAP_API_KEY/CAP_IDENTIFIER/CAP_API_PASSWORD directly in env.
Claude Desktop
~/Library/Application Support/Claude/claude_desktop_config.json (macOS) /
%APPDATA%\Claude\claude_desktop_config.json (Windows):
{
"mcpServers": {
"capitalcom": {
"command": "uvx",
"args": ["capitalcom-mcp"],
"env": { "CAP_ENV_FILE": "/Users/you/.config/capital-mcp/.env" }
}
}
}
Claude Code
claude mcp add --transport stdio \
--env CAP_ENV_FILE=/Users/you/.config/capital-mcp/.env \
capitalcom -- uvx capitalcom-mcp
Cursor
~/.cursor/mcp.json (global) or .cursor/mcp.json (project):
{
"mcpServers": {
"capitalcom": {
"command": "uvx",
"args": ["capitalcom-mcp"],
"env": { "CAP_ENV_FILE": "/Users/you/.config/capital-mcp/.env" }
}
}
}
VS Code (Copilot)
.vscode/mcp.json — note the root key is servers and type: "stdio":
{
"servers": {
"capitalcom": {
"type": "stdio",
"command": "uvx",
"args": ["capitalcom-mcp"],
"env": { "CAP_ENV_FILE": "/Users/you/.config/capital-mcp/.env" }
}
}
}
Windsurf
~/.codeium/windsurf/mcp_config.json:
{
"mcpServers": {
"capitalcom": {
"command": "uvx",
"args": ["capitalcom-mcp"],
"env": { "CAP_ENV_FILE": "/Users/you/.config/capital-mcp/.env" }
}
}
}
ChatGPT
ChatGPT requires a remote server (stdio is not supported) — see
Remote / VPS hosting. Once your server is reachable over
HTTPS, enable Developer Mode (Settings → Connectors → Advanced) and add the
server URL ending in /mcp. ChatGPT Deep Research connectors call two
read-only tools, search and fetch, which this server implements; full custom
tools require Developer Mode.
Remote / VPS hosting
Run with streamable-HTTP instead of stdio:
CAP_ENV_FILE=/home/you/.config/capital-mcp/.env \
capitalcom-mcp run --transport http --host 0.0.0.0 --port 8000
# endpoint: http://<host>:8000/mcp
Or via env (handy in systemd): CAP_MCP_TRANSPORT=http, CAP_MCP_HOST,
CAP_MCP_PORT. Put it behind a TLS-terminating reverse proxy for any public use.
Safety model
- Trading off unless
CAP_ALLOW_TRADING=trueand the EPIC is inCAP_ALLOWED_EPICS(orALL). - Two-phase execution;
confirm=truerequired for mutations. - Size, open-position, and daily-order caps;
CAP_DRY_RUN=trueblocks all executions. ATIMEOUTconfirmation is ambiguous — reconcile, don't blindly retry.
Development
make install # editable MCP + capitalcom-cli SDK from PyPI
make check # ruff + mypy + pytest (offline; no network/credentials)
End-to-end tests drive every tool through the MCP against the demo API
(read, watchlists, account switch, preview/execute/amend/close/cancel, streaming).
They place real demo orders and clean up after themselves, so use a demo .env
with trading + streaming enabled:
# demo .env: CAP_ALLOW_TRADING=true, CAP_ALLOWED_EPICS=GOLD, CAP_WS_ENABLED=true
CAP_MCP_E2E=1 pytest -m e2e -v
License
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file capitalcom_mcp-0.2.0.tar.gz.
File metadata
- Download URL: capitalcom_mcp-0.2.0.tar.gz
- Upload date:
- Size: 34.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4130173f6e0468886f02b4ff515c66440f2d79dbaba7504853dd15caacc24253
|
|
| MD5 |
1cf478b6e83e9b43c7955c401f8a0984
|
|
| BLAKE2b-256 |
54df93152385f0e06d6b91948bf29181289daa84371e88e3e74747cab8106a2e
|
Provenance
The following attestation bundles were made for capitalcom_mcp-0.2.0.tar.gz:
Publisher:
publish.yml on SimonTarara62/capitalcom-mcp-server
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
capitalcom_mcp-0.2.0.tar.gz -
Subject digest:
4130173f6e0468886f02b4ff515c66440f2d79dbaba7504853dd15caacc24253 - Sigstore transparency entry: 1821641828
- Sigstore integration time:
-
Permalink:
SimonTarara62/capitalcom-mcp-server@f8fbcbee2b89e9514b38d9a616bc8f726ce367d0 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/SimonTarara62
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@f8fbcbee2b89e9514b38d9a616bc8f726ce367d0 -
Trigger Event:
release
-
Statement type:
File details
Details for the file capitalcom_mcp-0.2.0-py3-none-any.whl.
File metadata
- Download URL: capitalcom_mcp-0.2.0-py3-none-any.whl
- Upload date:
- Size: 28.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0d27312deea27ec4b2b2d2823b6a141f0e68711a1e9b8ae68dee853c96911d12
|
|
| MD5 |
6db85dcce1c00348754b1a4f424037d1
|
|
| BLAKE2b-256 |
69ffea1312a8959f29a7d8ef25f01dac8ad240517a164d5696f58c7763c8d380
|
Provenance
The following attestation bundles were made for capitalcom_mcp-0.2.0-py3-none-any.whl:
Publisher:
publish.yml on SimonTarara62/capitalcom-mcp-server
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
capitalcom_mcp-0.2.0-py3-none-any.whl -
Subject digest:
0d27312deea27ec4b2b2d2823b6a141f0e68711a1e9b8ae68dee853c96911d12 - Sigstore transparency entry: 1821641882
- Sigstore integration time:
-
Permalink:
SimonTarara62/capitalcom-mcp-server@f8fbcbee2b89e9514b38d9a616bc8f726ce367d0 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/SimonTarara62
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@f8fbcbee2b89e9514b38d9a616bc8f726ce367d0 -
Trigger Event:
release
-
Statement type: