Skip to main content
Glama

get-historical-analysis

Analyze historical cryptocurrency prices by specifying the symbol, time interval, and duration. Customize the analysis to identify trends and patterns over a selected timeframe.

Instructions

Get historical price analysis with customizable timeframe

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
daysNoNumber of days to analyze (1-30)
intervalNoTime interval (m5, m15, m30, h1, h2, h6, h12, d1)h1
symbolYesCryptocurrency symbol (e.g., BTC, ETH)

Implementation Reference

  • The handler function that executes the get-historical-analysis tool. It validates input using Zod schema, fetches asset data and historical prices from CoinCap API, handles errors, and formats the response.
    export async function handleGetHistoricalAnalysis(args: unknown) {
      const { symbol, interval, days } = GetHistoricalAnalysisSchema.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: { symbol: string; }) => a.symbol.toUpperCase() === upperSymbol
      );
    
      if (!asset) {
        return {
          content: [{ type: "text", text: `Could not find cryptocurrency with symbol ${upperSymbol}` }],
        };
      }
    
      const end = Date.now();
      const start = end - (days * 24 * 60 * 60 * 1000);
      const historyData = await getHistoricalData(asset.id, interval, start, end);
    
      if (!historyData || !historyData.data.length) {
        return {
          content: [{ type: "text", text: "Failed to retrieve historical data" }],
        };
      }
    
      return {
        content: [{ type: "text", text: formatHistoricalAnalysis(asset, historyData.data) }],
      };
    }
  • Zod schema used for input validation within the handler function.
    export const GetHistoricalAnalysisSchema = z.object({
      symbol: z.string().min(1),
      interval: z.enum(['m5', 'm15', 'm30', 'h1', 'h2', 'h6', 'h12', 'd1']).default('h1'),
      days: z.number().min(1).max(30).default(7),
    });
  • src/index.ts:60-82 (registration)
    Tool registration in the ListTools handler, including name, description, and input schema.
      name: "get-historical-analysis",
      description: "Get historical price analysis with customizable timeframe",
      inputSchema: {
        type: "object",
        properties: {
          symbol: {
            type: "string",
            description: "Cryptocurrency symbol (e.g., BTC, ETH)",
          },
          interval: {
            type: "string",
            description: "Time interval (m5, m15, m30, h1, h2, h6, h12, d1)",
            default: "h1",
          },
          days: {
            type: "number",
            description: "Number of days to analyze (1-30)",
            default: 7,
          },
        },
        required: ["symbol"],
      },
    },
  • src/index.ts:97-98 (registration)
    Switch case in CallTool handler that routes to the get-historical-analysis handler function.
    case "get-historical-analysis":
      return await handleGetHistoricalAnalysis(args);
  • src/index.ts:15-15 (registration)
    Import of the handler function from tools/index.js for use in server setup.
    } from './tools/index.js';
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/wazzan/mcp-coincap-jj'

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