Skip to main content
Glama
crazyrabbitLTC

Morpho API MCP Server

get_liquidations

Retrieve liquidation events with customizable filters and pagination for Morpho markets, enabling precise tracking of seized or repaid assets within specified timeframes.

Instructions

Get liquidation events with filtering and pagination.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
endTimestampNo
firstNo
marketUniqueKeysNo
orderByNo
orderDirectionNo
skipNo
startTimestampNo

Implementation Reference

  • The main handler function for the 'get_liquidations' tool. It constructs a GraphQL query to fetch liquidation transactions from the Morpho API, applies filters for market keys and timestamps, paginates and orders results, validates the response, and returns the formatted data.
    if (name === GET_LIQUIDATIONS_TOOL) {
        try {
              const liquidationParams = params as LiquidationsParams;
              const where: Record<string, any> = {
                type_in: ['MarketLiquidation']
              };
    
              if (liquidationParams.marketUniqueKeys?.length) {
                where.marketUniqueKey_in = liquidationParams.marketUniqueKeys;
              }
              if (liquidationParams.startTimestamp) {
                where.timestamp_gte = liquidationParams.startTimestamp;
              }
              if (liquidationParams.endTimestamp) {
                where.timestamp_lte = liquidationParams.endTimestamp;
              }
    
              const queryParams = buildQueryParams({
                first: liquidationParams.first,
                skip: liquidationParams.skip,
                orderBy: liquidationParams.orderBy,
                orderDirection: liquidationParams.orderDirection,
                where
              });
    
              const query = `
              query {
                transactions${queryParams} {
                  pageInfo {
                    count
                    countTotal
                  }
                  items {
                    blockNumber
                    hash
                    type
                    timestamp
                    user {
                      address
                    }
                    data {
                      ... on MarketLiquidationTransactionData {
                        seizedAssets
                        repaidAssets
                        seizedAssetsUsd
                        repaidAssetsUsd
                        badDebtAssetsUsd
                        liquidator
                        market {
                          uniqueKey
                        }
                      }
                    }
                  }
                }
              }`;
    
              const response = await axios.post(MORPHO_API_BASE, { query });
              const validatedData = LiquidationsResponseSchema.parse(response.data);
    
              return {
                content: [{ type: 'text', text: JSON.stringify(validatedData.data.transactions, null, 2) }],
              };
        } catch (error: any) {
              return {
                isError: true,
                content: [{ type: 'text', text: `Error retrieving liquidations: ${error.message}` }],
              };
        }
    }
  • src/index.ts:742-766 (registration)
    Registration of the 'get_liquidations' tool in the listTools handler, including name, description, and input schema definition.
    {
      name: GET_LIQUIDATIONS_TOOL,
      description: 'Get liquidation events with filtering and pagination.',
      inputSchema: {
        type: 'object',
        properties: {
          marketUniqueKeys: {
            type: 'array',
            items: { type: 'string' }
          },
          startTimestamp: { type: 'number' },
          endTimestamp: { type: 'number' },
          first: { type: 'number' },
          skip: { type: 'number' },
          orderBy: {
            type: 'string',
            enum: ['Timestamp', 'SeizedAssetsUsd', 'RepaidAssetsUsd']
          },
          orderDirection: {
            type: 'string',
            enum: ['Asc', 'Desc']
          }
        }
      },
    },
  • Zod schema for validating the response from the liquidations GraphQL query.
    const LiquidationsResponseSchema = z.object({
      data: z.object({
        transactions: z.object({
          pageInfo: PageInfoSchema,
          items: z.array(TransactionSchema),
        }),
      }),
    });
  • Zod schema defining the structure of transaction objects used in liquidations response.
    const TransactionSchema = z.object({
      blockNumber: z.number(),
      hash: z.string(),
      type: z.string(),
      timestamp: z.number(),
      user: z.object({
        address: z.string(),
      }),
      data: z.object({
        seizedAssets: z.union([z.string(), z.number()]).transform(stringToNumber).optional(),
        repaidAssets: z.union([z.string(), z.number()]).transform(stringToNumber).optional(),
        seizedAssetsUsd: z.union([z.string(), z.number()]).transform(stringToNumber).optional(),
        repaidAssetsUsd: z.union([z.string(), z.number()]).transform(stringToNumber).optional(),
        badDebtAssetsUsd: z.union([z.string(), z.number()]).transform(stringToNumber).optional(),
        liquidator: z.string().optional(),
        market: z.object({
          uniqueKey: z.string(),
        }).optional(),
      }).optional(),
    });
  • src/index.ts:314-314 (registration)
    Constant defining the tool name 'get_liquidations' used throughout the code.
    const GET_LIQUIDATIONS_TOOL = 'get_liquidations';
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 vaguely mentions 'filtering and pagination'. It fails to disclose critical behavioral traits such as rate limits, authentication needs, response format, error handling, or whether it's a read-only operation. This leaves significant gaps for an agent.

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 extremely concise with a single sentence that is front-loaded and wastes no words. Every part ('Get liquidation events with filtering and pagination') contributes directly to the tool's function, making it efficient and well-structured.

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 (7 parameters, no schema descriptions, no output schema, no annotations), the description is incomplete. It lacks details on parameter usage, return values, error conditions, and operational constraints, making it inadequate for an agent to effectively use this tool without guesswork.

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 only generically references 'filtering and pagination'. It does not explain the meaning, purpose, or usage of any of the 7 parameters (e.g., endTimestamp, marketUniqueKeys, orderBy), leaving them undocumented and ambiguous.

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 resource ('liquidation events'), specifying the action and target. It distinguishes from siblings by focusing on liquidation events rather than accounts, markets, vaults, or other data types. However, it lacks specificity about the data source or system context.

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 mentions 'filtering and pagination' but provides no explicit guidance on when to use this tool versus alternatives. It does not specify scenarios, prerequisites, or comparisons with sibling tools like get_markets or get_vault_transactions, leaving usage context unclear.

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