Skip to main content
Glama

compare_vaults

Compare DeFi vaults side-by-side on TVL, APR, risk scores, audit status, and other key metrics to evaluate investment options.

Instructions

Compare 2-3 DeFi vaults side-by-side on TVL, APR, risk score, risk tier, audited status, and more.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
vaultsYesArray of 2-3 vaults to compare

Implementation Reference

  • Main handler implementation for the compare_vaults tool. Contains the registration and async handler that fetches vault data using Promise.allSettled, handles errors, formats the comparison using formatVaultComparison, and returns the results as text content.
    export function registerCompareVaults(server: McpServer) {
      server.tool(
        'compare_vaults',
        'Compare 2-3 DeFi vaults side-by-side on TVL, APR, risk score, risk tier, audited status, and more.',
        {
          vaults: z
            .array(
              z.object({
                network: z.string().describe('Network slug (e.g. ethereum, base)'),
                address: z.string().describe('Vault contract address (0x...)'),
              })
            )
            .min(2)
            .max(3)
            .describe('Array of 2-3 vaults to compare'),
        },
        async (params) => {
          const settled = await Promise.allSettled(
            params.vaults.map((v) => apiGet<{ data: any }>(`/v1/vault/${v.network}/${v.address}`))
          );
    
          const errors: string[] = [];
          const vaultData: any[] = [];
          settled.forEach((result, i) => {
            if (result.status === 'fulfilled') {
              vaultData.push(result.value.data);
            } else {
              errors.push(
                `${params.vaults[i].network}/${params.vaults[i].address}: ${result.reason?.message || 'Unknown error'}`
              );
            }
          });
    
          if (vaultData.length < 2) {
            const errorList = errors.length
              ? `\n\nErrors:\n${errors.map((e) => `- ${e}`).join('\n')}`
              : '';
            return {
              content: [
                {
                  type: 'text' as const,
                  text: `Need at least 2 vaults to compare, but only ${vaultData.length} could be fetched.${errorList}`,
                },
              ],
            };
          }
    
          let text = formatVaultComparison(vaultData);
          if (errors.length) {
            text += `\n\n**Note:** Could not fetch: ${errors.join('; ')}`;
          }
    
          return { content: [{ type: 'text' as const, text }] };
        }
      );
    }
  • Input schema definition using Zod. Validates an array of 2-3 vaults, each with a 'network' slug and 'address' field.
    vaults: z
      .array(
        z.object({
          network: z.string().describe('Network slug (e.g. ethereum, base)'),
          address: z.string().describe('Vault contract address (0x...)'),
        })
      )
      .min(2)
      .max(3)
      .describe('Array of 2-3 vaults to compare'),
  • src/server.ts:7-7 (registration)
    Import statement for registerCompareVaults function.
    import { registerCompareVaults } from './tools/compare-vaults';
  • src/server.ts:34-34 (registration)
    Tool registration call that registers the compare_vaults tool with the MCP server.
    registerCompareVaults(server);
  • Helper function formatVaultComparison that formats vault comparison data into a markdown table, including metrics like protocol, chain, asset, TVL, APR, risk score, risk tier, and audit status.
    export function formatVaultComparison(vaults: any[]): string {
      const headers = ['Metric', ...vaults.map((v) => v.vault?.name || v.name || 'Unknown')];
      const rows = [
        ['Protocol', ...vaults.map((v) => (v.vault || v).protocol_name)],
        ['Chain', ...vaults.map((v) => (v.vault || v).chain_name)],
        ['Asset', ...vaults.map((v) => (v.vault || v).asset_symbol || 'N/A')],
        ['TVL', ...vaults.map((v) => '$' + formatNumber((v.vault || v).tvl_usd))],
        ['APR', ...vaults.map((v) => formatPercent((v.vault || v).apr_net))],
        ['APR (7d avg)', ...vaults.map((v) => formatPercent(computeAvgApr(v.snapshots, 7)))],
        ['APR (30d avg)', ...vaults.map((v) => formatPercent(computeAvgApr(v.snapshots, 30)))],
        [
          'Risk Score',
          ...vaults.map((v) => {
            const d = v.vault || v;
            return `${d.total_score ?? d.risk_score ?? 'N/A'}/10`;
          }),
        ],
        [
          'Risk Tier',
          ...vaults.map((v) => {
            const d = v.vault || v;
            return d.risk_tier || 'N/A';
          }),
        ],
        ['Audited', ...vaults.map((v) => ((v.vault || v).is_audited ? 'Yes' : 'No'))],
      ];
    
      return formatMarkdownTable(headers, rows);
    }
Behavior2/5

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

With no annotations provided, the description carries full burden but lacks behavioral details. It doesn't disclose whether this is a read-only operation, if it requires authentication, rate limits, or what happens with invalid inputs. The phrase 'and more' is vague about additional metrics.

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?

Single sentence efficiently conveys purpose and key comparison metrics. No wasted words, and the structure is front-loaded with the core action ('compare 2-3 DeFi vaults').

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

Completeness3/5

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

For a comparison tool with no annotations and no output schema, the description adequately covers what metrics are compared but lacks details about return format, error handling, or behavioral constraints. The schema provides good parameter coverage, but overall completeness is moderate given the missing behavioral context.

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?

Schema description coverage is 100%, so the schema fully documents the 'vaults' parameter structure. The description adds no parameter-specific information beyond implying 2-3 vaults, which is already in the schema's minItems/maxItems. Baseline 3 is appropriate when schema does the heavy lifting.

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 clearly states the specific action ('compare') and resources ('2-3 DeFi vaults'), listing the exact comparison metrics (TVL, APR, risk score, etc.). It distinguishes from siblings like 'get_vault' (single vault) or 'find_safest_vaults' (different objective).

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

Usage Guidelines3/5

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

The description implies usage for side-by-side comparison of specific metrics, but doesn't explicitly state when to use this tool versus alternatives like 'search_vaults' for broader discovery or 'get_vault_risk_breakdown' for detailed risk analysis. No exclusions or prerequisites are mentioned.

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/Philidor-Labs/philidor-mcp'

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