IG Trading MCP
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@IG Trading MCP show me my open positions"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
ig-trading-mcp
A modern Node.js client for IG Trading API with built-in MCP (Model Context Protocol) server for AI integration. Trade forex, indices, commodities and more through IG's REST API, now with AI assistant support.
โจ Features
๐ค MCP Server - 21 tools for AI assistants (Claude, Cursor, etc.)
๐ Complete IG REST API - Trading, positions, orders, market data
๐ Enterprise Security - RSA encryption, rate limiting, audit logging
๐ Modern JavaScript - ES modules, async/await, full TypeScript support
๐ก๏ธ Battle-tested - Production-ready with comprehensive error handling
Related MCP server: IBKR MCP Server
๐ Quick Start
Install & Run with npx (no installation needed)
# Run directly with npx
npx ig-trading-mcp serve --api-key YOUR_KEY --identifier YOUR_ID --password YOUR_PWD
# Or install globally
npm install -g ig-trading-mcp
ig-trading-mcp serveBasic Setup
Initialize configuration:
npx ig-trading-mcp initEdit
.envwith your IG credentials:
IG_API_KEY=your_api_key_here
IG_IDENTIFIER=your_username_here
IG_PASSWORD=your_password_here
IG_DEMO=trueTest connection:
npx ig-trading-mcp testStart MCP server for AI tools:
npx ig-trading-mcp serve๐ฏ Usage Examples
Command Line Interface
# Start MCP server with credentials
npx ig-trading-mcp serve \
--api-key YOUR_API_KEY \
--identifier YOUR_USERNAME \
--password YOUR_PASSWORD \
--demo true
# Test account connection
npx ig-trading-mcp test
# List available tools
npx ig-trading-mcp tools
# Initialize config files
npx ig-trading-mcp initAs a Node.js Library
import { IGService } from 'ig-trading-mcp';
const ig = new IGService({
apiKey: 'YOUR_API_KEY',
identifier: 'YOUR_USERNAME',
password: 'YOUR_PASSWORD',
isDemo: true
});
// Login
await ig.login();
// Get accounts
const accounts = await ig.getAccounts();
console.log('Balance:', accounts.accounts[0].balance);
// Search markets
const markets = await ig.searchMarkets('EUR/USD');
// Create position
const position = await ig.createPosition({
epic: 'CS.D.EURUSD.CFD.IP',
direction: 'BUY',
size: 1,
orderType: 'MARKET',
guaranteedStop: false,
forceOpen: true
});
// Get positions
const positions = await ig.getPositions();
// Close position
await ig.closePosition(position.dealId);
// Logout
await ig.logout();๐ค AI Integration (MCP)
Configure with Claude Desktop
Add to ~/Library/Application Support/Claude/claude_desktop_config.json:
{
"mcpServers": {
"ig-trading": {
"command": "npx",
"args": ["ig-trading-mcp", "serve"],
"env": {
"IG_API_KEY": "your_api_key",
"IG_IDENTIFIER": "your_username",
"IG_PASSWORD": "your_password",
"IG_DEMO": "true"
}
}
}
}Configure with Cursor
Add to .cursor/mcp.json in your project:
{
"mcpServers": {
"ig-trading": {
"command": "npx",
"args": ["ig-trading-mcp", "serve"],
"env": {
"IG_API_KEY": "${IG_API_KEY}",
"IG_IDENTIFIER": "${IG_IDENTIFIER}",
"IG_PASSWORD": "${IG_PASSWORD}",
"IG_DEMO": "true"
}
}
}
}Available MCP Tools (21)
Account Management (5)
ig_login- Authenticate with IGig_logout- End sessionig_get_accounts- List all accountsig_switch_account- Change active accountig_get_account_activity- View account history
Position Management (5)
ig_get_positions- View open positionsig_create_position- Open new positionig_update_position- Modify positionig_close_position- Close specific positionig_close_all_positions- Close all positions
Order Management (3)
ig_get_working_orders- View pending ordersig_create_working_order- Place new orderig_delete_working_order- Cancel order
Market Data (4)
ig_search_markets- Search tradeable marketsig_get_market_details- Get market infoig_get_historical_prices- Historical dataig_get_client_sentiment- Market sentiment
Watchlists (4)
ig_get_watchlists- View all watchlistsig_get_watchlist- Get specific watchlistig_create_watchlist- Create watchlistig_add_to_watchlist- Add market to list
๐ Security Features
RSA Encryption - Password encryption using pidCrypt (IG-compatible)
Secure Storage - Credentials encrypted with AES-256-GCM
Rate Limiting - Automatic throttling (60 req/min)
Audit Logging - Track all operations
Session Management - JWT tokens with auto-refresh
Input Validation - Joi schemas for all inputs
๐ Project Structure
ig-trading-mcp/
โโโ bin/
โ โโโ cli.js # CLI entry point
โโโ src/
โ โโโ core/ # Core modules
โ โ โโโ api-client.js # HTTP client
โ โ โโโ config.js # Configuration
โ โ โโโ encryption.cjs # RSA encryption
โ โโโ services/ # Business logic
โ โ โโโ ig-service.js # Main IG API
โ โ โโโ mcp-service.js # MCP server
โ โโโ security/ # Security layer
โ โโโ indicators/ # Trading indicators
โโโ examples/ # Usage examples
โโโ scripts/ # Utility scripts
โโโ package.json๐ ๏ธ API Reference
Account Methods
await ig.login(useEncryption = true)
await ig.logout()
await ig.getAccounts()
await ig.switchAccount(accountId)
await ig.getAccountActivity(options)Trading Methods
await ig.getPositions()
await ig.createPosition(ticket)
await ig.updatePosition(dealId, updates)
await ig.closePosition(dealId)
await ig.closeAllPositions()Order Methods
await ig.getWorkingOrders()
await ig.createWorkingOrder(ticket)
await ig.deleteWorkingOrder(dealId)Market Data Methods
await ig.searchMarkets(searchTerm)
await ig.getMarketDetails(epics)
await ig.getHistoricalPrices(epic, resolution, options)
await ig.getClientSentiment(marketIds)๐ Requirements
Node.js 18.0.0 or higher
IG Trading Account (demo or live)
API Key from IG (get from My IG > Settings > API keys)
๐งช Testing
# Test connection
npm test
# Test with credentials
npm run test:account๐ค Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Fork the repository
Create your feature branch (
git checkout -b feature/AmazingFeature)Commit your changes (
git commit -m 'Add some AmazingFeature')Push to the branch (
git push origin feature/AmazingFeature)Open a Pull Request
๐๏ธ Built On
This project is built on top of gfiocco/node-ig-api, enhancing it with:
Modern ES modules and async/await patterns
MCP (Model Context Protocol) server for AI integration
Enhanced security with RSA encryption
CLI interface for easy usage with npx
Comprehensive error handling and rate limiting
๐ License
This project is licensed under the MIT License - see the LICENSE file for details.
โ ๏ธ Disclaimer
This software is for educational purposes only. Trading CFDs carries risk and you could lose more than your initial deposit. Use at your own risk. The authors are not responsible for any financial losses incurred through use of this software.
๐ Resources
๐ Support
Issues: GitHub Issues
Discussions: GitHub Discussions
Made with โค๏ธ for the trading community
Available Tools
21 toolsig_add_to_watchlistC
Add an epic to a watchlist
Inputs: epic (required), watchlistId (required).
ig_close_all_positionsB
Close all open positions
Inputs: no named parameters.
ig_close_positionC
Close an open position
Inputs: dealId (required).
ig_create_positionC
Create a new trading position
Inputs: currencyCode (required), direction (required), epic (required), expiry (required), +8 more.
ig_create_watchlistC
Create a new watchlist
Inputs: name (required), epics.
ig_create_working_orderD
Create a working order
Inputs: currencyCode (required), direction (required), epic (required), expiry (required), +9 more.
ig_delete_working_orderC
Delete a working order
Inputs: dealId (required).
ig_get_account_activityC
Get account activity history
Inputs: detailed, from, pageSize, to.
ig_get_accountsB
Get list of all trading accounts
Inputs: no named parameters.
ig_get_client_sentimentC
Get client sentiment for markets
Inputs: marketIds (required).
ig_get_historical_pricesC
Get historical price data
Inputs: epic (required), resolution (required), from, max, +1 more.
ig_get_market_detailsC
Get detailed information about a market
Inputs: epics (required).
ig_get_positionsB
Get all open positions
Inputs: no named parameters.
ig_get_watchlistC
Get details of a specific watchlist
Inputs: watchlistId (required).
ig_get_watchlistsC
Get all watchlists
Inputs: no named parameters.
ig_get_working_ordersC
Get all working orders
Inputs: no named parameters.
ig_loginC
Login to IG Trading account
Inputs: apiKey, identifier, isDemo, password, +1 more.
ig_logoutB
Logout from IG Trading account
Inputs: no named parameters.
ig_search_marketsC
Search for tradeable markets
Inputs: searchTerm (required).
ig_switch_accountC
Switch to a different trading account
Inputs: accountId (required).
ig_update_positionC
Update stop/limit levels for an open position
Inputs: dealId (required), limitLevel, stopLevel, trailingStop, +1 more.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelogโฆ
TDQS
Scored across 21 tools
Each tool has a clearly distinct purpose targeting specific resources and actions in the IG Trading domain. For example, create_position vs. update_position vs. close_position handle different stages of position lifecycle, while get_watchlist vs. get_watchlists differentiate singular vs. plural operations. No tools appear to overlap or cause confusion.
All tools follow a consistent 'ig_verb_noun' pattern with snake_case throughout. The naming convention is highly predictable, making it easy to understand each tool's function at a glance. This uniformity supports clear agent selection and reduces cognitive load.
With 21 tools, the count is slightly high but reasonable for a comprehensive trading platform covering accounts, positions, watchlists, orders, markets, and authentication. It provides full coverage without being excessively bloated, though it borders on the upper limit of typical well-scoped servers.
The toolset offers complete CRUD/lifecycle coverage for all core trading domain entities: positions (create, update, close, get), watchlists (create, add to, get, list), working orders (create, delete, get), accounts (get, switch, activity), and markets (search, details, prices, sentiment). Authentication (login/logout) is also included, leaving no obvious gaps for agent workflows.
Maintenance
Related MCP Connectors
Manage MetaTrader 4 and 5 trade copying from your AI agent: list your connected accounts, set up copiers, add followers with their own rules, pause and resume copying, and read what the copier did. Tool calls need an Algo Trader Tools API key in the X-API-Key header, and a key lists only the tools its scopes allow.
Read-only access to your MetaTrader 4 and 5 accounts for AI agents: balances, open positions, trade history with win rate, live quotes, symbol specs and candles. It cannot place, modify or close orders.
Live crypto + IDX stock market intelligence for AI agents โ 19 tools, no API key.
Live stock quotes, a stock screener, crypto prices and FX rates as agent tools.
Related MCP Servers
- AlicenseBqualityCmaintenanceEnables AI assistants to interact with Interactive Brokers trading accounts to retrieve market data, check positions, and place trades. Includes pre-configured IB Gateway and handles OAuth authentication automatically.14161 npm228MIT
- AlicenseNot gradedqualityDmaintenanceProvides AI models with secure access to Interactive Brokers trading data and functionality, enabling account management, market data retrieval, and trading operations through natural language interactions.18MIT
- AlicenseAqualityDmaintenanceEnables AI assistants to interact with Trading 212 investment accounts for portfolio tracking, account management, and real-time order execution. It supports managing investment pies, analyzing historical data, and monitoring market performance across multiple instrument types.232MIT
- AlicenseBqualityCmaintenanceProvides tools for interacting with Interactive Brokers Gateway to access market data, account summaries, and portfolio positions. It enables users to perform contract lookups, retrieve historical OHLCV bars, and view real-time quotes through natural language interfaces.649 PyPI3PolyForm Noncommercial 1.0.0