Skip to main content
Glama
EmanuelJr
by EmanuelJr

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
NameRequiredDescriptionDefault
slugYes

Implementation Reference

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

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