Skip to main content
Glama
crazyrabbitLTC

Morpho API MCP Server

get_vault_positions

Retrieve vault positions by specifying the vault address, sorting order, and pagination parameters to access detailed asset and shares data efficiently.

Instructions

Get positions for a specific vault.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
firstNo
orderByNo
orderDirectionNo
skipNo
vaultAddressYes

Implementation Reference

  • Handler for get_vault_positions tool: constructs GraphQL query for vaultPositions filtered by vaultAddress, fetches from Morpho API, validates with Zod schema, returns JSON response.
    if (name === GET_VAULT_POSITIONS_TOOL) {
      try {
        const { vaultAddress, ...rest } = params as VaultPositionsParams;
        const queryParams = buildQueryParams({
          ...rest,
          where: { vaultAddress_in: [vaultAddress] }
        });
    
        const query = `
          query {
            vaultPositions${queryParams} {
              items {
                shares
                assets
                assetsUsd
                user {
                  address
                }
              }
            }
          }`;
    
        const response = await axios.post(MORPHO_API_BASE, { query });
        const validatedData = VaultPositionsResponseSchema.parse(response.data);
    
        return {
          content: [{ type: 'text', text: JSON.stringify(validatedData.data.vaultPositions, null, 2) }]
        };
      } catch (error: any) {
        return {
          isError: true,
          content: [{ type: 'text', text: `Error retrieving vault positions: ${error.message}` }]
        };
      }
    }
  • src/index.ts:820-839 (registration)
    Tool registration in ListToolsRequestHandler: defines name, description, and inputSchema for get_vault_positions.
      name: GET_VAULT_POSITIONS_TOOL,
      description: 'Get positions for a specific vault.',
      inputSchema: {
        type: 'object',
        properties: {
          vaultAddress: { type: 'string' },
          first: { type: 'number' },
          skip: { type: 'number' },
          orderBy: {
            type: 'string',
            enum: ['Shares', 'Assets', 'AssetsUsd']
          },
          orderDirection: {
            type: 'string',
            enum: ['Asc', 'Desc']
          }
        },
        required: ['vaultAddress']
      }
    },
  • Zod schema for validating the response from the vaultPositions GraphQL query.
    const VaultPositionsResponseSchema = z.object({
      data: z.object({
        vaultPositions: z.object({
          items: z.array(z.object({
            shares: z.union([z.string(), z.number()]).transform(stringToNumber),
            assets: z.union([z.string(), z.number()]).transform(stringToNumber),
            assetsUsd: z.union([z.string(), z.number()]).transform(stringToNumber),
            user: z.object({
              address: z.string()
            })
          }))
        })
      })
    });
  • TypeScript type definition for input parameters to the get_vault_positions tool.
    type VaultPositionsParams = PaginationParams & {
      vaultAddress: string;
      orderBy?: 'Shares' | 'Assets' | 'AssetsUsd';
      orderDirection?: OrderDirection;
    };
  • Helper function to build GraphQL query parameters from input params, used in the handler.
    function buildQueryParams(params: PaginationParams & { orderBy?: string, orderDirection?: OrderDirection, where?: Record<string, any> } = {}): string {
      const queryParts: string[] = [];
      
      if (params.first !== undefined) queryParts.push(`first: ${params.first}`);
      if (params.skip !== undefined) queryParts.push(`skip: ${params.skip}`);
      if (params.orderBy) queryParts.push(`orderBy: ${params.orderBy}`);
      if (params.orderDirection) queryParts.push(`orderDirection: ${params.orderDirection}`);
      if (params.where && Object.keys(params.where).length > 0) {
        const whereStr = JSON.stringify(params.where).replace(/"([^"]+)":/g, '$1:');
        queryParts.push(`where: ${whereStr}`);
      }
    
      return queryParts.length > 0 ? `(${queryParts.join(', ')})` : '';
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It only states the basic action without mentioning whether this is a read-only operation, if it requires authentication, rate limits, pagination behavior, or what the return format looks like. This is inadequate for a tool with 5 parameters and no output schema.

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 a single, efficient sentence that gets straight to the point with no wasted words. It's appropriately sized for the tool's apparent complexity.

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 5 parameters with 0% schema coverage, no annotations, and no output schema, the description is incomplete. It doesn't provide enough context about what 'positions' entails, how to interpret parameters, or what to expect in return, making it insufficient for effective tool use.

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 it adds no parameter information beyond implying 'vaultAddress' is needed. It doesn't explain what 'positions' means, what the ordering/skipping parameters do, or how results are structured, leaving most parameters undocumented.

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 action ('Get') and resource ('positions for a specific vault'), making the purpose understandable. It doesn't explicitly differentiate from siblings like 'get_vault_allocation' or 'get_vaults', but the specificity of 'positions' provides some distinction.

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?

No guidance is provided on when to use this tool versus alternatives. The description doesn't mention prerequisites, exclusions, or comparisons to sibling tools like 'get_vault_allocation' or 'get_market_positions', 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