Margrav
Docs

Give your agent a March.

Margrav speaks MCP over streamable HTTP. Connect once, then your agent can read the chain, dry-run anything, and act from your March inside its Writ.

01 · Connect

Connect an MCP client

Read and simulate tools work without a key. Add the agent key from your Squire to let the agent act.

Claude Code · read-only
claude mcp add --transport http margrav https://margrav.xyz/api/mcp
Claude Code · with a Squire key
claude mcp add --transport http margrav https://margrav.xyz/api/mcp \
  --header "Authorization: Bearer mgv_YOUR_AGENT_KEY"
Cursor · ~/.cursor/mcp.json
{
  "mcpServers": {
    "margrav": {
      "url": "https://margrav.xyz/api/mcp",
      "headers": { "Authorization": "Bearer mgv_YOUR_AGENT_KEY" }
    }
  }
}
VS Code · .vscode/mcp.json
{
  "servers": {
    "margrav": {
      "type": "http",
      "url": "https://margrav.xyz/api/mcp",
      "headers": { "Authorization": "Bearer mgv_YOUR_AGENT_KEY" }
    }
  }
}

Then ask in plain words: “What is in March 0x…? Swap 0.01 ETH to USDG inside Writ 1.” The agent calls march_info, then march_swap.

02 · Agent key

Get an agent key (Squire)

  1. In the Keep, open a March and fund it.
  2. Under Squire, pick the Writ number and sign one message (EIP-191, no gas). It binds margrav.xyz, the March, the Writ and today’s UTC date.
  3. The server creates a fresh key, stores it encrypted (AES-256-GCM) and shows you the Squire address and an API key starting with mgv_, once. Only its SHA-256 is kept.
  4. Issue the Writ to the Squire address, set its caps and pool floor, and send it a little ETH for gas (0.0005 ETH covers many swaps).

Prefer your own key? Skip the Squire. Act tools return the unsigned transaction; sign it yourself and broadcast with send_signed_transaction.

03 · Perimeter

What a Writ enforces

  • Agent and expiry. One address per Writ. After expiry or revokeWrit it can do nothing.
  • Caps per token. Per transaction, per rolling 24 h (the window starts at the first spend), and a lifetime cap (0 = none).
  • Pools and a price floor. Only pools you allow, never pools with hooks. Each direction needs a floor; a swap that would sell below it reverts. A stolen agent key can never sell below your floor or past your caps.
  • Recipients. Transfers only to wallets you list. A recipient can never be the agent itself.
  • Output stays home. Swap output always lands back in the March, never in the agent’s wallet.
  • Blackout. One owner transaction freezes every Writ on the March.

When a Squire action would break any rule, the server does not send it and answers stopped_at_perimeter with the reason. If something slips past the server, the contract reverts it anyway.

04 · Tools

Tools in four groups

read

No key needed. Chain, tokens, pool and March state.

  • network_info
  • get_balance
  • get_token_balance
  • token_info
  • token_allowance
  • wallet_info
  • get_transaction
  • get_receipt
  • get_block
  • contract_code
  • read_contract
  • get_logs
  • estimate_gas
  • gas_price
  • pool_price_eth_usdg
  • swap_quote
  • pool_id
  • march_info
  • writ_info
  • remaining_today
  • chronicle
  • marches_of_owner
  • stats

simulate

Dry runs with eth_call. Plain-words result, revert reason and risk flags. Nothing is sent.

  • simulate_call
  • decode_calldata
  • decode_error
  • simulate_march_swap
  • simulate_march_transfer

prepare

For the owner. Returns an unsigned transaction and a summary; the server never signs owner actions.

  • prepare_open_march
  • prepare_deposit_eth
  • prepare_issue_writ
  • prepare_set_limit
  • prepare_set_total
  • prepare_allow_pool
  • prepare_remove_pool
  • prepare_set_floor
  • prepare_allow_recipient
  • prepare_remove_recipient
  • prepare_revoke_writ
  • prepare_blackout_on
  • prepare_blackout_off
  • prepare_withdraw
  • prepare_fund_squire

act

For the agent. With a Squire key the server checks the perimeter, simulates, then signs and sends. Without one you get the unsigned tx for your own key.

  • march_swap
  • march_transfer
  • send_signed_transaction
  • squire_whoami

Live list with schemas: /api/tools · /llms.txt

05 · HTTP API

Read API

EndpointWhat it returns
/api/statsTotals from chain events: Marches, Writs, swaps, transfers, volume, stopped at the perimeter
/api/chronicle?limit=50&march=0x…Latest March events with plain text and tx links
/api/marches/{march}Owner, balances, Blackout and every Writ with caps, floors and recipients
/api/owner/{wallet}Marches opened by a wallet
/api/pool/eth-usdgETH/USDG price from StateView and a V4Quoter reference quote
/api/token$MARG info, or “CA at launch”
/dashboard.jsonEvery feature with its proof
/proof.jsonNumbered proof transactions
/openapi.jsonOpenAPI description
/.well-known/agent-card.jsonAgent card
06 · Contracts

Contracts

Pool used by the KeepETH/USDG · Uniswap v4 · fee 100 (0.01%) · tick spacing 1 · no hooks