fetch_quote
Retrieve current token prices from EVM blockchains by providing a token slug identifier.
Instructions
Get the price of a token
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| slug | Yes |
Implementation Reference
- src/tools/FetchQuote.ts:10-16 (handler)The primary handler function implementing the 'fetch_quote' tool logic. It destructures the slug option, fetches lightweight crypto data from CoinMarketCap service, and returns the current price from the statistics.export const fetchQuote = async (options: FetchQuoteOptions) => { const { slug } = options; const data = await getCryptoDataLite(slug); return data.data.statistics.price; };
- src/tools/FetchQuote.ts:5-8 (schema)Zod schema defining the input for fetch_quote: a required 'slug' string (e.g., token identifier). Includes the inferred TypeScript type.export const FetchQuoteSchema = z.object({ slug: z.string(), }); export type FetchQuoteOptions = z.infer<typeof FetchQuoteSchema>;
- src/index.ts:50-54 (registration)Registration of the 'fetch_quote' tool in the list returned by ListToolsRequestSchema, including name, description, and JSON schema for input validation.{ name: "fetch_quote", description: "Get the price of a token", inputSchema: z.toJSONSchema(FetchQuoteSchema), },
- src/index.ts:142-155 (handler)Dispatcher handler in the main CallToolRequestSchema switch case. Parses arguments with the schema, invokes the fetchQuote handler, and formats the response as MCP tool content.case "fetch_quote": { const args = FetchQuoteSchema.parse(request.params.arguments); const result = await fetchQuote(args); return { content: [ { type: "text", text: result.toString(), description: "The price of the token in USD", }, ], }; }