get_vault_allocation
Retrieve vault allocation for a specific market by providing the address and chain ID using the Morpho API MCP Server.
Instructions
Get vault allocation for a specific market.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| address | Yes | ||
| chainId | No |
Implementation Reference
- src/index.ts:1359-1394 (handler)The core handler logic for the 'get_vault_allocation' tool. It takes vault address and optional chainId, constructs a GraphQL query to fetch vault state allocation from Morpho API, validates the response using Zod schema, and returns the formatted data.if (name === GET_VAULT_ALLOCATION_TOOL) { try { const { address, chainId = 1 } = params as VaultAllocationParams; const query = ` query { vaultByAddress( chainId: ${chainId} address: "${address}" ) { address state { allocation { market { uniqueKey } supplyCap supplyAssets supplyAssetsUsd } } } }`; const response = await axios.post(MORPHO_API_BASE, { query }); const validatedData = VaultAllocationResponseSchema.parse(response.data); return { content: [{ type: 'text', text: JSON.stringify(validatedData.data.vaultByAddress, null, 2) }], }; } catch (error: any) { return { isError: true, content: [{ type: 'text', text: `Error retrieving vault allocation: ${error.message}` }], }; } }
- src/index.ts:767-778 (registration)Registration of the tool in the listTools handler, providing name, description, and JSON input schema for the MCP protocol.{ name: GET_VAULT_ALLOCATION_TOOL, description: 'Get vault allocation for a specific market.', inputSchema: { type: 'object', properties: { address: { type: 'string' }, chainId: { type: 'number' } }, required: ['address'] }, },
- src/index.ts:451-460 (schema)Zod schema used to validate the GraphQL response data for vault allocation in the tool handler.const VaultAllocationResponseSchema = z.object({ data: z.object({ vaultByAddress: z.object({ address: z.string(), state: z.object({ allocation: z.array(VaultAllocationSchema) }) }) }) });
- src/index.ts:476-479 (schema)TypeScript type definition for the input parameters expected by the tool handler.type VaultAllocationParams = { address: string; chainId?: number; };
- src/index.ts:472-472 (registration)Constant defining the tool name string.const GET_VAULT_ALLOCATION_TOOL = 'get_vault_allocation';