Skip to main content
Glama
code-rabi

Interactive Brokers MCP Server

by code-rabi

get_account_info

Retrieve account details and current balances from Interactive Brokers trading accounts to monitor financial positions and track portfolio status.

Instructions

Get account information and balances. Usage: { "confirm": true }.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
confirmYes

Implementation Reference

  • The main MCP tool handler for get_account_info. Ensures gateway readiness and authentication, calls IBClient.getAccountInfo(), formats response as ToolHandlerResult.
    async getAccountInfo(input: GetAccountInfoInput): Promise<ToolHandlerResult> {
      try {
        // Ensure Gateway is ready
        await this.ensureGatewayReady();
        
        // Ensure authentication in headless mode
        if (this.context.config.IB_HEADLESS_MODE) {
          await this.ensureAuth();
        }
        
        const result = await this.context.ibClient.getAccountInfo();
        return {
          content: [
            {
              type: "text",
              text: JSON.stringify(result, null, 2),
            },
          ],
        };
      } catch (error) {
        return {
          content: [
            {
              type: "text",
              text: this.formatError(error),
            },
          ],
        };
      }
    }
  • src/tools.ts:49-55 (registration)
    MCP server tool registration for 'get_account_info', providing description, input schema, and handler reference.
    // Register get_account_info tool
    server.tool(
      "get_account_info",
      "Get account information and balances. Usage: `{ \"confirm\": true }`.",
      GetAccountInfoZodShape,
      async (args) => await handlers.getAccountInfo(args)
    );
  • Zod shape used for input validation of get_account_info tool (requires 'confirm: true'). Full schema and TypeScript type also defined nearby.
    export const GetAccountInfoZodShape = {
      confirm: z.literal(true)
    };
  • IBClient helper method implementing the core logic: fetches all portfolio accounts and their summary details via IB Gateway API endpoints.
    async getAccountInfo(): Promise<any> {
      Logger.log("[ACCOUNT-INFO] Starting getAccountInfo request...");
      try {
        Logger.log("[ACCOUNT-INFO] Fetching portfolio accounts...");
        const accountsResponse = await this.client.get("/portfolio/accounts");
        const accounts = accountsResponse.data;
        Logger.log(`[ACCOUNT-INFO] Found ${accounts?.length || 0} accounts:`, accounts);
    
        const result = {
          accounts: accounts,
          summaries: [] as any[]
        };
    
        Logger.log("[ACCOUNT-INFO] Processing account summaries...");
        for (let i = 0; i < accounts.length; i++) {
          const account = accounts[i];
          Logger.log(`[ACCOUNT-INFO] Processing account ${i + 1}/${accounts.length}: ${account.id}`);
          
          const summaryResponse = await this.client.get(
            `/portfolio/${account.id}/summary`
          );
          const summary = summaryResponse.data;
          Logger.log(`[ACCOUNT-INFO] Account ${account.id} summary:`, summary);
    
          result.summaries.push({
            accountId: account.id,
            summary: summary
          });
        }
    
        Logger.log(`[ACCOUNT-INFO] Completed processing ${result.summaries.length} accounts`);
        return result;
      } catch (error) {
        Logger.error("[ACCOUNT-INFO] Failed to get account info:", error);
        
        // Check if this is likely an authentication error
        if (this.isAuthenticationError(error)) {
          const authError = new Error("Authentication required to retrieve account information. Please authenticate with Interactive Brokers first.");
          (authError as any).isAuthError = true;
          throw authError;
        }
        
        throw new Error("Failed to retrieve account information");
      }
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden for behavioral disclosure. It mentions nothing about authentication requirements, rate limits, error conditions, or what specific information is returned. The 'Usage:' text shows parameter syntax but doesn't explain why confirmation is required or what happens during execution.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness3/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is brief but could be more front-loaded. The purpose statement is clear, but the 'Usage:' text feels like an afterthought rather than integrated guidance. It's concise but not optimally structured for agent comprehension.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a tool with no annotations, no output schema, and 0% schema description coverage, the description is inadequate. It doesn't explain what account information is returned, what format it comes in, whether authentication is required, or how this differs from similar sibling tools. The parameter guidance helps but doesn't compensate for the overall lack of context.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema has 0% description coverage, but the description compensates by showing the exact parameter syntax and value. While it doesn't explain why 'confirm' must be true or what this confirmation entails, it provides the necessary usage pattern that the schema alone doesn't convey.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb 'Get' and the resource 'account information and balances', making the purpose immediately understandable. It doesn't specifically differentiate from sibling tools like 'get_positions' or 'get_live_orders', but the resource focus is clear enough for basic understanding.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives like 'get_positions' or 'get_market_data'. The 'Usage:' text is actually parameter syntax guidance rather than contextual usage guidance, so this dimension remains weak.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/code-rabi/interactive-brokers-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server