Skip to main content
Glama

AgentFi

Status: developer alpha License: Apache 2.0

Website: agentfi.cc · Run the local demo · Send feedback

Spend controls and a payment ledger for AI agents that buy paid APIs and services. AgentFi is a self-hosted, headless API and MCP layer: your agent pays an x402 (HTTP 402) resource under rules you set, the budget is enforced before anything is signed, payment and delivery are recorded separately, and payments whose outcome is uncertain are reconciled against the chain.

Developer alpha. It runs locally, on your machine. We do not offer a hosted service. This alpha deploys and uses no contracts on a public network (legacy contracts from earlier versions exist on Base mainnet; do not use them), and everything x402 was demonstrated on a local Anvil fork of Base Sepolia, not on a public testnet and not on mainnet. Do not point it at funds you care about.

Who it is for

  • Software and automation companies whose agents buy services and answer for the spend.

  • The integrator developer, who calls an HTTP/OpenAPI endpoint or an MCP tool from any agent framework.

  • The budget owner, who needs limits, a payment ledger and a clear list of exceptions.

Related MCP server: Universal Crypto MCP

The problem

An agent that can pay can also overspend, pay twice after a timeout, or pay for something it never received. Payment rails give you a wallet; they do not give you a budget, a record that separates "money moved" from "the work arrived", or an answer for "did that timed-out payment go through?".

The first flow

  1. Configure the rules. Agent policy (per-payment cap in USD, daily volume, allowed tokens and recipients, pause) and a job whose reward is the budget.

  2. The agent buys through x402. The provider of an accepted job pays a 402 resource with POST /v1/jobs/{id}/pay-resource (MCP: pay_for_resource).

  3. The budget is respected. The price is checked against the policy and the remaining budget (job reward minus counted payments) before a signature exists. Over budget is refused, not paid.

  4. Payment and delivery are tracked separately. A payment row (reserved, pending, settled, unknown, refused, failed_before_signing; the reconciliation worker may also set expired) is independent of what the resource returned and of the job's own status.

  5. Uncertain operations are reconciled. A payment whose answer was lost stays counted against the budget and is never retried blindly. The worker reads the USDC contract and settles or releases the row only on proof.

Scope of the budget. The budget is per job, and the buyer is the provider of an ACCEPTED job. There are no budgets per client or per task beyond that, and no standalone "agent buys X" endpoint. Reconciliation proves whether a payment happened; it does not recover content and never re-fetches a paid resource.

Minimal example

curl -X POST "$AGENTFI_API_URL/v1/jobs/$JOB_ID/pay-resource" \
  -H "x-api-key: $PROVIDER_AGENT_KEY" -H "content-type: application/json" \
  -d '{ "url": "https://seller.example/quote", "method": "GET", "maxAmount": "0.50" }'

Field names below follow docs/api/openapi.yaml (PayResourceResponse, ResourcePayment, ResourcePaymentError), trimmed for reading.

Settled (200): the resource was fetched and the payment recorded.

{ "payment": { "paymentId": "…", "status": "settled", "amount": "400000", "settlementTxHash": "0x…" },
  "remainingBudget": { "symbol": "USDC", "remaining": "600000", "remainingFormatted": "0.6" },
  "resource": { "status": 200, "body": { "…": "…" }, "truncated": false } }

Unknown (502, code PAYMENT_OUTCOME_UNKNOWN): no answer after signing, money may have moved. It is not retried; the nonce and window are returned for reconciliation and the amount stays counted.

{ "code": "PAYMENT_OUTCOME_UNKNOWN", "paymentId": "…",
  "authorization": { "method": "eip3009", "nonce": "0x…", "validAfter": "…", "validBefore": "…" } }

Partial delivery: the paid response was cut at the 64 KiB read limit, resource.truncated: true. The payment is still settled; delivery is a separate fact. (A server that reports no settlement comes back 200 with payment.status: "unknown" and a warning.)

Refusals before signing (402 BUDGET_EXCEEDED, 403 POLICY_VIOLATION, 400 INVALID_URL, ...) sign nothing and spend nothing. Full state machine: x402 payments.

Quickstart

Start at docs/alpha/quickstart.md. Every run is labelled with one of three modes so a demo is never mistaken for a public transaction:

Mode

What it is

SIMULATION

No chain and no funds. Shows the flow and the rules.

LOCAL FORK

A local Anvil fork of Base Sepolia with test USDC (npm run demo:x402:fork in packages/backend). The mode all current x402 evidence comes from.

PUBLIC TESTNET

Real Base Sepolia. Not done yet. A separate, gated milestone; the prepared package is x402 testnet proof (not executed).

Install = checkout. There is no package release for the x402 features yet: use a git checkout (or tag) of this repository. The npm package @agent_fi/mcp-server is at 0.5.0 (31 tools, published 2026-05-15) and does not include pay_for_resource; main has 35 tools. A 0.6.0 release is planned (roadmap). Until it ships, do not npm i for x402.

Compatibility

HTTP/OpenAPI and MCP first; framework examples are tracked in the compatibility matrix, which says per framework and version what is tested and what is not. packages/adapters holds thin tool adapters (not published to npm); see the matrix for what was tested. In the adapters the legacy DeFi tools are opt-in; the MCP server and the backend, however, expose the experimental DeFi/transaction tools and routes unconditionally, so give a paying agent only the payer-safe tool subset (see the matrix).

What works today

Status

What

Works locally (tests and local-fork demo; not a public network)

x402 exact buyer with a job budget · agent policy caps (per payment, daily volume, token and recipient allowlists, pause) · payment ledger with idempotent retries · automatic reconciliation of unknown payments (worker) · outbound target policy (no private hosts, no redirects) · MCP tools in source, incl. pay_for_resource · OpenAPI contract

Experimental

ERC-8183 job escrow and ERC-8004 reputation (local fork only) · A2A jobs · DeFi tools (swaps, Aave, Compound, ERC-4626, Curve) and GMX · ENS names · admin dashboard

Not available

Safe mode (does not work; refused in production and staging) · AgentFi contracts on any public network (the maintainer's Base mainnet pair is legacy: do not use it) · hosted service · mainnet use · upto / auth-capture payments · multi-tenant SaaS

Status and limits

  • Self-hosted by design; we do not offer a hosted service.

  • Defaults are permissive, set your own limits. A new agent's policy has maxValuePerTxUsd=1.0 and maxDailyVolumeUsd=10000; empty allowedRecipients (and token / contract lists) means any payee. Set allowedRecipients and the caps yourself before running anything that matters (see openapi.yaml).

  • Agent wallets: keys held by Turnkey when WALLET_PROVIDER=turnkey; the in-memory local provider is for development only and is refused in production and staging. The escrow evaluator's key is a raw key held by the backend.

  • Alpha: APIs and tool shapes can change. Not audited. No production funds.

  • Only USDC on a supported chain, exact scheme, EVM.

  • Details and history: STATE.md · alpha roadmap · Project history & postmortem.

Feedback and security

Documentation

Documentation hub (alpha quickstart first) · Dev quickstart · Architecture · x402 payments · API reference · MCP server

License

Apache 2.0, see LICENSE.

Available Tools

31 tools
check_inboxA

Checks for new service requests (jobs) assigned to you by other agents. Returns a list of PENDING and ACCEPTED jobs.

Inputs: no named parameters.

close_gmx_positionA

Closes (fully or partially) a perpetual position on GMX V2 (Arbitrum). Creates a MarketDecrease order. Specify the market, collateral token, size to close, and direction. Use the full position size in size_delta_usd for a complete close.

Inputs: market (required), is_long (required), size_delta_usd (required), acceptable_price (required), +2 more.

deposit_aaveA

Supplies an asset to Aave V3 lending protocol to earn yield. The supplied amount earns the current supply APY and can be withdrawn at any time. Call get_defi_rates first to check current rates.

Inputs: asset (required), amount (required), chain_id.

deposit_erc4626A

Deposits an asset into any ERC-4626 compliant vault (Yearn, Morpho, Beefy, etc.). The vault address is supplied by the caller — no pre-registration needed. Useful for any yield strategy that follows the tokenized-vault standard.

Inputs: asset (required), vault (required), amount (required), chain_id.

execute_swapA

Executes a token swap via Uniswap V3. You MUST call simulate_swap first and pass the returned simulation_id here. Returns a transaction_id to track the status with get_transaction_status.

Inputs: to_token (required), amount_in (required), from_token (required), simulation_id (required), +2 more.

get_agent_manifestA

Fetches the service manifest of another agent by their ID. Use this to understand what services another agent provides before attempting a payment or collaboration.

Inputs: agent_id (required).

get_agent_trust_reportA

Fetches the reputation and trust metrics of another agent. Use this to evaluate a peer's reliability (transaction count, age, reputation score) before collaborating.

Inputs: agent_id (required).

get_defi_ratesA

Returns current supply and borrow APY rates for major assets on Aave V3. Use this to decide where to deploy capital for yield.

Inputs: chain_id.

get_my_agent_profileA

Fetches this AgentFi agent profile using the configured API key. Use this to confirm the active identity, wallet, supported chains, tier, policy, and billing usage.

Inputs: no named parameters.

get_my_pnlA

Fetches this agent's profit and loss breakdown. Use this to inspect A2A earnings, rewards paid, protocol fees, gas costs, net P&L, and breakeven status.

Inputs: since.

get_policyA

Returns the current operational limits and restrictions for this agent. Check this to understand what transactions are allowed before attempting them.

Inputs: no named parameters.

get_token_priceA

Returns the current USD price of a token. Use this before swaps to understand value.

Inputs: token_symbol (required), chain_id.

get_transaction_statusA

Returns the current status of a submitted transaction. Poll this after execute_swap, transfer_token, deposit_aave, or withdraw_aave. Status values: PENDING, SIMULATING, QUEUED, SUBMITTED, CONFIRMED, FAILED, REVERTED.

Inputs: transaction_id (required).

get_wallet_infoA

Returns the agent's wallet address and current token balances across chains. Call this to know how much ETH, USDC, USDT, DAI, WETH the agent holds before executing transactions.

Inputs: chain_id.

list_gmx_marketsA

Lists available GMX V2 perpetual markets on Arbitrum. Returns market labels and token addresses. Use this to discover which markets are available before opening positions.

Inputs: no named parameters.

open_gmx_positionA

Opens a leveraged perpetual position on GMX V2 (Arbitrum). Creates a MarketIncrease order that is executed by a GMX keeper after oracle price update. Specify the market (e.g. "ETH/USD"), collateral amount, position size in USD, and direction (long/short). Returns a transaction ID to track with get_transaction_status.

Inputs: market (required), is_long (required), size_delta_usd (required), acceptable_price (required), +3 more.

pay_agentA

Constructs and executes a direct payment to another agent. Use this to pay for services, data, or compute provided by another AI agent.

Inputs: amount (required), reason (required), recipient_address (required), chain_id, +1 more.

post_jobA

Submits a service request (job) to another agent. Use this to delegate tasks defined in the provider's manifest. You should sign the payload before posting.

Inputs: payload (required), provider_id (required), signature, reward_token, +1 more.

search_agentsA

Finds other agents by name or wallet address. Use this to discover potential agent-to-agent (A2A) partners for collaboration or payment. Returns a list of agents with their safeAddress and active chains.

Inputs: query (required).

set_my_manifestA

Sets the agent's service manifest. Use this to broadcast your capabilities to other agents (e.g., "I provide risk analysis", "I offer liquidity data"). The manifest should be a structured JSON describing your services and their pricing/parameters.

Inputs: manifest (required).

sign_handshakeA

Signs a message with your agent wallet. Use this to prove your identity to other agents or to sign a service agreement/handshake.

Inputs: message (required).

simulate_swapA

Simulates a token swap via Uniswap V3 and returns the expected output, price impact, and gas estimate. ALWAYS call this before execute_swap to verify the trade is viable. Returns a simulation_id that must be passed to execute_swap.

Inputs: to_token (required), amount_in (required), from_token (required), chain_id, +1 more.

supply_compoundA

Supplies an asset to Compound V3 (Comet USDC market) to earn yield. Each Compound V3 market is single-asset; the USDC market accepts USDC as the base asset plus whitelisted collateral (e.g. WETH, WBTC). Available on Mainnet, Base, Arbitrum, Polygon.

Inputs: asset (required), amount (required), chain_id.

swap_curveA

Swaps between two assets on a Curve StableSwap pool. Ideal for stablecoin-to-stablecoin conversions (USDC↔USDT↔DAI) with minimal slippage. The caller must supply the pool address and the indices of the input/output tokens within that pool. Assumes fromToken has already been approved to the pool; simulation will fail clearly if approval is missing.

Inputs: pool (required), amount_in (required), min_amount_out (required), to_token_index (required), +4 more.

transfer_tokenB

Transfers ETH or an ERC-20 token to any Ethereum address. Use "ETH" as the token identifier to send native ETH, or provide a contract address for ERC-20.

Inputs: to (required), token (required), amount (required), chain_id.

update_job_statusA

Updates the status of a job (Accept, Complete, Fail). Use this to manage your workflow as a service provider.

Inputs: job_id (required), status (required), result.

update_policyA

Updates the agent's own operational policy. The change applies IMMEDIATELY — there is no operator approval step. The operator can audit and revert via the admin panel. Use this when you need higher limits, more allowed tokens, or contract whitelisting to complete a mission. Provide a reason for audit — it is logged but does not gate the change.

Inputs: reason (required), allowed_tokens, allowed_contracts, max_value_per_tx_eth.

verify_handshakeB

Verifies a signature provided by another agent. Use this to confirm that a peer truly controls the wallet address they claim to represent.

Inputs: address (required), message (required), signature (required).

withdraw_aaveB

Withdraws a previously supplied asset from Aave V3. Pass "max" as the amount to withdraw your entire position.

Inputs: asset (required), amount (required), chain_id.

withdraw_compoundB

Withdraws a previously supplied asset from Compound V3 (Comet USDC market). Pass "max" as the amount to withdraw your entire balance.

Inputs: asset (required), amount (required), chain_id.

withdraw_erc4626A

Withdraws assets from any ERC-4626 compliant vault. Use "max" to attempt a full withdrawal (vault may still limit to available liquidity).

Inputs: asset (required), vault (required), amount (required), chain_id.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A3.9/5.0

    Scored across 31 tools

    Disambiguation5/5

    Each tool targets a unique action and domain (A2A jobs, peer discovery, wallet management, DeFi protocols). Overlaps like multiple yield protocols are clearly separated by protocol-specific names and descriptions.

    Naming Consistency5/5

    All tools follow a consistent verb_noun pattern with underscores, e.g., `check_inbox`, `deposit_aave`, `get_agent_manifest`. No mixed conventions or unclear names.

    Tool Count4/5

    31 tools cover a broad domain (A2A + multi-protocol DeFi), which justifies the count. Slightly heavy but each tool serves a distinct purpose; no glaring redundancies.

    Completeness4/5

    Core A2A workflows (post/accept/complete jobs, payments, identity verification) and DeFi operations (swaps, lending, perps, rates) are well-covered. Minor gaps like job cancellation or agent deregistration exist but are acceptable.

    Maintenance

    ActivityActive
    ResponsivenessLimited data

    Related MCP Connectors

    Related MCP Servers