modelscope·@kea0811/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.
# 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 serve
npx ig-trading-mcp init
.env with your IG credentials:IG_API_KEY=your_api_key_here
IG_IDENTIFIER=your_username_here
IG_PASSWORD=your_password_here
IG_DEMO=true
npx ig-trading-mcp test
npx ig-trading-mcp serve
# 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 init
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();
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"
}
}
}
}
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"
}
}
}
}
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 historyPosition 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 positionsOrder Management (3)
ig_get_working_orders - View pending ordersig_create_working_order - Place new orderig_delete_working_order - Cancel orderMarket Data (4)
ig_search_markets - Search tradeable marketsig_get_market_details - Get market infoig_get_historical_prices - Historical dataig_get_client_sentiment - Market sentimentWatchlists (4)
ig_get_watchlists - View all watchlistsig_get_watchlist - Get specific watchlistig_create_watchlist - Create watchlistig_add_to_watchlist - Add market to listig-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
await ig.login(useEncryption = true)
await ig.logout()
await ig.getAccounts()
await ig.switchAccount(accountId)
await ig.getAccountActivity(options)
##…