ctrader-mcp-server
cTrader MCP Server
A standalone Model Context Protocol (MCP) server that enables AI assistants to interact with the cTrader trading platform.
🚀 What is This?
This MCP server allows AI assistants like Claude to execute trades, analyze markets, and manage positions on cTrader through natural language conversations.
Example conversations:
"Show me my account balance" → Gets balance, equity, positions
"Buy 0.01 lots of EURUSD with stop at 1.08" → Places trade
"Calculate RSI for GBPUSD" → Analyzes technical indicators
"Close all losing positions" → Manages risk
✨ Features
Trading Operations
✅ Market Orders - Execute immediately at current price
✅ Limit Orders - Order at specific price level
✅ Stop Orders - Stop-loss or stop-entry orders
✅ Position Management - Close positions fully or partially
✅ Order Management - Cancel pending orders
Market Data & Analysis
✅ Historical Data - OHLCV candles (9 timeframes: M1, M5, M15, M30, H1, H4, D1, W1, MN1)
✅ Technical Indicators - RSI, MACD, EMA, SMA, Bollinger Bands, ATR, Stochastic
✅ Real-time Ticks - Subscribe to live price feeds
✅ Symbol Search - Browse 100+ trading instruments
Account Information
✅ Account Status - Balance, equity, margin, free margin
✅ Position Tracking - All open positions with P&L
✅ Order Tracking - All pending orders
✅ P&L Analysis - Detailed profit/loss breakdown
🎯 Available Tools (14 Total)
Tool | Description |
| View balance, equity, margin, and P&L |
| List all open positions with details |
| Show all pending limit/stop orders |
| Get detailed P&L breakdown |
| Execute trade at current market price |
| Place order at specific price |
| Place stop-loss or stop-entry order |
| Close position fully or partially |
| Cancel a pending order |
| Browse available trading instruments |
| Get OHLCV candlestick data |
| Calculate technical indicators |
| Subscribe to real-time price updates |
| Unsubscribe from price updates |
📋 Prerequisites
Python 3.10 or higher
A cTrader account (demo or live)
cTrader API credentials
🔧 Installation
1. Get cTrader API Credentials
Create an application to get:
CLIENT_IDCLIENT_SECRET
Generate an access token:
ACCESS_TOKEN
Find your account ID in cTrader:
ACCOUNT_ID
2. Install the Server
# Clone or download this repository
cd ctrader-mcp-server
# Run installation script
./install.sh3. Configure Credentials
Create a .env file in the project root:
CLIENT_ID=your_client_id_here
CLIENT_SECRET=your_client_secret_here
ACCESS_TOKEN=your_access_token_here
ACCOUNT_ID=your_account_id_here
HOST=demoImportant: Use HOST=demo for testing!
4. Test the Server
# Activate virtual environment
source venv/bin/activate
# Run tests
python test_server.pyYou should see:
✓ Bot initialized and authenticated
✓ Account status retrieved
✓ Found X EUR symbols
...
All Tests Completed Successfully! ✓🤖 Configure AI Assistant
Claude Desktop
Find your config file:
macOS:
~/Library/Application Support/Claude/claude_desktop_config.jsonWindows:
%APPDATA%\Claude\claude_desktop_config.jsonLinux:
~/.config/Claude/claude_desktop_config.json
Add this configuration:
{
"mcpServers": {
"ctrader": {
"command": "/absolute/path/to/ctrader-mcp-server/venv/bin/python",
"args": [
"/absolute/path/to/ctrader-mcp-server/server.py"
],
"cwd": "/absolute/path/to/ctrader-mcp-server"
}
}
}Restart Claude Desktop
Other MCP Clients
This server implements the standard MCP protocol and should work with any MCP-compatible client.
💬 Example Conversations
Once configured, you can interact naturally:
Check Account:
You: "How much money do I have in my cTrader account?"
AI: "Your account has a balance of $10,000, equity of $10,250, with 3 open positions generating a total P&L of +$250."
Place Trade:
You: "Buy 0.01 lots of EURUSD with stop loss at 1.08 and take profit at 1.10"
AI: "Order executed! Bought 0.01 lots of EURUSD at 1.09245 with stop loss at 1.08000 and take profit at 1.10000."
Analyze Market:
You: "Calculate the RSI for GBPUSD on the 15-minute chart"
AI: "GBPUSD RSI(14) on M15 is currently at 65.3, indicating the pair is approaching overbought territory."
Manage Risk:
You: "Close all positions that are losing more than $50"
AI: "Found 1 position losing more than $50. Closed GBPUSD position (loss: -$62.50)."
📚 Documentation
Quick Start Guide - Get started in 5 minutes
Complete Guide - Comprehensive reference
Architecture - Technical details
Configuration - Setup options
API Reference - All tools documented
🔐 Security & Safety
Demo vs Live Trading
Default configuration uses demo accounts
Explicitly set
HOST=livein.envfor live tradingAlways test thoroughly on demo before going live
Risk Management
All orders support stop-loss and take-profit
Position closing can be partial or full
Volume is specified in lots (0.01 = micro lot)
Credentials Security
Credentials stored in
.envfile (never committed)Environment variables never exposed in logs
Authentication state validated before operations
🚨 Important Warnings
⚠️ Trading involves significant risk. You can lose money.
⚠️ Always test on demo accounts first
⚠️ Start with small positions when going live
⚠️ Use stop losses to limit risk
⚠️ Never share your credentials or access tokens
🛠️ Development
Project Structure
ctrader-mcp-server/
├── server.py # Main MCP server
├── ctrader_bot.py # cTrader API wrapper
├── test_server.py # Testing tool
├── install.sh # Installation script
├── requirements.txt # Python dependencies
├── .env.example # Environment template
├── README.md # This file
└── docs/ # Documentation
├── QUICKSTART.md
├── GUIDE.md
├── ARCHITECTURE.md
├── CONFIGURATION.md
└── API.mdRunning Tests
# Basic functionality test
python test_server.py
# Run with specific account
ACCOUNT_ID=12345 python test_server.py
# Test with live account (careful!)
HOST=live python test_server.pyAdding New Tools
To add new tools:
Add tool definition in
server.pyhandle_list_tools()Implement handler in
_execute_tool()Add corresponding method to
ctrader_bot.pyif neededUpdate documentation
📊 Performance
Startup Time: 5-10 seconds (authentication + symbol loading)
Order Execution: <100ms (market orders)
Historical Data: 1-5 seconds (100 candles)
Indicator Calculation: <1 second
Memory Usage: ~50-100 MB
🌐 Rate Limits
cTrader API enforces:
50 requests/second for trading operations
5 requests/second for historical data
The server automatically respects these limits.
🐛 Troubleshooting
"Bot not ready" errors
Check
.envfile credentialsVerify internet connection
Ensure cTrader account is active
Check server logs for authentication errors
Symbol not found
Use
list_symbolstool to see available symbolsSymbol names are case-sensitive
Different brokers may have different symbol names
Order rejected
Check account balance and margin
Verify symbol is tradable
Ensure volume meets minimum requirements
Check if market is open
Connection issues
Verify API credentials are correct
Check if account is active
Ensure no firewall blocking port 5035 (demo) or 5034 (live)
🔗 Resources
📄 License
MIT License - See LICENSE file for details
⚖️ Disclaimer
This software is provided "as is" without warranty of any kind. Trading involves significant risk and you can lose money. Use at your own risk. Always test on demo accounts before live trading.
🤝 Contributing
Contributions are welcome! Please:
Fork the repository
Create a feature branch
Make your changes
Add tests if applicable
Submit a pull request
📧 Support
📖 Check the documentation
🐛 Report issues on GitHub
💬 Join cTrader Community
Made with ❤️ for algorithmic traders
Ready to start? Run ./install.sh and follow the instructions above!
This server cannot be installed
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
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/akinabudu/ctrader-mcp-server'
If you have feedback or need assistance with the MCP directory API, please join our Discord server