Capital.com MCP Server for Amazon Q and other LLMs
Project description
Capital.com MCP Server
This is a Model Context Protocol (MCP) server that exposes the Capital.com trading API as tools that can be used by Amazon Q, Claude Desktop, and other LLMs that support the MCP protocol.
Available Tools
The following tools are exposed by the MCP server:
get_account_info: Get account information and balancesearch_markets: Search for markets/instruments (supports both search terms and epic codes)get_prices: Get current prices with configurable time resolution (MINUTE, HOUR, DAY, etc.)get_historical_prices: Get historical price data with custom time ranges and resolutionget_positions: Get all open trading positionscreate_position: Create a new trading position (buy/sell) with optional stop loss and take profitclose_position: Close an open position by deal IDupdate_position: Update position stop loss or take profit levelsget_watchlists: Get all saved watchlists
✨ Key Features
- Automatic Authentication: Handles login and session token refresh automatically
- Enhanced Search: Search markets by name or use specific epic codes (e.g., "Apple" or "AAPL")
- Multiple Time Resolutions: MINUTE, HOUR, DAY, WEEK for price data
- Robust Error Handling: Built-in retry logic for expired sessions
- No Manual Auth: No separate authentication tool needed - handled behind the scenes
Configuration
Required Environment Variables
The MCP server requires the following environment variables:
CAPITAL_BASE_URL: The Capital.com API base URL (e.g.,https://demo-api-capital.backend-capital.com)CAPITAL_API_KEY: Your Capital.com API keyCAPITAL_PASSWORD: Your Capital.com passwordCAPITAL_IDENTIFIER: Your Capital.com email/identifier
Optional Environment Variables
CAPITAL_MCP_DEBUG: Set to1to enable debug loggingFASTMCP_LOG_LEVEL: Set toDEBUG,INFO,WARNING,ERROR, orCRITICALto control logging level
Installation & Setup
Install via pip
pip install capital-com-mcp-server
Running Manually
# Run with stdio transport (default)
capital-com-mcp-server
# Run with debug logging
capital-com-mcp-server --debug
# Get help with all options
capital-com-mcp-server --help
Example Usage
Searching for Markets
You: Search for Apple stock on Capital.com
AI: I'll search for Apple stock on Capital.com for you.
[Uses search_markets tool]
I found Apple Inc. (AAPL) on Capital.com. Here are the details:
- Epic: AAPL
- Market name: Apple Inc.
- Current bid price: $184.25
- Current ask price: $184.30
- Market status: OPEN
Getting Historical Price Data
You: Show me Tesla's daily price data for the last week
AI: I'll get Tesla's daily price data for you.
[Uses get_prices with epic="TSLA" and resolution="DAY"]
Tesla (TSLA) daily prices:
- Day 1: Open $248.50, Close $252.30, High $254.80, Low $247.90
- Day 2: Open $252.30, Close $249.75, High $253.20, Low $248.40
- Volume and price trends show recent volatility
Getting Account Information
You: What's my account balance on Capital.com?
AI: Let me check your Capital.com account information.
[Uses get_account_info tool]
Your Capital.com account information:
- Account ID: ABC123456
- Account type: Demo
- Currency: USD
- Balance: $10,000.00
- Available funds: $9,500.00
- Margin used: $500.00
Creating a Position
You: Buy 10 shares of Apple stock
AI: I'll create a buy position for Apple stock on Capital.com.
[Uses create_position tool]
Successfully created a BUY position for Apple Inc. (AAPL):
- Deal ID: DEF789012
- Size: 10 shares
- Opening price: $184.30
- Position status: OPEN
Prerequisites for using with LLMs
Make sure you have uv installed on your system:
curl -LsSf https://astral.sh/uv/install.sh | sh
Using with Amazon Q
-
Create an
mcp.jsonconfiguration file in your Amazon Q configuration directory (~/.aws/amazonq/mcp.json):{ "mcpServers": { "capital-com-mcp-server": { "command": "uvx", "args": ["capital-com-mcp-server"], "env": { "CAPITAL_BASE_URL": "https://demo-api-capital.backend-capital.com", "CAPITAL_API_KEY": "your_api_key_here", "CAPITAL_PASSWORD": "your_password_here", "CAPITAL_IDENTIFIER": "your_email@example.com", "FASTMCP_LOG_LEVEL": "ERROR" } } } }
-
Run Amazon Q with:
q chat -
Amazon Q will automatically start the MCP server and connect to it.
Using with Claude Desktop
-
In Claude Desktop, go to Settings > Developer section and click on "Edit Config"
-
This will open the configuration file. Add the following to the JSON:
{ "mcpServers": { "capital-com-mcp-server": { "command": "uvx", "args": ["capital-com-mcp-server"], "env": { "CAPITAL_BASE_URL": "https://demo-api-capital.backend-capital.com", "CAPITAL_API_KEY": "your_api_key_here", "CAPITAL_PASSWORD": "your_password_here", "CAPITAL_IDENTIFIER": "your_email@example.com", "FASTMCP_LOG_LEVEL": "ERROR" } } } }
Resources
Project details
Release history Release notifications | RSS feed
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 capital_com_mcp_server-0.1.8.1.tar.gz.
File metadata
- Download URL: capital_com_mcp_server-0.1.8.1.tar.gz
- Upload date:
- Size: 12.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
08a4f3a2aa6b78f1932fd252835ecd2122e082320eafe93b6eec5015ff68ba10
|
|
| MD5 |
893c1de1d6798dada7b94d30c77cf4b0
|
|
| BLAKE2b-256 |
92ba8a7cbf8fb30da1d0f3a9e109895321d121f40dcf8118a78c31d526e56fab
|
Provenance
The following attestation bundles were made for capital_com_mcp_server-0.1.8.1.tar.gz:
Publisher:
python-publish.yml on syedair/mcp-servers
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
capital_com_mcp_server-0.1.8.1.tar.gz -
Subject digest:
08a4f3a2aa6b78f1932fd252835ecd2122e082320eafe93b6eec5015ff68ba10 - Sigstore transparency entry: 233036893
- Sigstore integration time:
-
Permalink:
syedair/mcp-servers@219b34f6d62f6ca45bfac18157c44dd7fc45eb7a -
Branch / Tag:
refs/tags/v0.1.8.1 - Owner: https://github.com/syedair
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@219b34f6d62f6ca45bfac18157c44dd7fc45eb7a -
Trigger Event:
release
-
Statement type:
File details
Details for the file capital_com_mcp_server-0.1.8.1-py3-none-any.whl.
File metadata
- Download URL: capital_com_mcp_server-0.1.8.1-py3-none-any.whl
- Upload date:
- Size: 14.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
71df38ddb5ac4076a3b3e31290dd6e6a2af11eb0e49190c113d8570c7123f8fa
|
|
| MD5 |
618a8d9727f1a55cee42bd0a8c879a4b
|
|
| BLAKE2b-256 |
6080a82ff58e7874cafedea60ab30a19292e7e7eb843afe5fab3bc63c4120958
|
Provenance
The following attestation bundles were made for capital_com_mcp_server-0.1.8.1-py3-none-any.whl:
Publisher:
python-publish.yml on syedair/mcp-servers
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
capital_com_mcp_server-0.1.8.1-py3-none-any.whl -
Subject digest:
71df38ddb5ac4076a3b3e31290dd6e6a2af11eb0e49190c113d8570c7123f8fa - Sigstore transparency entry: 233036920
- Sigstore integration time:
-
Permalink:
syedair/mcp-servers@219b34f6d62f6ca45bfac18157c44dd7fc45eb7a -
Branch / Tag:
refs/tags/v0.1.8.1 - Owner: https://github.com/syedair
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@219b34f6d62f6ca45bfac18157c44dd7fc45eb7a -
Trigger Event:
release
-
Statement type: