get_order_status
Retrieve the current status of a specific order using the order ID through the Interactive Brokers MCP Server, designed for efficient account interaction and order tracking.
Instructions
Get the status of a specific order
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| orderId | Yes | Order ID |
Implementation Reference
- src/tool-handlers.ts:444-473 (handler)Main handler function for get_order_status tool that ensures gateway readiness, handles authentication if needed, calls ibClient.getOrderStatus, and formats the result as ToolHandlerResult.async getOrderStatus(input: GetOrderStatusInput): 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.getOrderStatus(input.orderId); return { content: [ { type: "text", text: JSON.stringify(result, null, 2), }, ], }; } catch (error) { return { content: [ { type: "text", text: this.formatError(error), }, ], }; } }
- src/tool-definitions.ts:40-42 (schema)Zod shape definition for get_order_status input validation, requiring an orderId string. Used in tool registration.export const GetOrderStatusZodShape = { orderId: z.string() };
- src/tools.ts:85-91 (registration)MCP tool registration for get_order_status, linking name, description, schema, and handler.// Register get_order_status tool server.tool( "get_order_status", "Get the status of a specific order. Usage: `{ \"orderId\": \"12345\" }`.", GetOrderStatusZodShape, async (args) => await handlers.getOrderStatus(args) );
- src/ib-client.ts:492-508 (helper)Low-level IBClient method that makes the actual API call to retrieve order status by orderId via /iserver/account/orders/{orderId} endpoint.async getOrderStatus(orderId: string): Promise<any> { try { const response = await this.client.get(`/iserver/account/orders/${orderId}`); return response.data; } catch (error) { Logger.error("Failed to get order status:", error); // Check if this is likely an authentication error if (this.isAuthenticationError(error)) { const authError = new Error(`Authentication required to get order status for order ${orderId}. Please authenticate with Interactive Brokers first.`); (authError as any).isAuthError = true; throw authError; } throw new Error(`Failed to get status for order ${orderId}`); } }