Skip to main content
Glama
truss44

Crypto Price & Market Analysis MCP Server

get-crypto-price

Fetch current price and 24-hour statistics for any cryptocurrency by providing its symbol. Access real-time data for informed market analysis.

Instructions

Get current price and 24h stats for a cryptocurrency

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
symbolYesCryptocurrency symbol (e.g., BTC, ETH)

Implementation Reference

  • The handler function that executes the get-crypto-price tool logic: parses input symbol, fetches assets from CoinCap, finds the asset, formats price info, handles errors.
    export async function handleGetPrice(args: unknown) {
      const { symbol } = GetPriceArgumentsSchema.parse(args);
      const upperSymbol = symbol.toUpperCase();
    
      try {
        const assetsData = await getAssets();
        
        if (!assetsData) {
          return {
            content: [{ type: "text", text: "Failed to retrieve cryptocurrency data" }],
          };
        }
        
        const asset = assetsData.data.find(
          (a: { symbol: string; }) => a.symbol.toUpperCase() === upperSymbol
        );
    
        if (!asset) {
          return {
            content: [
              {
                type: "text",
                text: `Could not find cryptocurrency with symbol ${upperSymbol}`,
              },
            ],
          };
        }
    
        return {
          content: [{ type: "text", text: formatPriceInfo(asset) }],
        };
      } catch (error) {
        return {
          content: [{ 
            type: "text", 
            text: error instanceof Error ? error.message : `Failed to retrieve cryptocurrency data: ${String(error)}` 
          }],
        };
      }
    }
  • Zod input schema defining the 'symbol' parameter for the tool.
    export const GetPriceArgumentsSchema = z.object({
      symbol: z.string().min(1),
    });
  • src/index.ts:38-49 (registration)
    Registers the 'get-crypto-price' tool on the MCP server with title, description, input schema, and handler.
    server.registerTool(
      "get-crypto-price",
      {
        title: "Get Crypto Price",
        description: "Get current price and 24h stats for a cryptocurrency",
        inputSchema: GetPriceArgumentsSchema.shape,
      },
      async (args, _extra) => {
        const result = await handleGetPrice(args);
        return result as any;
      }
    );
Install Server

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/truss44/mcp-crypto-price'

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