get_market_overview
Analyze DeFi vault market trends with total TVL, vault count, risk distribution, and protocol-level TVL data for comprehensive market assessment.
Instructions
Get a high-level overview of the DeFi vault market: total TVL, vault count, risk distribution, and TVL by protocol.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/tools/get-market-overview.ts:5-16 (handler)Main handler implementation for get_market_overview tool. Registers the tool, calls the API endpoint '/v1/stats', formats the response, and returns it as text content.export function registerGetMarketOverview(server: McpServer) { server.tool( 'get_market_overview', 'Get a high-level overview of the DeFi vault market: total TVL, vault count, risk distribution, and TVL by protocol.', {}, async () => { const result = await apiGet<{ data: any }>('/v1/stats'); const text = formatStats(result.data); return { content: [{ type: 'text' as const, text }] }; } ); }
- src/server.ts:38-39 (registration)Registration call in server.ts that activates the get_market_overview tool during server initialization.registerGetMarketOverview(server); registerExplainRiskScore(server);
- src/lib/formatters.ts:172-196 (helper)Helper function that formats the market stats API response into a human-readable markdown format with total vaults, TVL, APR, risk distribution, and TVL by protocol.export function formatStats(stats: any): string { const sections = [ '## Philidor DeFi Vault Market Overview', `\n**Total Vaults:** ${stats.totalVaults}`, `**Total TVL:** $${formatNumber(stats.totalTvl)}`, `**Average APR:** ${formatPercent(stats.avgApr)}`, `**Protocols:** ${stats.protocolCount} | **Curators:** ${stats.curatorCount} | **Chains:** ${stats.chainCount}`, ]; if (stats.riskDistribution?.length) { sections.push('\n### Risk Distribution'); for (const r of stats.riskDistribution) { sections.push(`- **${r.risk_tier}**: ${r.count} vaults, $${formatNumber(r.tvl)} TVL`); } } if (stats.tvlByProtocol?.length) { sections.push('\n### TVL by Protocol'); for (const p of stats.tvlByProtocol.slice(0, 10)) { sections.push(`- **${p.name}**: $${formatNumber(p.tvl)} (${p.vault_count} vaults)`); } } return sections.join('\n'); }
- src/api-client.ts:3-19 (helper)Helper function that makes HTTP GET requests to the Philidor API endpoint, handling errors and returning typed JSON responses.export async function apiGet<T = any>(path: string): Promise<T> { const res = await fetch(`${API_BASE}${path}`, { headers: { Accept: 'application/json' }, }); if (!res.ok) { let message: string; try { const json = (await res.json()) as Record<string, any>; message = json?.error?.message || json?.message || JSON.stringify(json); } catch { message = res.statusText || `HTTP ${res.status}`; } throw new Error(`API ${res.status}: ${message}`); } const json = await res.json(); return json as T; }