get-market-analysis
Analyze cryptocurrency market data by retrieving detailed insights on top exchanges and volume distribution. Input a cryptocurrency symbol (e.g., BTC, ETH) to access comprehensive market trends and exchange information.
Instructions
Get detailed market analysis including top exchanges and volume distribution
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| symbol | Yes | Cryptocurrency symbol (e.g., BTC, ETH) |
Implementation Reference
- src/index.ts:51-63 (registration)Registers the 'get-market-analysis' tool with the MCP server, specifying title, description, input schema, and handler function that calls handleGetMarketAnalysis.server.registerTool( "get-market-analysis", { title: "Get Market Analysis", description: "Get detailed market analysis including top exchanges and volume distribution", inputSchema: GetMarketAnalysisSchema.shape, }, async (args, _extra) => { const result = await handleGetMarketAnalysis(args); return result as any; } );
- src/tools/market.ts:5-7 (schema)Zod schema for input validation of the get-market-analysis tool, requiring a 'symbol' string.export const GetMarketAnalysisSchema = z.object({ symbol: z.string().min(1), });
- src/tools/market.ts:9-51 (handler)Main handler function for get-market-analysis tool. Parses input symbol, fetches asset data from CoinCap, finds the asset, gets its markets, formats analysis, and returns markdown content or error.export async function handleGetMarketAnalysis(args: unknown) { const { symbol } = GetMarketAnalysisSchema.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}` }], }; } const marketsData = await getMarkets(asset.id); if (!marketsData) { return { content: [{ type: "text", text: "Failed to retrieve market data" }], }; } return { content: [{ type: "text", text: formatMarketAnalysis(asset, marketsData.data) }], }; } catch (error) { return { content: [{ type: "text", text: error instanceof Error ? error.message : `Failed to retrieve data: ${String(error)}` }], }; } }