Skip to main content
Glama
crazyrabbitLTC

Morpho API MCP Server

get_vault_reallocates

Retrieve reallocation details for a specific vault, including timestamps and order direction, through the Morpho API MCP Server's GraphQL interface.

Instructions

Get vault reallocates for a specific vault.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
firstNo
orderByNo
orderDirectionNo
skipNo
vaultAddressYes

Implementation Reference

  • Handler implementation that builds and executes a GraphQL query to retrieve vault reallocate events for a given vault address, validates the response, and returns formatted JSON data.
    if (name === GET_VAULT_REALLOCATES_TOOL) {
        try {
              const { vaultAddress, first, skip, orderBy = 'Timestamp', orderDirection = 'Asc' } = params as VaultReallocateParams;
              const queryParams = buildQueryParams({
                first,
                skip,
                orderBy,
                orderDirection,
                where: { vaultAddress_in: [vaultAddress] }
              });
    
              const query = `
              query {
                vaultReallocates${queryParams} {
                  pageInfo {
                    count
                    countTotal
                  }
                  items {
                    id
                    timestamp
                    hash
                    blockNumber
                    caller
                    shares
                    assets
                    type
                    vault {
                      id
                      chain {
                        id
                      }
                    }
                    market {
                      uniqueKey
                    }
                  }
                }
              }`;
    
              const response = await axios.post(MORPHO_API_BASE, { query });
              const validatedData = VaultReallocatesResponseSchema.parse(response.data);
    
              return {
                content: [{ type: 'text', text: JSON.stringify(validatedData.data.vaultReallocates, null, 2) }],
              };
        } catch (error: any) {
              return {
                isError: true,
                content: [{ type: 'text', text: `Error retrieving vault reallocates: ${error.message}` }],
              };
        }
    }
  • src/index.ts:779-799 (registration)
    Tool registration in the listTools handler, including name, description, and input schema definition.
    {
      name: GET_VAULT_REALLOCATES_TOOL,
      description: 'Get vault reallocates for a specific vault.',
      inputSchema: {
        type: 'object',
        properties: {
          vaultAddress: { type: 'string' },
          first: { type: 'number' },
          skip: { type: 'number' },
          orderBy: {
            type: 'string',
            enum: ['Timestamp']
          },
          orderDirection: {
            type: 'string',
            enum: ['Asc', 'Desc']
          }
        },
        required: ['vaultAddress']
      },
    },
  • Zod schema for validating the GraphQL response from the vaultReallocates query.
    const VaultReallocatesResponseSchema = z.object({
      data: z.object({
        vaultReallocates: z.object({
          items: z.array(VaultReallocateSchema),
          pageInfo: PageInfoSchema
        })
      })
    });
  • Zod schema defining the structure of individual vault reallocate events.
    const VaultReallocateSchema = z.object({
      id: z.string(),
      timestamp: z.number(),
      hash: z.string(),
      blockNumber: z.number(),
      caller: z.string(),
      shares: z.union([z.string(), z.number()]).transform(stringToNumber),
      assets: z.union([z.string(), z.number()]).transform(stringToNumber),
      type: z.string(),
      vault: z.object({
        id: z.string(),
        chain: z.object({
          id: z.number()
        })
      }),
      market: MarketSchema
    });
  • Constant defining the tool name for consistent reference throughout the code.
    const GET_VAULT_REALLOCATES_TOOL = 'get_vault_reallocates';
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