Skip to main content
Glama
code-rabi

Interactive Brokers MCP Server

by code-rabi

activate_alert

Activate a previously created trading alert in Interactive Brokers by specifying account and alert IDs to monitor market conditions.

Instructions

Activate a previously created alert. Usage: { "accountId": "<id>", "alertId": "<alertId>" }.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
accountIdYes
alertIdYes

Implementation Reference

  • The primary handler function for the 'activate_alert' tool. It ensures the IB Gateway is ready and authenticated if needed, calls the IB client to perform the activation, and returns the result as JSON or formats any errors.
    async activateAlert(input: ActivateAlertInput): 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.activateAlert(input.accountId, input.alertId);
        return {
          content: [
            {
              type: "text",
              text: JSON.stringify(result, null, 2),
            },
          ],
        };
      } catch (error) {
        return {
          content: [
            {
              type: "text",
              text: this.formatError(error),
            },
          ],
        };
      }
  • src/tools.ts:126-131 (registration)
    Registers the 'activate_alert' tool with the MCP server, providing the name, description, input schema, and handler reference.
    // Register activate_alert tool
    server.tool(
      "activate_alert",
      "Activate a previously created alert. Usage: `{ \"accountId\": \"<id>\", \"alertId\": \"<alertId>\" }`.",
      ActivateAlertZodShape,
      async (args) => await handlers.activateAlert(args)
  • Defines the Zod shape for the 'activate_alert' tool input validation, specifying accountId and alertId as required strings. Referenced in registration and used to derive the full schema and TypeScript type.
    export const ActivateAlertZodShape = {
      accountId: z.string(),
      alertId: z.string()
    };
  • The IB client method that makes the actual HTTP POST request to Interactive Brokers' API endpoint to activate the specified alert for the account.
    async activateAlert(accountId: string, alertId: string): Promise<any> {
      try {
        Logger.log(`[ALERT] Activating alert ${alertId} for account ${accountId}`);
        
        const response = await this.client.post(
          `/iserver/account/${accountId}/alert/activate`,
          { alertId }
        );
    
        Logger.log("[ALERT] Alert activation response:", response.data);
        return response.data;
      } catch (error) {
        Logger.error("[ALERT] Failed to activate alert:", error);
        
        // Check if this is likely an authentication error
        if (this.isAuthenticationError(error)) {
          const authError = new Error("Authentication required to activate alerts. Please authenticate with Interactive Brokers first.");
          (authError as any).isAuthError = true;
          throw authError;
        }
        
        throw new Error("Failed to activate alert: " + (error as any).message);
      }
    }
Behavior2/5

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

With no annotations provided, the description carries full burden but offers minimal behavioral insight. It implies a mutation ('Activate') but doesn't disclose permissions needed, side effects, error conditions, or what 'activation' entails (e.g., enabling notifications, changing alert status). This leaves significant gaps for a tool that likely modifies system state.

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

Conciseness5/5

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

The description is extremely concise—two sentences with zero waste. It front-loads the purpose and follows with a usage example, making it easy to parse. Every word serves a clear function, though this brevity comes at the cost of completeness.

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 the complexity (a mutation tool with no annotations, 2 parameters, 0% schema coverage, and no output schema), the description is inadequate. It lacks crucial context: what activation does, prerequisites, error handling, and return values. For a tool that likely changes alert states in a financial/trading context, this leaves too many unknowns.

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

Parameters3/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, but it only provides a usage example without explaining parameter meanings. It doesn't clarify what 'accountId' or 'alertId' represent, their formats, or where to obtain them. The baseline is 3 because the schema covers the parameters structurally, but the description adds minimal semantic value.

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 ('Activate') and resource ('a previously created alert'), making the purpose specific and understandable. However, it doesn't explicitly differentiate from sibling tools like 'create_alert' or 'delete_alert', which would require mentioning that this tool only works on existing alerts rather than creating new ones.

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 doesn't mention prerequisites (e.g., needing an existing alert created via 'create_alert'), exclusions, or contextual factors. The usage example is purely syntactic and doesn't offer decision-making help.

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