Skip to main content
Glama

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
NameRequiredDescriptionDefault
order_idYesUUID of the order to cancel

Implementation Reference

  • 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) }],
      };
    }
  • 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) }],
        };
      }
    );
  • 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>;
    }

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/mikusnuz/pexbot-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server