Skip to main content
Glama
code-rabi

Interactive Brokers MCP Server

by code-rabi

confirm_order

Confirm pending Interactive Brokers orders that require manual approval before execution.

Instructions

Manually confirm an order that requires confirmation. Usage: { "replyId": "742a95a7-55f6-4d67-861b-2fd3e2b61e3c", "messageIds": ["o10151", "o10153"] }.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
replyIdYes
messageIdsYes

Implementation Reference

  • Main tool handler that ensures gateway readiness and authentication, calls IBClient.confirmOrder with input parameters, and returns formatted JSON response.
    async confirmOrder(input: ConfirmOrderInput): 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.confirmOrder(input.replyId, input.messageIds); return { content: [ { type: "text", text: JSON.stringify(result, null, 2), }, ], }; } catch (error) { return { content: [ { type: "text", text: this.formatError(error), }, ], }; } }
  • Zod shape definition for confirm_order input validation (replyId and messageIds). Used in registration and type inference.
    export const ConfirmOrderZodShape = { replyId: z.string(), messageIds: z.array(z.string()) };
  • src/tools.ts:102-108 (registration)
    Registers the confirm_order MCP tool with server.tool(), providing description, input schema, and handler reference.
    // Register confirm_order tool server.tool( "confirm_order", "Manually confirm an order that requires confirmation. Usage: `{ \"replyId\": \"742a95a7-55f6-4d67-861b-2fd3e2b61e3c\", \"messageIds\": [\"o10151\", \"o10153\"] }`.", ConfirmOrderZodShape, async (args) => await handlers.confirmOrder(args) );
  • Underlying IBClient method that POSTs to /iserver/reply/{replyId} with confirmed:true and messageIds to perform the actual order confirmation API call.
    async confirmOrder(replyId: string, messageIds: string[]): Promise<any> { try { Logger.log(`Confirming order with reply ID ${replyId} and message IDs:`, messageIds); const response = await this.client.post(`/iserver/reply/${replyId}`, { confirmed: true, messageIds: messageIds }); Logger.log("Order confirmation response:", response.data); return response.data; } catch (error) { Logger.error("Failed to confirm order:", error); // Check if this is likely an authentication error if (this.isAuthenticationError(error)) { const authError = new Error("Authentication required to confirm orders. Please authenticate with Interactive Brokers first."); (authError as any).isAuthError = true; throw authError; } throw new Error("Failed to confirm order: " + (error as any).message); } }

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