Skip to main content
Glama

get_crypto_price

Retrieve real-time cryptocurrency prices from CoinCap's API to monitor market values and track specific coin performance.

Instructions

Get realtime crypto price on crypto

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameNoName of the crypto coin

Implementation Reference

  • The `toolCall` method that executes the core logic: extracts crypto name from arguments, fetches price data from Coincap API endpoint, returns JSON data or error response.
    async toolCall(request: z.infer<typeof CallToolRequestSchema>) { try { const cryptoName = request.params.arguments?.name; if (!cryptoName) { throw new Error("Missing crypto name"); } const url = CONSTANTS.CRYPTO_PRICE_URL + cryptoName; const response = await fetch(url); if (!response.ok) { throw new Error("Error fetching coincap data"); } const body = await response.json(); return { content: [{ type: "text", text: JSON.stringify(body.data) }], }; } catch (error) { return { content: [ { type: "error", text: JSON.stringify((error as any).message) }, ], }; } }
  • Tool definition including name, description, and input schema specifying a required 'name' string for the cryptocurrency.
    toolDefinition: Tool = { name: this.name, description: "Get realtime crypto price on crypto", inputSchema: { type: "object", properties: { name: { type: "string", description: "Name of the crypto coin", }, }, }, };
  • Creates a Map of tools keyed by their name (including 'get_crypto_price') for lookup during tool calls.
    export function createToolsMap(tools: BaseTool[]): Map<string, BaseTool> { return new Map(tools.map((tool) => [tool.name, tool])); }
  • Defines CRYPTO_PRICE_URL constant used by the get_crypto_price handler to construct the API endpoint.
    export const CONSTANTS = { CRYPTO_PRICE_URL: "https://api.coincap.io/v2/assets/", PROJECT_NAME: "coincap-mcp", PROJECT_VERSION: "0.9.2", };
  • Exports the GetCryptoPrice class for dynamic loading and instantiation by the tool loader.
    export default GetCryptoPrice;

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/QuantGeekDev/coincap-mcp'

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