Skip to main content
Glama
code-rabi

Interactive Brokers MCP Server

by code-rabi

get_alerts

Retrieve all trading alerts for a specific Interactive Brokers account to monitor account activity and trading notifications.

Instructions

Get all trading alerts for an account. Usage: { "accountId": "<id>" }.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
accountIdYes

Implementation Reference

  • Main tool handler for 'get_alerts': ensures prerequisites (gateway/auth), calls IBClient.getAlerts, returns formatted result or error.
    async getAlerts(input: GetAlertsInput): 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.getAlerts(input.accountId);
        return {
          content: [
            {
              type: "text",
              text: JSON.stringify(result, null, 2),
            },
          ],
        };
      } catch (error) {
        return {
          content: [
            {
              type: "text",
              text: this.formatError(error),
            },
          ],
        };
      }
  • src/tools.ts:110-116 (registration)
    MCP server.tool registration for 'get_alerts' tool with description, Zod shape, and handler reference.
    // Register get_alerts tool
    server.tool(
      "get_alerts",
      "Get all trading alerts for an account. Usage: `{ \"accountId\": \"<id>\" }`.",
      GetAlertsZodShape,
      async (args) => await handlers.getAlerts(args)
    );
  • Zod input shape for get_alerts: requires 'accountId' string. Used for validation in registration.
    export const GetAlertsZodShape = {
      accountId: z.string()
    };
  • IBClient helper method implementing the core API call to retrieve alerts via IB Gateway REST API.
    async getAlerts(accountId: string): Promise<any> {
      try {
        Logger.log(`[ALERT] Getting alerts for account ${accountId}`);
        
        const response = await this.client.get(
          `/iserver/account/${accountId}/alerts`
        );
    
        Logger.log("[ALERT] Get alerts response:", response.data);
        return response.data;
      } catch (error) {
        Logger.error("[ALERT] Failed to get alerts:", error);
        
        // Check if this is likely an authentication error
        if (this.isAuthenticationError(error)) {
          const authError = new Error("Authentication required to get alerts. Please authenticate with Interactive Brokers first.");
          (authError as any).isAuthError = true;
          throw authError;
        }
        
        throw new Error("Failed to get alerts: " + (error as any).message);
      }
Behavior2/5

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

No annotations are provided, so the description carries full burden. It states the tool retrieves alerts but lacks behavioral details such as whether it's read-only, requires authentication, has rate limits, returns paginated results, or includes error handling. The example usage adds minimal context but doesn't compensate for the missing annotations.

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

Conciseness4/5

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

The description is brief and front-loaded with the core purpose, followed by a usage example. Both sentences are relevant, with no wasted words, though the example could be integrated more smoothly. It efficiently conveys key information in a compact form.

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?

Given no annotations, 0% schema coverage, and no output schema, the description is incomplete. It covers the basic purpose and parameter example but lacks details on authentication needs, return format, error cases, or how it differs from siblings. For a tool with one required parameter and no structured support, more context is needed for effective use.

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

Parameters2/5

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

Schema description coverage is 0%, so the description must compensate. It mentions the 'accountId' parameter and provides an example format, adding some meaning beyond the bare schema. However, it doesn't explain what an accountId is, where to find it, or its expected format (e.g., numeric, alphanumeric), leaving significant gaps in parameter understanding.

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 resource ('trading alerts for an account'), making the purpose specific and understandable. It distinguishes from siblings like 'create_alert' or 'delete_alert' by focusing on retrieval, though it doesn't explicitly differentiate from other get_* tools like 'get_account_info' or 'get_market_data'.

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. It mentions the required parameter but offers no context about prerequisites, timing, or comparisons to siblings like 'get_account_info' or 'get_positions', leaving the agent to infer usage based on tool names alone.

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