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
| Name | Required | Description | Default |
|---|---|---|---|
| first | No | ||
| orderBy | No | ||
| orderDirection | No | ||
| skip | No | ||
| vaultAddress | Yes |
Implementation Reference
- src/index.ts:1396-1448 (handler)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'] }, },
- src/index.ts:462-469 (schema)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 }) }) });
- src/index.ts:422-438 (schema)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 });
- src/index.ts:473-473 (helper)Constant defining the tool name for consistent reference throughout the code.const GET_VAULT_REALLOCATES_TOOL = 'get_vault_reallocates';