Skip to main content
Glama

get_historical_apy

Retrieve historical APY data for a specific market by providing market details and time range to analyze performance over intervals like hour, day, week, or month.

Instructions

Get historical APY data for a specific market.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
chainIdNo
endTimestampYes
intervalYes
marketUniqueKeyYes
startTimestampYes

Implementation Reference

  • The core handler logic for the 'get_historical_apy' tool. Constructs a GraphQL query to the Morpho API to fetch historical supply and borrow APY data for a given market over a time range at specified interval, validates the response, and returns it as formatted JSON.
    if (name === GET_HISTORICAL_APY_TOOL) { try { const { marketUniqueKey, chainId = 1, startTimestamp, endTimestamp, interval } = params as HistoricalApyParams; const query = ` query MarketApys { marketByUniqueKey( uniqueKey: "${marketUniqueKey}" chainId: ${chainId} ) { uniqueKey historicalState { supplyApy(options: { startTimestamp: ${startTimestamp} endTimestamp: ${endTimestamp} interval: ${interval} }) { x y } borrowApy(options: { startTimestamp: ${startTimestamp} endTimestamp: ${endTimestamp} interval: ${interval} }) { x y } } } }`; const response = await axios.post(MORPHO_API_BASE, { query }); const validatedData = HistoricalApyResponseSchema.parse(response.data); return { content: [{ type: 'text', text: JSON.stringify(validatedData.data.marketByUniqueKey, null, 2) }], }; } catch (error: any) { return { isError: true, content: [{ type: 'text', text: `Error retrieving historical APY: ${error.message}` }], }; } }
  • src/index.ts:701-717 (registration)
    Tool registration in the MCP server's ListTools handler, defining the tool name, description, and input schema for validation.
    name: GET_HISTORICAL_APY_TOOL, description: 'Get historical APY data for a specific market.', inputSchema: { type: 'object', properties: { marketUniqueKey: { type: 'string' }, chainId: { type: 'number' }, startTimestamp: { type: 'number' }, endTimestamp: { type: 'number' }, interval: { type: 'string', enum: ['HOUR', 'DAY', 'WEEK', 'MONTH'] } }, required: ['marketUniqueKey', 'startTimestamp', 'endTimestamp', 'interval'] }, },
  • Zod schema used to validate and parse the GraphQL response data from the Morpho API for historical APY.
    const HistoricalApyResponseSchema = z.object({ data: z.object({ marketByUniqueKey: z.object({ uniqueKey: z.string(), historicalState: z.object({ supplyApy: z.array(TimeseriesPointSchema), borrowApy: z.array(TimeseriesPointSchema), }), }), }), });
  • TypeScript type for the tool's input parameters, used for type-checking in the handler.
    type HistoricalApyParams = { marketUniqueKey: string; chainId?: number; } & TimeseriesParams;
  • Constant string defining the exact tool name used in registration and handler dispatch.
    const GET_HISTORICAL_APY_TOOL = 'get_historical_apy';

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/crazyrabbitLTC/mcp-morpho-server'

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