cancel_order
Cancel an open cryptocurrency trading order by its unique ID within the pexbot-mcp simulated exchange environment.
Instructions
Cancel an open order by its ID.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| order_id | Yes | UUID of the order to cancel |
Implementation Reference
- src/index.ts:375-380 (handler)The handler function that executes the cancel_order tool logic. It calls the API DELETE endpoint for the specified order_id and returns the result as JSON.
async ({ order_id }) => { const data = await apiDelete<unknown>(`/orders/${order_id}`); return { content: [{ type: "text" as const, text: JSON.stringify(data, null, 2) }], }; } - src/index.ts:374-374 (schema)Zod schema definition for cancel_order input validation. Defines order_id as a required string parameter with description.
{ order_id: z.string().describe("UUID of the order to cancel") }, - src/index.ts:371-381 (registration)Registration of the cancel_order tool with the MCP server. Includes tool name, description, schema, and handler function.
server.tool( "cancel_order", "Cancel an open order by its ID.", { order_id: z.string().describe("UUID of the order to cancel") }, async ({ order_id }) => { const data = await apiDelete<unknown>(`/orders/${order_id}`); return { content: [{ type: "text" as const, text: JSON.stringify(data, null, 2) }], }; } ); - src/index.ts:118-128 (helper)Helper function apiDelete that performs HTTP DELETE requests to the API. Used by the cancel_order handler to make the actual API call.
async function apiDelete<T>(path: string): Promise<T> { const res = await fetch(`${API_BASE}${path}`, { method: "DELETE", headers: getAuthHeaders(), }); if (!res.ok) { const text = await res.text(); throw new Error(`API DELETE ${path} failed (${res.status}): ${text}`); } return res.json() as Promise<T>; }