Skip to main content
Glama
code-rabi

Interactive Brokers MCP Server

by code-rabi

delete_alert

Remove trading alerts from your Interactive Brokers account by specifying account and alert IDs to manage notification settings.

Instructions

Delete an alert. Usage: { "accountId": "<id>", "alertId": "<alertId>" }.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
accountIdYes
alertIdYes

Implementation Reference

  • The main handler function for the delete_alert tool. Ensures gateway readiness and authentication, calls the IB client to delete the alert, and returns the result as JSON or formatted error.
    async deleteAlert(input: DeleteAlertInput): 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.deleteAlert(input.accountId, input.alertId);
        return {
          content: [
            {
              type: "text",
              text: JSON.stringify(result, null, 2),
            },
          ],
        };
      } catch (error) {
        return {
          content: [
            {
              type: "text",
              text: this.formatError(error),
            },
          ],
        };
      }
  • Zod schema definition for delete_alert input validation, including DeleteAlertZodShape and DeleteAlertZodSchema.
    export const DeleteAlertZodShape = {
      accountId: z.string(),
      alertId: z.string()
    };
    
    // Flex Query Zod Shapes
    export const GetFlexQueryZodShape = {
      queryId: z.string(),
      queryName: z.string().optional(), // Optional friendly name for auto-saving
      parseXml: z.boolean().optional().default(true)
    };
    
    export const ListFlexQueriesZodShape = {
      confirm: z.literal(true)
    };
    
    export const ForgetFlexQueryZodShape = {
      queryId: z.string()
    };
    
    // Full Zod Schemas (for validation if needed)
    export const AuthenticateZodSchema = z.object(AuthenticateZodShape);
    
    export const GetAccountInfoZodSchema = z.object(GetAccountInfoZodShape);
    
    export const GetPositionsZodSchema = z.object(GetPositionsZodShape);
    
    export const GetMarketDataZodSchema = z.object(GetMarketDataZodShape);
    
    export const PlaceOrderZodSchema = z.object(PlaceOrderZodShape).refine(
      (data) => {
        if (data.orderType === "LMT" && data.price === undefined) {
          return false;
        }
        if (data.orderType === "STP" && data.stopPrice === undefined) {
          return false;
        }
        return true;
      },
      {
        message: "LMT orders require price, STP orders require stopPrice",
        path: ["price", "stopPrice"]
      }
    );
    
    export const GetOrderStatusZodSchema = z.object(GetOrderStatusZodShape);
    
    export const GetLiveOrdersZodSchema = z.object(GetLiveOrdersZodShape);
    
    export const ConfirmOrderZodSchema = z.object(ConfirmOrderZodShape);
    
    export const GetAlertsZodSchema = z.object(GetAlertsZodShape);
    
    export const CreateAlertZodSchema = z.object(CreateAlertZodShape);
    
    export const ActivateAlertZodSchema = z.object(ActivateAlertZodShape);
    
    export const DeleteAlertZodSchema = z.object(DeleteAlertZodShape);
  • src/tools.ts:134-140 (registration)
    Registration of the delete_alert tool with the MCP server, linking to the handler and schema.
    // Register delete_alert tool
    server.tool(
      "delete_alert",
      "Delete an alert. Usage: `{ \"accountId\": \"<id>\", \"alertId\": \"<alertId>\" }`.",
      DeleteAlertZodShape,
      async (args) => await handlers.deleteAlert(args)
    );
  • IBClient helper method that performs the actual HTTP DELETE request to the IB Gateway API to delete the specified alert.
    async deleteAlert(accountId: string, alertId: string): Promise<any> {
      try {
        Logger.log(`[ALERT] Deleting alert ${alertId} for account ${accountId}`);
        
        const response = await this.client.delete(
          `/iserver/account/${accountId}/alert/${alertId}`
        );
    
        Logger.log("[ALERT] Alert deletion response:", response.data);
        return response.data;
      } catch (error) {
        Logger.error("[ALERT] Failed to delete alert:", error);
        
        // Check if this is likely an authentication error
        if (this.isAuthenticationError(error)) {
          const authError = new Error("Authentication required to delete alerts. Please authenticate with Interactive Brokers first.");
          (authError as any).isAuthError = true;
          throw authError;
        }
        
        throw new Error("Failed to delete alert: " + (error as any).message);
      }
    }
Behavior2/5

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

With no annotations, the description carries full burden but only states the action without behavioral details. It doesn't disclose if deletion is permanent, requires specific permissions, has side effects, or provides confirmation, which is inadequate for a destructive operation.

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 very concise with two sentences, front-loading the purpose and providing a usage example. There's no wasted text, though it could be more informative without sacrificing brevity.

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 destructive tool with no annotations, no output schema, and low schema coverage, the description is incomplete. It lacks details on behavior, outcomes, error handling, and integration with sibling tools, making it insufficient for safe and effective use.

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%, but the description adds minimal semantics by naming the parameters ('accountId' and 'alertId') and showing usage format. However, it doesn't explain what these IDs represent or their formats, leaving gaps despite the schema's lack of descriptions.

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

Purpose3/5

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

The description states the verb ('Delete') and resource ('an alert'), which is clear but basic. It doesn't differentiate from siblings like 'create_alert' or 'get_alerts' beyond the obvious action difference, lacking specificity about what type of alert or system context.

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?

No guidance is provided on when to use this tool versus alternatives. It doesn't mention prerequisites (e.g., needing an existing alert), exclusions, or compare to siblings like 'activate_alert' or 'create_alert', leaving usage context implied.

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