Philidor Docs
Guides

Agent Integration

Build AI agents that check DeFi risk before making decisions.

AI agents making DeFi decisions should check risk before executing. Philidor provides the data layer for risk-aware autonomous agents.

Architecture

User Request → AI Agent → Philidor MCP/API → Risk Data → Decision

The agent receives a request (e.g., "deposit USDC into highest-yield vault"), queries Philidor for risk scores, and makes an informed decision rather than optimizing purely for yield.

The fastest path is connecting your agent to the MCP server:

claude mcp add philidor --transport http https://mcp.philidor.io

The agent automatically gets access to 10 tools, 3 resources, and 3 prompts.

Example Agent Workflow

  1. User: "Find me the best USDC vault"
  2. Agent calls search_vaults with asset=USDC, sortBy=apr_net, sortOrder=desc
  3. Agent calls get_vault_risk_breakdown for the top result
  4. Agent checks if risk tier is acceptable (Prime or Core)
  5. Agent recommends the vault with risk context

REST API Integration

For agents that don't support MCP, use the REST API directly:

async function checkVaultRisk(network: string, address: string) {
  const res = await fetch(`https://api.philidor.io/v1/vault/${network}/${address}`);
  const { data } = await res.json();
  const vault = data.vault;

  return {
    score: vault.total_score,
    tier: vault.risk_tier,
    isAudited: vault.is_audited,
    isSafe: vault.total_score >= 8.0 && vault.is_audited,
  };
}

// Agent decision logic
const risk = await checkVaultRisk('ethereum', '0x8eB67...');
if (!risk.isSafe) {
  return "This vault doesn't meet the minimum safety threshold (Prime tier, audited).";
}

Risk Guardrails

Agents should enforce risk guardrails before executing DeFi operations:

GuardrailCheckThreshold
Minimum risk tierrisk_tierPrime or Core
Audit requirementis_auditedMust be true
Minimum TVLtvl_usd> $1M
Oracle qualityAsset vector score>= 7
No recent incidentsCheck events endpointNo incidents in 90 days

Portfolio-Level Checks

Before adding a new position, check portfolio concentration:

const positions = await fetch(`https://api.philidor.io/v1/address/${wallet}/positions`);
const { data } = await positions.json();

// Check if adding this vault would exceed protocol concentration
const protocolExposure = data.positions
  .filter((p) => p.protocol_name === newVault.protocol_name)
  .reduce((sum, p) => sum + parseFloat(p.balance_usd), 0);

const totalValue = parseFloat(data.summary.total_value_usd) + depositAmount;
const concentration = (protocolExposure + depositAmount) / totalValue;

if (concentration > 0.5) {
  return 'Adding this position would exceed 50% concentration in one protocol.';
}

Future: Agent-First DeFi

Philidor's roadmap prioritizes agent-first infrastructure:

  • Structured risk data optimized for LLM consumption
  • Real-time webhook notifications for risk tier changes
  • Portfolio simulation endpoints (proposed allocation → projected risk)
  • Agent authentication for personalized risk policies

On this page

Raw