UNPKG

@bujaayjaay/mcp-coincap-jj

Version:

A Model Context Protocol (MCP) server that provides real-time cryptocurrency data and analysis through CoinCap's API v3. Features include price tracking, market analysis, and historical trends. This is a fork of the original repo by truss44, with updates

31 lines (30 loc) 985 B
import { z } from 'zod'; import { getAssets } from '../services/coincap.js'; import { formatPriceInfo } from '../services/formatters.js'; export const GetPriceArgumentsSchema = z.object({ symbol: z.string().min(1), }); export async function handleGetPrice(args) { const { symbol } = GetPriceArgumentsSchema.parse(args); const upperSymbol = symbol.toUpperCase(); const assetsData = await getAssets(); if (!assetsData) { return { content: [{ type: "text", text: "Failed to retrieve cryptocurrency data" }], }; } const asset = assetsData.data.find((a) => 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) }], }; }