Skip to main content
Glama

fetch_quote

Retrieve real-time token prices using a specified slug for accurate market data on EVM chains.

Instructions

Get the price of a token

Input Schema

NameRequiredDescriptionDefault
slugYes

Input Schema (JSON Schema)

{ "$schema": "https://json-schema.org/draft/2020-12/schema", "additionalProperties": false, "properties": { "slug": { "type": "string" } }, "required": [ "slug" ], "type": "object" }

Implementation Reference

  • The primary handler function that executes the logic for the 'fetch_quote' tool. It destructures the slug from options, fetches crypto data using the helper getCryptoDataLite, and returns the price from the statistics.
    export const fetchQuote = async (options: FetchQuoteOptions) => { const { slug } = options; const data = await getCryptoDataLite(slug); return data.data.statistics.price; };
  • Zod schema defining the input for the 'fetch_quote' tool (requires a 'slug' string) and 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 ListToolsRequestHandler response, including name, description, and input schema reference.
    { name: "fetch_quote", description: "Get the price of a token", inputSchema: z.toJSONSchema(FetchQuoteSchema), },
  • Server-side dispatch handler case for 'fetch_quote' in the CallToolRequestHandler. Parses arguments using the schema, calls the fetchQuote function, and formats the response as MCP 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", }, ], }; }
  • Supporting helper utility called by fetchQuote to retrieve lightweight cryptocurrency data (including price) from the CoinMarketCap API using the provided slug.
    export const getCryptoDataLite = async (slug: string) => { const response = await fetch( `https://api.coinmarketcap.com/data-api/v3/cryptocurrency/detail/lite?slug=${slug}` ); if (!response.ok) { throw new Error("Failed to fetch crypto data"); } const data = await response.json(); return data as GetCryptoDataLiteResponse; };

Other Tools

Related Tools

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/EmanuelJr/web3-mcp-server'

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