GET_TICKER
Retrieve current ticker data for a specific market from Upbit. Input the market code (e.g., KRW-BTC) to get real-time price, volume, and change information.
Instructions
Get the latest ticker data from Upbit for a single market
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| market | Yes | Upbit market code, e.g., KRW-BTC |
Implementation Reference
- src/tools/get-ticker.ts:12-25 (handler)The getTickerTool object containing the name 'GET_TICKER', description, parameters schema, and the execute async function that fetches ticker data from Upbit API and returns it as a JSON string.
export const getTickerTool = { name: "GET_TICKER", description: "Get the latest ticker data from Upbit for a single market", parameters: paramsSchema, execute: async ({ market }: Params) => { const baseURL = `${config.upbit.baseUrl}${config.upbit.apiBasePath}`; const client = createHttpClient(baseURL); const data = await fetchJson<unknown>(client, "/ticker", { params: { markets: market }, }); const item = Array.isArray(data) ? (data as any[])[0] : (data as any); return JSON.stringify(item, null, 2); }, } as const; - src/tools/get-ticker.ts:6-8 (schema)Zod schema for the 'market' parameter (string min 3 chars, describes Upbit market code e.g., KRW-BTC).
const paramsSchema = z.object({ market: z.string().min(3).describe("Upbit market code, e.g., KRW-BTC"), }); - src/index.ts:15-15 (registration)Import of getTickerTool from the get-ticker module.
import { getTickerTool } from "./tools/get-ticker.js"; - src/index.ts:31-31 (registration)Registration of getTickerTool on the FastMCP server via server.addTool().
server.addTool(getTickerTool); - src/lib/http.ts:32-67 (helper)The fetchJson helper function used by the getTickerTool execute handler to make HTTP GET requests to the Upbit API.
export async function fetchJson<T>( client: AxiosInstance, url: string, options: { method?: "GET" | "POST" | "DELETE" | "PUT" | "PATCH"; params?: Record<string, unknown>; data?: unknown; headers?: Record<string, string>; } = {}, schema?: z.ZodType<T>, ): Promise<T> { try { const response = await client.request({ url, method: options.method ?? "GET", params: options.params, data: options.data, headers: options.headers, }); const data = response.data; if (schema) { return schema.parse(data); } return data as T; } catch (err) { if (axios.isAxiosError(err)) { const ae = err as AxiosError; const status = ae.response?.status ?? 0; const message = ae.message || "HTTP request failed"; const data = ae.response?.data; throw new HttpError(status, message, data); } throw err; } }