Skip to main content
Glama

get_vaults

Retrieve detailed information on all vaults including their current states, sorted and filtered by assets, APY, or net APY in ascending or descending order.

Instructions

Retrieves all vaults with their current states.

Input Schema

NameRequiredDescriptionDefault
firstNo
orderByNo
orderDirectionNo
skipNo

Input Schema (JSON Schema)

{ "properties": { "first": { "type": "number" }, "orderBy": { "enum": [ "TotalAssetsUsd", "Apy", "NetApy" ], "type": "string" }, "orderDirection": { "enum": [ "Asc", "Desc" ], "type": "string" }, "skip": { "type": "number" } }, "type": "object" }

Implementation Reference

  • src/index.ts:800-818 (registration)
    Registration of the 'get_vaults' tool in the listTools handler, including input schema definition.
    { name: GET_VAULTS_TOOL, description: 'Retrieves all vaults with their current states.', inputSchema: { type: 'object', properties: { first: { type: 'number' }, skip: { type: 'number' }, orderBy: { type: 'string', enum: ['TotalAssetsUsd', 'Apy', 'NetApy'] }, orderDirection: { type: 'string', enum: ['Asc', 'Desc'] } } } },
  • Handler function for 'get_vaults' tool that constructs a GraphQL query to fetch vaults data from Morpho API, validates the response using VaultsResponseSchema, and returns formatted JSON.
    if (name === GET_VAULTS_TOOL) { try { const queryParams = buildQueryParams(params as VaultQueryParams); const query = ` query { vaults${queryParams} { pageInfo { count countTotal } items { address symbol name creationBlockNumber creationTimestamp creatorAddress whitelisted asset { id address decimals } chain { id network } state { id apy netApy totalAssets totalAssetsUsd fee timelock } warnings { type level } } } }`; const response = await axios.post(MORPHO_API_BASE, { query }); const validatedData = VaultsResponseSchema.parse(response.data); return { content: [{ type: 'text', text: JSON.stringify(validatedData.data.vaults, null, 2) }] }; } catch (error: any) { return { isError: true, content: [{ type: 'text', text: `Error retrieving vaults: ${error.message}` }] }; } }
  • Zod schema for validating the response from the Morpho API vaults query.
    const VaultsResponseSchema = z.object({ data: z.object({ vaults: z.object({ pageInfo: PageInfoSchema, items: z.array(VaultSchema) }) }) });
  • Detailed Zod schema defining the structure of a single vault object used in response validation.
    const VaultSchema = z.object({ address: z.string(), symbol: z.string(), name: z.string(), creationBlockNumber: z.number(), creationTimestamp: z.number(), creatorAddress: z.string(), whitelisted: z.boolean(), asset: z.object({ id: z.string(), address: z.string(), decimals: z.number() }), chain: z.object({ id: z.number(), network: z.string() }), state: z.object({ id: z.string(), apy: z.number().nullable(), netApy: z.number().nullable(), totalAssets: z.union([z.string(), z.number()]).transform(stringToNumber), totalAssetsUsd: z.union([z.string(), z.number(), z.null()]).transform(val => val === null ? 0 : stringToNumber(val)), fee: z.number(), timelock: z.number() }), warnings: z.array(WarningSchema).optional(), pendingCaps: z.array(PendingCapSchema).optional(), allocators: z.array(z.object({ address: z.string() })).optional(), publicAllocatorConfig: PublicAllocatorConfigSchema.optional() });
  • Constant defining the tool name 'get_vaults' for use in registration and handler dispatch.
    const GET_VAULTS_TOOL = 'get_vaults';

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