ig_switch_account
Switch to a different trading account on IG Trading by specifying the account ID. Enables users to manage multiple accounts efficiently for forex, indices, and commodities trading.
Instructions
Switch to a different trading account
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| accountId | Yes | Account ID to switch to |
Input Schema (JSON Schema)
{
"properties": {
"accountId": {
"description": "Account ID to switch to",
"type": "string"
}
},
"required": [
"accountId"
],
"type": "object"
}
Implementation Reference
- src/services/ig-service.js:67-83 (handler)Core handler function that switches the IG trading account by sending a PUT request to '/session' endpoint with the accountId and updates the session tokens.async switchAccount(accountId) { try { const response = await this.apiClient.put('/session', { accountId }, 1); config.setSessionTokens({ 'x-security-token': response.headers['x-security-token'], cst: response.headers.cst, lightstreamerEndpoint: config.sessionTokens.lightstreamerEndpoint, currentAccountId: accountId }); logger.info(`Switched to account: ${accountId}`); return response.data; } catch (error) { logger.error('Account switch failed:', error.message); throw error; }
- src/services/mcp-service.js:100-113 (schema)Tool schema definition including input validation requiring 'accountId'.{ name: 'ig_switch_account', description: 'Switch to a different trading account', inputSchema: { type: 'object', properties: { accountId: { type: 'string', description: 'Account ID to switch to', }, }, required: ['accountId'], }, },
- src/services/mcp-service.js:567-576 (handler)MCP server dispatch handler that calls the igService.switchAccount method and formats the response.case 'ig_switch_account': const switchResult = await igService.switchAccount(args.accountId); return { content: [ { type: 'text', text: JSON.stringify(switchResult, null, 2), }, ], };
- src/services/mcp-service.js:506-509 (registration)Registers the list of tools including ig_switch_account by returning the TOOLS array in response to ListToolsRequest.server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools: TOOLS, };