Skip to main content
Glama
crazyrabbitLTC

Morpho API MCP Server

get_account_overview

Retrieve detailed account summaries, including positions and transactions, for a specified address and chain ID using the Morpho API MCP Server.

Instructions

Get account overview including positions and transactions.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
addressYes
chainIdNo

Implementation Reference

  • Handler implementation for get_account_overview tool. Parses params, constructs GraphQL query to fetch user market positions, vault positions, and transactions from Morpho API, validates response, and returns JSON.
    if (name === GET_ACCOUNT_OVERVIEW_TOOL) {
        try {
              const { address, chainId = 1 } = params as AccountOverviewParams;
              const query = `
              query {
                userByAddress(
                  chainId: ${chainId}
                  address: "${address}"
                ) {
                  address
                  marketPositions {
                    market {
                      uniqueKey
                    }
                    borrowAssets
                    borrowAssetsUsd
                    supplyAssets
                    supplyAssetsUsd
                  }
                  vaultPositions {
                    vault {
                      address
                      name
                    }
                    assets
                    assetsUsd
                    shares
                  }
                  transactions {
                    hash
                    timestamp
                    type
                  }
                }
              }`;
    
              const response = await axios.post(MORPHO_API_BASE, { query });
              const validatedData = AccountOverviewResponseSchema.parse(response.data);
    
              return {
                content: [{ type: 'text', text: JSON.stringify(validatedData.data.userByAddress, null, 2) }],
              };
        } catch (error: any) {
              return {
                isError: true,
                content: [{ type: 'text', text: `Error retrieving account overview: ${error.message}` }],
              };
        }
    }
  • src/index.ts:730-741 (registration)
    Registration of the get_account_overview tool in the ListTools response, including name, description, and input schema.
    {
      name: GET_ACCOUNT_OVERVIEW_TOOL,
      description: 'Get account overview including positions and transactions.',
      inputSchema: {
        type: 'object',
        properties: {
          address: { type: 'string' },
          chainId: { type: 'number' }
        },
        required: ['address']
      },
    },
  • Zod schema defining the structure of account overview data, used for response validation.
    const AccountOverviewSchema = z.object({
      address: z.string(),
      marketPositions: z.array(MarketPositionSchema),
      vaultPositions: z.array(VaultPositionSchema),
      transactions: z.array(TransactionSchema),
    });
  • Zod schema for the full API response of account overview, used to parse and validate the GraphQL response.
    const AccountOverviewResponseSchema = z.object({
      data: z.object({
        userByAddress: AccountOverviewSchema,
      }),
    });
  • src/index.ts:313-313 (registration)
    Constant definition for the tool name, used in registration and handler dispatch.
    const GET_ACCOUNT_OVERVIEW_TOOL = 'get_account_overview';

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