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
| Name | Required | Description | Default |
|---|---|---|---|
| replyId | Yes | ||
| messageIds | Yes |
Implementation Reference
- src/tool-handlers.ts:507-536 (handler)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), }, ], }; } }
- src/tool-definitions.ts:48-51 (schema)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) );
- src/ib-client.ts:467-490 (helper)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); } }