Skip to main content
Glama

get_app_positions

Retrieve DeFi positions such as lending, LP shares, and staking for any wallet address. Filter by network or app slug like 'aave-v3' to get specific protocol exposure.

Instructions

DeFi app positions only (Aave lending, Uniswap LP, staking, etc.). Use when the question is about protocol exposure: 'any leveraged positions?', 'Aave borrows?', 'LP positions on Uniswap?'. Optionally filter by app slug.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
addressYesWallet address or ENS name
networksNoNetworks to filter by. Supported: ethereum, base, optimism, arbitrum, polygon, bnb, avalanche, zora. Omit for all networks.
app_slugNoFilter to a specific app slug, e.g. 'aave-v3', 'uniswap-v3'

Implementation Reference

  • Core handler that fetches DeFi app positions from Zapper GraphQL API. Calls APP_POSITIONS_QUERY, parses results and optionally filters by app slug.
    export async function fetchAppPositions(
      apiKey: string,
      address: string,
      chainIds?: number[],
      appSlug?: string,
    ): Promise<AppPositionsResult> {
      const data = (await gql(apiKey, APP_POSITIONS_QUERY, {
        addresses: [address],
        chainIds: chainIds ?? null,
      })) as { portfolioV2: { appBalances: { totalBalanceUSD: number; byApp: { edges: Array<{ node: GqlAppNode }> } } } };
    
      const ab = data.portfolioV2.appBalances;
      let apps = ab.byApp.edges.map(({ node }) => parseAppNode(node));
    
      if (appSlug) {
        apps = apps.filter((a) => a.slug === appSlug);
      }
    
      return {
        totalUSD: appSlug ? apps.reduce((s, a) => s + a.balanceUSD, 0) : (ab.totalBalanceUSD ?? 0),
        apps,
      };
  • src/server.ts:94-123 (registration)
    Registers the 'get_app_positions' tool on the MCP server with description, input schema (address, networks, app_slug), and invokes fetchAppPositions.
    server.registerTool(
      "get_app_positions",
      {
        description:
          "DeFi app positions only (Aave lending, Uniswap LP, staking, etc.). Use when the question is about protocol exposure: 'any leveraged positions?', 'Aave borrows?', 'LP positions on Uniswap?'. Optionally filter by app slug.",
        inputSchema: {
          address: z.string().describe("Wallet address or ENS name"),
          networks: networksSchema,
          app_slug: z
            .string()
            .optional()
            .describe("Filter to a specific app slug, e.g. 'aave-v3', 'uniswap-v3'"),
        },
      },
      async ({ address, networks, app_slug }) => {
        try {
          const result = await fetchAppPositions(
            apiKey,
            address,
            resolveChainIds(networks),
            app_slug,
          );
          return {
            content: [{ type: "text", text: JSON.stringify(result, null, 2) }],
          };
        } catch (err) {
          return errorResponse(err);
        }
      },
    );
  • Type interface for the result of fetchAppPositions: totalUSD and an array of AppBalance objects.
    export interface AppPositionsResult {
      totalUSD: number;
      apps: AppBalance[];
    }
  • Type interface for a single app balance entry, containing name, slug, network, balanceUSD, and an array of positions.
    export interface AppBalance {
      name: string;
      slug: string;
      network: string;
      balanceUSD: number;
      positions: AppPosition[];
    }
  • Parses a GraphQL app node into the AppBalance shape, extracting positions with underlying token details.
    function parseAppNode(node: GqlAppNode): AppBalance {
      const positions: AppPosition[] = node.positionBalances.edges.map(({ node: pos }) => {
        const underlying = (pos.tokens ?? []).map((t) => {
          const inner = t.token ?? t;
          return {
            symbol: inner.symbol ?? "",
            balance: typeof inner.balance === "string" ? parseFloat(inner.balance) : (inner.balance ?? 0),
            balanceUSD: inner.balanceUSD ?? 0,
          };
        });
        return {
          type: pos.type === "contract-position" ? "contract_position" : "app_token",
          symbol: pos.symbol,
          balance: pos.balance !== undefined
            ? typeof pos.balance === "string" ? parseFloat(pos.balance) : pos.balance
            : undefined,
          balanceUSD: pos.balanceUSD ?? 0,
          underlying,
        };
      });
      return {
        name: node.app.displayName,
        slug: node.app.slug,
        network: node.network.name,
        balanceUSD: node.balanceUSD ?? 0,
        positions,
      };
    }
Behavior3/5

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

With no annotations provided, the description carries full burden but does not disclose behavioral traits such as read-only nature, data freshness, or performance characteristics. The description only mentions filtering capabilities, which is adequate but not comprehensive.

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 two sentences: first defines scope, second provides usage context and optional filter. Every sentence earns its place with no redundancy.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

With no output schema, the description does not explain return values. However, given the tool's simplicity (3 params, 1 required) and clear purpose, the description is largely complete. Minor gap in output expectations.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Input schema has 100% coverage with descriptions for each parameter. The description does not add semantic value beyond the schema, simply restating the optional app_slug filter. Baseline score of 3 is appropriate.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description explicitly states 'DeFi app positions only' and lists examples (Aave, Uniswap, staking), clearly distinguishing it from sibling tools like get_portfolio and get_token_balances.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description directly tells when to use the tool ('when the question is about protocol exposure') and provides example queries ('any leveraged positions?', 'Aave borrows?', 'LP positions on Uniswap?'), effectively guiding the agent.

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

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/mehdi-loup/zapper-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server