GET_ORDER
Retrieve a specific order from your Upbit account using its UUID or identifier.
Instructions
Get a single Upbit order (requires private API)
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| uuid | No | ||
| identifier | No |
Implementation Reference
- src/tools/get-order.ts:17-34 (handler)The actual handler for the GET_ORDER tool. It validates parameters (uuid or identifier required), signs a JWT token with the query params, and calls the Upbit API /v1/order endpoint to fetch a single order.
export const getOrderTool = { name: "GET_ORDER", description: "Get a single Upbit order (requires private API)", parameters: paramsSchema, execute: async ({ uuid, identifier }: Params) => { ensurePrivateEnabled(); const baseURL = `${config.upbit.baseUrl}${config.upbit.apiBasePath}`; const client = createHttpClient(baseURL); const query: Record<string, string> = {}; if (uuid) query.uuid = uuid; if (identifier) query.identifier = identifier; const token = signJwtToken(query); const data = await fetchJson<unknown>(client, "/order", { params: query, headers: { Authorization: `Bearer ${token}` }, }); return JSON.stringify(data, null, 2); }, - src/tools/get-order.ts:6-13 (schema)Zod schema defining the input parameters for GET_ORDER: uuid (optional string) and identifier (optional string), with a refinement that at least one must be provided.
const paramsSchema = z .object({ uuid: z.string().optional(), identifier: z.string().optional(), }) .refine((v) => v.uuid || v.identifier, { message: "Either uuid or identifier is required", }); - src/index.ts:37-37 (registration)Registration of GET_ORDER tool with the FastMCP server so it's exposed to clients.
server.addTool(getOrderTool); - src/index.ts:12-12 (registration)Import of the getOrderTool module in the main entry point.
import { getOrderTool } from "./tools/get-order.js"; - src/lib/upbit-auth.ts:18-41 (helper)Helper function that signs a JWT token with Upbit API credentials. Used by GET_ORDER to authenticate the /v1/order API call.
export function signJwtToken( params?: Record<string, string | number | boolean | undefined>, ): string { const payload: Record<string, unknown> = { access_key: config.upbit.accessKey, nonce: crypto.randomUUID(), }; if (params && Object.keys(params).length > 0) { const searchParams = new URLSearchParams(); const sortedKeys = Object.keys(params).sort(); for (const key of sortedKeys) { const value = params[key]; if (value === undefined) continue; searchParams.append(key, String(value)); } const encoded = searchParams.toString(); const queryHash = crypto.createHash("sha512").update(encoded).digest("hex"); payload.query_hash = queryHash; payload.query_hash_alg = "SHA512"; } return jwt.sign(payload, config.upbit.secretKey as string); }