Skip to main content

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:

  • authenticate: Authenticate with Capital.com API
  • get_account_info: Get account information
  • search_markets: Search for markets (e.g., EURUSD, AAPL)
  • get_prices: Get prices for a specific instrument
  • get_positions: Get all open positions
  • create_position: Create a new trading position
  • close_position: Close an open position
  • update_position: Update an existing position (stop loss, take profit)
  • get_watchlists: Get all watchlists

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 key
  • CAPITAL_PASSWORD: Your Capital.com password
  • CAPITAL_IDENTIFIER: Your Capital.com email/identifier

Optional Environment Variables

  • CAPITAL_MCP_DEBUG: Set to 1 to enable debug logging
  • FASTMCP_LOG_LEVEL: Set to DEBUG, INFO, WARNING, ERROR, or CRITICAL to control logging level

Running Manually

You can run the MCP server manually with various options:

capital-com-mcp-server --help

Available options:

  • --sse: Use SSE transport
  • --port PORT: Port to run the server on (default: 8080)
  • --debug: Enable debug logging
  • --log-dir LOG_DIR: Directory to store log files

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 capital-com-mcp-server___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 Account Information

You: What's my account balance on Capital.com?

AI: Let me check your Capital.com account information.

[Uses capital-com-mcp-server___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 capital-com-mcp-server___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

  1. Create an mcp.json configuration 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"
          }
        }
      }
    }
    
  2. Run Amazon Q with:

    q chat
    
  3. Amazon Q will automatically start the MCP server and connect to it.

Using with Claude Desktop

  1. In Claude Desktop, go to Settings > Developer section and click on "Edit Config"

  2. 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

capital_com_mcp_server-0.1.7.2.tar.gz (9.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

capital_com_mcp_server-0.1.7.2-py3-none-any.whl (11.1 kB view details)

Uploaded Python 3

File details

Details for the file capital_com_mcp_server-0.1.7.2.tar.gz.

File metadata

File hashes

Hashes for capital_com_mcp_server-0.1.7.2.tar.gz
Algorithm Hash digest
SHA256 5eebca265183dcc13bc6b4fbc481367872e7162840ec78268c0c4d3305537e09
MD5 4c7af3c7c0e45ccdbf4dff8ae6bf2169
BLAKE2b-256 714f62d6090953d49a12869d9f4bc4070f3cdfc549ea5e5b0e73e99ea4ecdcd4

See more details on using hashes here.

Provenance

The following attestation bundles were made for capital_com_mcp_server-0.1.7.2.tar.gz:

Publisher: python-publish.yml on syedair/mcp-servers

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file capital_com_mcp_server-0.1.7.2-py3-none-any.whl.

File metadata

File hashes

Hashes for capital_com_mcp_server-0.1.7.2-py3-none-any.whl
Algorithm Hash digest
SHA256 8b6ae7645c11769ba7951b2ff16537364c2af655e4e43dd2b8633fb3bcfd5444
MD5 a6d12e034498db0029ac47bc9a4dcb14
BLAKE2b-256 bf4eddc20c49ef3387fcfebe91e2f2988f300da8f1c249ca98f24c17b94f661b

See more details on using hashes here.

Provenance

The following attestation bundles were made for capital_com_mcp_server-0.1.7.2-py3-none-any.whl:

Publisher: python-publish.yml on syedair/mcp-servers

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page