Skip to main content
Glama
crazyrabbitLTC

Morpho API MCP Server

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';
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden but only states what the tool does without behavioral details. It doesn't disclose whether this is a read-only operation, potential rate limits, error conditions, or the format of returned APY data, leaving significant gaps in understanding how the tool behaves.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence with no wasted words. It's appropriately sized for a simple tool and front-loads the core purpose without unnecessary elaboration.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity (5 parameters, no output schema, no annotations), the description is incomplete. It doesn't cover parameter meanings, return values, or behavioral traits, making it inadequate for the agent to fully understand how to use this tool effectively in context.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters2/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, so the description must compensate but adds no parameter information. It doesn't explain what 'marketUniqueKey', 'chainId', or the timestamps represent, nor clarify the 'interval' enum options' meanings. This leaves all 5 parameters semantically undocumented.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb 'Get' and the resource 'historical APY data for a specific market', making the purpose understandable. However, it doesn't distinguish this tool from sibling 'get_vault_apy_history', which appears to serve a similar purpose for vaults rather than markets, leaving some ambiguity.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives like 'get_vault_apy_history' or other sibling tools. It lacks context about prerequisites, such as needing valid market identifiers or timestamp ranges, which could help the agent decide appropriateness.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

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

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