[ Documentation · v0.7 ]

Lydion MCP

Lydion is an open-source Model Context Protocol server that gives AI agents safe, policy-guarded access to on-chain value. Plug it into Claude, Cursor or any MCP client, and your agent can read markets, check wallets, scan tokens for scams and price x402 payments. Every spend goes through a policy engine that you configure, and nothing the agent says can change it.

Lydion landing page hero: the 3D maze sphere and the Lydion Guard card
The Lydion landing page. The Guard card and feed tags over the hero are illustrations, not live traffic.

At a glance

WhatMCP server (Node.js, ESM, zero build step)
ForAI agents that need market data, wallet reads, risk checks and spend control
Tools25: 16 read-only (incl. 4 Equity Rails), 9 for execution and approvals
ExtensionLydion Guard: the same checks in your browser, before every signature
ChainsEthereum, Base, Arbitrum, Optimism, Polygon, BNB Chain, Avalanche, Robinhood Chain, plus Base Sepolia and Sepolia
DataPublicNode RPC · GoPlus Security · DefiLlama · CoinGecko · KyberSwap · Yahoo / Nasdaq (equities). Free, no API keys
LicenseMIT

Why Lydion exists

AI agents are turning into economic actors. They call paid APIs, buy data, and soon will trade and pay each other. To do that they need money, and today the usual answer is to hand the model a private key or an exchange API key.

That is dangerous. An LLM can be prompt-injected: a malicious web page, token name or email can tell it to "send everything to 0x…". With a raw key, nothing stops it.

Lydion splits capability from authority. The agent gets rich, typed tools to understand the market. Authority to spend stays in a policy engine on your machine, configured by you and enforced in code.

Raw private key in the agent

  • Any prompt injection can drain funds
  • No spending limits
  • No idea whether a token is a scam
  • No audit trail
  • Each agent re-implements web3 plumbing

Agent + Lydion MCP

  • Limits enforced server-side, so prompts can't change them
  • Daily, per-transaction, per-counterparty and hard caps, plus hourly velocity limits
  • Risk scan before every buy
  • Append-only, hash-chained spend ledger
  • One server works with any MCP client

How it works

Lydion runs as a local process next to your MCP client and talks to it over stdio. The client (Claude Desktop, Cursor, Claude Code and others) lists Lydion's tools to the model. When the model decides to call one, the request flows through Lydion to public data sources, and every spend passes through the policy engine first.

AI agent Claude · Cursor · any MCP client Lydion MCP server Typed tools market · wallets · risk · x402 Policy engine allow · needs_approval · deny Spend ledger ~/.lydion-mcp/ledger.jsonl · hash-chained CoinGecko prices · trending EVM RPC (8 chains) balances · gas GoPlus Security token & address risk x402 merchants HTTP 402 paywalls call result runs locally · your keys never leave your machine
Request flow: agent → MCP client → Lydion → data sources. Spends are always evaluated by the policy engine before any action.
  1. Discover. On start, the client asks Lydion for its tool list. Each tool has a name, description and JSON schema, so the model knows when and how to call it.
  2. Call. The model calls a tool with arguments. Lydion validates them (bad addresses, unknown chains and negative amounts are rejected before anything runs).
  3. Guard. For anything involving money, Lydion evaluates the policy and returns a decision with human-readable reasons.
  4. Answer. Results come back as structured JSON. The model turns them into a plain-language answer for you.

Quick start

Requirements: Node.js 18.17+ and git. No API keys needed. The 16 read-only tools work without a wallet; the execution tools need an agent wallet (see Execution & approvals).

Option A · npm (recommended)

terminal
npx -y lydion-mcp
Not on npm yet The lydion-mcp package is about to be published. Until it is, npx -y lydion-mcp will fail: use Option B, which works today.

Option B · from source (works today)

terminal · one line
git clone https://github.com/lydion-mcp/lydion && cd lydion-mcp/server && npm install && node src/index.js

Step by step, with the test suite:

terminal
# 1. get the code
git clone https://github.com/lydion-mcp/lydion
cd lydion-mcp/server

# 2. install (three dependencies: MCP SDK, zod, viem)
npm install

# 3. verify: every read tool against live data, then the policy, equities, execution
#    (local x402 merchant, no real funds), smart account, allowances, grants, x402 and console suites
npm test

# 4. or run one suite on its own, e.g. execution, approvals, x402 and HTTP
node test/execution.js

The smoke test prints the tool list and every read tool’s answer, ending with all calls completed; each later suite ends with its own line, such as all execution checks passed. A failed check prints ✕ and stops the run.

Terminal output of npm test showing live prices, gas, balances and a token risk scan
Real output of npm test: live ETH/TAO/BTC prices, Base gas, a wallet balance, a USDC risk scan, and input validation rejecting a bad address.
Tip To explore tools interactively, run npm run inspect. It opens the official MCP Inspector in your browser.
Troubleshooting Run node src/index.js doctor. It checks Node, limits, execution chains, RPC, the approval channel and the ledger, and prints one fix per problem (exit code 1 if anything is broken). See Owner console.

Client setup

From source (works today), use the absolute path to server/src/index.js, as below. Once Lydion is published to npm, you can replace "command": "node", "args": ["…/index.js"] with "command": "npx", "args": ["-y", "lydion-mcp"].

Settings → Developer → Edit Config, then add:

claude_desktop_config.json
{
  "mcpServers": {
    "lydion": {
      "command": "node",
      "args": ["/absolute/path/lydion-mcp/server/src/index.js"],
      "env": {
        "LYDION_DAILY_LIMIT_USD": "50",
        "LYDION_ALLOWLIST": "uniswap,aave,kyberswap"
      }
    }
  }
}

Restart the app. "lydion" with 25 tools appears in the tools menu.

terminal
claude mcp add lydion \
  -e LYDION_DAILY_LIMIT_USD=50 \
  -- node /absolute/path/lydion-mcp/server/src/index.js

Check with claude mcp list, or type /mcp inside a session.

Create .cursor/mcp.json in your project (or ~/.cursor/mcp.json globally):

.cursor/mcp.json
{
  "mcpServers": {
    "lydion": { "command": "node", "args": ["/absolute/path/lydion-mcp/server/src/index.js"] }
  }
}

Any client that supports MCP over stdio works: Windsurf, Zed, Cline, Continue, the OpenAI Agents SDK and custom agents built on the MCP SDK. Point it at node …/server/src/index.js. Environment variables configure the policy (see Configuration).

Illustration of an MCP client conversation where the agent scans a token, checks policy and refuses a risky purchase
What a session looks like: the agent scans the token, asks the policy engine, and advises against the purchase. (Illustrative conversation; the token address is shortened.)

Tool reference

Every tool returns JSON as text content. Errors come back with isError: true and a readable message, so the agent can recover. Tools marked read-only never move funds; tools marked write · policy-gated can, only through the execution gate.

Tool catalog on the landing page showing live and upcoming tools
The tool catalog on the landing page: the 25 tools documented below.

get_price

read-onlymarket

Spot price in USD, 24h change, market cap and 24h volume for one or more tokens. Accepts common symbols (ETH, TAO, SOL…) or CoinGecko ids. Unknown symbols are resolved through CoinGecko search.

ParamTypeDescription
tokens requiredstring[] (1–25)Symbols or ids, e.g. ["ETH", "bittensor"]
response
[{ "token": "ETH", "id": "ethereum", "price_usd": 1620.31, "change_24h_pct": -7.18,
   "market_cap_usd": 198124467910, "volume_24h_usd": 19805715629 }]

Ask your agent: "What are ETH, SOL and TAO doing today?"

get_gas

read-onlymarket

Current gas price on an EVM chain, plus the estimated USD cost of a simple transfer (21k gas) and a typical swap (150k gas).

ParamTypeDescription
chainenumethereum (default), base, arbitrum, optimism, polygon, bsc, avalanche, robinhood, base-sepolia, sepolia
response
{ "chain": "base", "gas_gwei": 0.006, "native_usd": 1620.05, "transfer_usd": 0.0002, "swap_usd": 0.0015 }

Ask: "Is it cheaper to swap on Base or Arbitrum right now?"

get_balance

read-onlywallets

Native balance of any address, valued in USD at the current price.

ParamTypeDescription
address required0x… (40 hex)Wallet or contract address
chainenumDefault ethereum
response
{ "address": "0xd8dA…6045", "chain": "ethereum", "symbol": "ETH", "balance": "5.79956339", "value_usd": 9395.58 }

scan_token

read-onlyrisk

Security scan of a token contract. Lydion fetches GoPlus Security data and turns it into a 0–100 risk score (higher means riskier), a verdict and a list of flags. Agents should run it before buying any unfamiliar token.

ParamTypeDescription
address required0x…Token contract
chainenumDefault ethereum
CheckPoints
Honeypot (cannot sell)+60
Owner can modify balances+25
Cannot sell entire balance+25
Source not verified+20
Mintable · hidden owner · self-destruct · buy/sell tax > 10%+15 each
Top-10 holders > 60%+12
Blacklist · pausable transfers · < 50% LP locked+10 each
Upgradeable proxy+8

Verdicts: ≥ 60 DANGEROUS · 30–59 CAUTION · < 30 no major red flags.

response · USDC on Base
{ "token": { "name": "USD Coin", "symbol": "USDC", "holders": 11788779 },
  "risk_score": 8, "verdict": "No major red flags found", "flags": ["upgradeable proxy"],
  "taxes": { "buy_pct": 0, "sell_pct": 0 }, "top10_holders_pct": 28.11, "source": "GoPlus Security" }

check_address

read-onlyrisk

Reputation check for an address: phishing, drainer contracts, sanctions, mixers, honeypot deployers and other malicious activity. Run it before sending funds anywhere new.

ParamTypeDescription
address required0x…Address to check
response
{ "address": "0xd8dA…6045", "flagged": false, "flags": [], "source": "GoPlus Security" }

swap_quote

read-onlytradingnew in 0.2

Best-route swap quote across DEXs from the KyberSwap aggregator, with Lydion's checks built in: price impact, gas as a share of the trade, a risk scan of the token being bought (anything outside a curated list of majors goes through the same scoring as scan_token) and the policy decision. Pass sender and Lydion also builds the exact router transaction and runs it through simulate_tx, so the agent sees what it would receive before anything is signed.

ParamTypeDescription
chainenumDefault ethereum
sell requiredstringSymbol (ETH, USDC, WETH…) or contract address
buy requiredstringSymbol or contract address
amount requireddecimal stringAmount of sell in whole units, e.g. "0.25"
slippage_bpsint 1–500Default 50 (0.5%). Sets min_out
sender0x…Wallet that would swap. Enables calldata build + simulation
fund_senderbooleanWhat-if mode: simulate as if the sender held enough native token
response (trimmed)
{ "verdict": "NEEDS_APPROVAL",
  "sell": { "symbol": "ETH", "amount": "0.05" },
  "buy": { "symbol": "USDC", "amount_out": "85.495379", "min_out": "85.067902" },
  "price_impact_pct": -0.048, "gas_usd": 0.0049,
  "route": { "aggregator": "KyberSwap", "exchanges": ["lunarbase"], "max_hops": 1 },
  "checks": [
    { "check": "price_impact", "status": "pass", "detail": "-0.048% (healthy)" },
    { "check": "token_risk", "status": "pass", "detail": "USDC is a curated asset" },
    { "check": "policy", "status": "warn", "detail": "needs_approval: above per-transaction limit of $25" },
    { "check": "simulation", "status": "pass", "detail": "succeeds on block 60775860, receives 85.495379 USDC" } ] }

Verdicts: OK_TO_SWAP (every check passes), REVIEW (warnings, e.g. thin liquidity or a token with elevated risk), NEEDS_APPROVAL (policy wants a human), DO_NOT_SWAP (any check fails: impact above 5%, risky token, policy deny, or the simulation reverts).

Ask: "Quote 0.5 ETH to USDC on Base and tell me if it's safe to do."

simulate_tx

read-onlyrisknew in 0.2

Dry-runs any EVM transaction against live chain state (eth_simulateV1 with transfer tracing) and reports what it would actually do to the sender: assets leaving and entering with USD values, approvals granted, NFTs leaving, the revert reason, gas cost, counterparty reputation and the policy decision. This is the answer to the most common way agents and people lose funds: signing calldata they did not write.

ParamTypeDescription
chainenumDefault ethereum
from required0x…Sender (the agent wallet)
to required0x…Destination contract or wallet
datahexCalldata. Default "0x" (plain transfer)
valuedecimal stringNative value in whole units, e.g. "0.01"
fund_senderbooleanWhat-if mode: hypothetical native balance for the simulation
response · unlimited USDC approval to a plain wallet
{ "verdict": "DO_NOT_SIGN", "status": "success", "method": "approve(address,uint256)",
  "asset_changes": [],
  "approvals": [{ "symbol": "USDC", "spender": "0x2222…2222", "amount": "unlimited", "spender_is_contract": false }],
  "warnings": [{ "severity": "high", "message": "unlimited USDC approval to a wallet (not a contract) 0x2222…2222" }],
  "gas": { "used": 55785, "cost_usd": 0.0006 } }
VerdictWhen
SAFE_TO_SIGNSucceeds, no warnings, policy allows
REVIEWMedium warnings: unlimited approval to a contract, NFT leaving, unpriced asset
NEEDS_APPROVALPolicy asks for a human (over a limit, or value that could not be priced)
DO_NOT_SIGNHigh warnings: approval to a plain wallet, setApprovalForAll, flagged counterparty, or policy deny
WILL_REVERTThe transaction fails on-chain and would only burn gas; the reason is included

Fail-closed by design: if an outgoing asset cannot be priced, the policy decision is raised to needs_approval instead of being waved through as a $0 micro-payment.

simulate_tx in the live playground flagging an unlimited USDC approval to a plain wallet
The same check in the landing-page playground, on live Base state.

Ask: "A dApp wants me to sign this. What does it actually do?"

policy_check

read-onlypolicy

Asks the policy engine whether a proposed spend is allowed. If a recipient is given, Lydion checks its reputation automatically, and a flagged recipient is always denied. Agents must call this before moving funds and respect the answer.

ParamTypeDescription
value_usd requirednumber ≥ 0USD value of the spend
recipient0x…Recipient address (reputation-checked)
merchantstringProtocol / domain, e.g. uniswap, api.example.com
response
{ "decision": "needs_approval", "reasons": ["above per-transaction limit of $25"],
  "remainingTodayUsd": 50, "counterparty": "api.example.com",
  "lastHour": { "transactions": 0, "microPayments": 0 }, "recipient_flags": [] }
response · covered by a spend grant
{ "decision": "allow", "reasons": ["covered by grant G7C21E0 ($20.00 of $25 left, expires 2026-11-24 13:02 UTC)"],
  "coveredReasons": ["owner requires approval for non-micro spends"], "grant": "G7C21E0",
  "remainingTodayUsd": 45, "counterparty": "api.meteo.xyz", "lastHour": { "transactions": 1, "microPayments": 0 }, "recipient_flags": [] }

counterparty is the lowercased merchant, or the recipient when there is no merchant: budgets, lists and grants are matched against it. lastHour counts the spends in the rolling 60 minutes the velocity limits look at. When a spend grant covers the spend, grant is its id and coveredReasons lists the approval reasons it waived. Swap grants are scoped to the sold token and only match inside swap_quote / execute_swap, not here.

See Policy engine for the full decision logic.

x402_quote

read-onlypayments

Requests a URL. If the server answers HTTP 402 Payment Required using the x402 protocol, Lydion parses the payment options (scheme, network, asset, pay-to address, amount) and returns the policy decision for the cheapest priced one. It reads the requirements exactly like x402_pay: the base64 PAYMENT-REQUIRED header (x402 v2) when present and valid, otherwise the JSON body (v1). Only USDC on Base or Base Sepolia, the options x402_pay can settle (payable: true), is priced in USD; other assets are listed with amount_usd: null. It does not pay. To pay, use x402_pay.

ParamTypeDescription
url requiredURLResource to quote
response · paywalled resource
{ "url": "https://api.meteo.xyz/v1/dubai", "status": 402, "paywalled": true, "x402_version": 2,
  "options": [{ "scheme": "exact", "network": "eip155:8453", "asset": "0x8335…2913", "pay_to": "0x…",
    "amount_atomic": "20000", "amount_usd": 0.02, "payable": true, "description": "Dubai weather" }],
  "policy": { "decision": "allow", "reasons": ["within micro-payment allowance ($1)"] } }

spending_report

read-onlypolicy

Today's spend (UTC day), the remaining budget, today's ledger entries, spend per counterparty (with its budget, if one is set), spends in the last hour against the velocity limits, per-day totals for recent days, the active spend grants and the active policy limits.

ParamTypeDescription
daysinteger 1–30How many UTC days of per-day totals to return in history, newest first. Default 1 (today)
response · days: 2
{ "day": "2026-11-20", "spentUsd": 1.5, "remainingUsd": 48.5,
  "entries": [{ "seq": 7, "at": "2026-11-20T09:12:04.511Z", "valueUsd": 1.5, "counterparty": "api.example.com", "memo": "x402 api.example.com 0x…" }],
  "counterparties": { "api.example.com": { "spentUsd": 1.5, "limitUsd": 5 } },
  "lastHour": { "transactions": 1, "microPayments": 0, "maxTransactions": 20, "maxMicroPayments": 10 },
  "history": [{ "day": "2026-11-20", "spentUsd": 1.5, "transactions": 1 }, { "day": "2026-11-19", "spentUsd": 12.04, "transactions": 6 }],
  "ledger": { "file": "~/.lydion-mcp/ledger.jsonl", "entries": 7, "head": "9c1f…" },
  "grants": [{ "id": "G7C21E0", "counterparty": "api.example.com", "maxUsdTotal": 25, "spentUsd": 1.5, "remainingUsd": 23.5, "expiresAt": "2026-11-20T10:12:00.000Z", "scope": { "kind": "counterparty" }, "status": "active", … }],
  "policy": { "dailyLimitUsd": 50, "perTxLimitUsd": 25, "hardCapUsd": 500, "microAllowanceUsd": 1, "maxTxPerHour": 20, "maxMicroPerHour": 10, "counterpartyLimits": { "api.example.com": 5 }, "requireApproval": true, … } }

verify_ledger

read-onlypolicy

Recomputes the hash chain of the spend ledger from the first entry. ok is false if any entry was edited, removed, reordered or inserted; firstBadSeq is the first entry that no longer verifies and head is the hash of the last entry that does. Keep a copy of head somewhere else (a note, a commit, a chat message) and you can later prove the history up to that point was not rewritten. No parameters.

response · intact
{ "ok": true, "entries": 7, "head": "9c1f…", "file": "~/.lydion-mcp/ledger.jsonl" }
response · entry 3 was edited
{ "ok": false, "entries": 7, "firstBadSeq": 3, "error": "hash does not match the entry", "head": "41d0…", "file": "~/.lydion-mcp/ledger.jsonl" }

Equity tools (new in 0.4)

Read-only tools for tokenized stocks: the real exchange price, each verified tokenized version, the Parity Guard verdict and the US market calendar. See Equity Rails.

get_equity_quote

read-onlyequitiesnew in 0.4

Reference price for a US stock or ETF from Yahoo Finance (Nasdaq API as fallback): price, previous close, change, exchange, timestamp and the current session. For tickers with a verified tokenized version, it adds each token's on-chain price (DefiLlama by contract, CoinGecko fallback), its premium against the share, the price age and the contract addresses.

ParamTypeDescription
ticker requiredstringUS ticker, e.g. TSLA, AAPL, NVDA, SPY (case-insensitive)
response (trimmed)
{ "ticker": "TSLA", "name": "Tesla, Inc.", "price": 385.03, "previous_close": 380.11, "change_pct": 1.294,
  "source": "Yahoo Finance", "market_open": true, "session": "regular",
  "tokenized": [
    { "token": "TSLAx", "issuer": "Backed · xStocks", "price_usd": 384.53, "premium_pct": -0.13, "source": "DefiLlama" },
    { "token": "TSLAon", "issuer": "Ondo Global Markets", "price_usd": 385.29, "premium_pct": 0.067, "source": "DefiLlama" } ] }

Ask: "What is Tesla at, and what do the tokenized versions trade at on-chain?"

parity_check

read-onlyequitiesnew in 0.4

Parity Guard. Compares every verified tokenized version of a stock with the real share and returns a verdict per token. Agents should run it before buying any tokenized stock and must not buy on ABOVE_BAND.

ParamTypeDescription
ticker requiredstringUS ticker
band_pctnumberAllowed premium in percent. Default LYDION_EQ_PARITY_BAND_PCT, or 0.5
VerdictMeaning
WITHIN_BANDPremium or discount inside the band: ok to buy at this price
ABOVE_BANDThe token costs more than the share by more than the band: block buys
BELOW_BANDDiscount beyond the band: flag it, it can mean a depeg, a redemption problem or a stale price
NO_PRICE / NO_REFERENCEOne side of the comparison is missing: do not trade
NO_TOKENIZED_VERSIONThe ticker is not in the verified registry yet
response
{ "ticker": "TSLA", "band_pct": 0.5, "market_open": true, "session": "regular",
  "reference": { "price": 386.37, "kind": "live", "source": "Yahoo Finance" },
  "tokens": [
    { "token": "TSLAx", "premium_pct": -0.477, "verdict": "WITHIN_BAND", "action": "ok to buy at this price" },
    { "token": "TSLAon", "premium_pct": -0.28, "verdict": "WITHIN_BAND", "action": "ok to buy at this price" } ] }

When the US market is closed, reference.kind is "last close" and a note explains that tokens keep trading 24/7, so a gap can reflect after-hours news. The band is never widened silently. Token prices older than an hour are marked stale.

Ask: "Is NVDAx fairly priced right now? Only buy if it is within 0.5% of the real share."

market_hours

read-onlyequitiesnew in 0.4

Whether the US regular session is open now, the current session (pre-market 04:00–09:30, regular 09:30–16:00, after-hours 16:00–20:00 ET, closed), when it closes or next opens in UTC and New York time, and the next holidays and 13:00 ET early closes. Daylight saving time is handled through the America/New_York time zone.

ParamTypeDescription
marketenumXNYS (default) or XNAS: the same calendar
response (trimmed)
{ "market": "XNYS", "open": true, "session": "regular",
  "now": { "new_york": "Tue, Nov 24, 15:00 EST" },
  "closes": { "utc": "2026-11-24T21:00:00.000Z", "in_minutes": 60 },
  "upcoming": [ { "date": "2026-11-26", "name": "Thanksgiving Day", "type": "closed" },
                { "date": "2026-11-27", "name": "Day after Thanksgiving", "type": "early close 13:00 ET" } ] }

The calendar is computed from the NYSE rules: ten holidays a year (Saturday holidays move to Friday, Sunday ones to Monday, except New Year's Day on a Saturday) and early closes on July 3 when July 4 falls Tuesday to Friday, the day after Thanksgiving and December 24 when it falls Monday to Thursday. Unit tests pin the 2026 and 2027 dates.

equity_policy_check

read-onlyequitiesnew in 0.5

Would buying this tokenized share pass the equity guardrails? Checks market hours, Parity Guard for the exact token, the per-trade cap (LYDION_EQ_MAX_TRADE_USD) and the per-ticker position cap including current holdings (LYDION_EQ_MAX_POSITION_USD). Returns allow, needs_approval or deny with every check. execute_swap applies the same rules automatically.

ParamTypeDescription
ticker requiredstringUS stock ticker, e.g. TSLA
value_usd requirednumberSize of the intended buy in USD
tokenstringTokenized version, e.g. TSLAx or TSLAon (default: the first verified one)
chainenumChain to read current holdings on

Ask: "Could I buy $80 of TSLA on-chain right now within my rules?"

Execution tools (new in 0.3)

These nine tools are the only ones that can move funds or touch approvals. Every action goes through the same gate: simulation on live state, the policy engine, a human approval when the policy asks for one, then signing. They run only on chains the owner enabled (default base-sepolia). See Execution & approvals.

wallet_info

read-onlyexecution

The agent wallet address, where it may execute, its native balance on each enabled chain, and how approvals reach the owner. Never returns key material. No parameters.

response
{ "configured": true, "address": "0xB6c6…445a", "key_source": "file",
  "execution_enabled": true, "execution_chains": ["base-sepolia"],
  "balances": [{ "chain": "base-sepolia", "testnet": true, "balance": "0.05", "symbol": "ETH" }],
  "approvals": "telegram + cli" }

Without a wallet it returns { "configured": false } with the setup command for the owner.

send_transaction

write · policy-gatedexecution

Sends a transaction from the agent wallet. It is simulated first with simulate_tx and blocked if it would revert or looks malicious (WILL_REVERT, DO_NOT_SIGN). Then the policy engine decides. If a human must approve, the tool returns pending_approval with an approval_id; once the owner approves, the agent calls it again with the same arguments plus approval_id. Simulation warnings (verdict REVIEW) also require approval.

ParamTypeDescription
chainenumDefault base-sepolia. Must be in LYDION_EXECUTION_CHAINS
to required0x…Recipient wallet or contract
valuedecimal stringNative amount in whole units. Default "0"
datahexCalldata. Default "0x" (plain transfer)
approval_id6 hex charsAn approval the owner granted for exactly these arguments
response · sent
{ "status": "sent", "hash": "0x9f3c…e21a", "onchain_status": "confirmed", "block": 19204411, "gas_used": 21000,
  "explorer": "https://sepolia.basescan.org/tx/0x9f3c…e21a", "value_usd": 0.85, "approved_by": "policy" }
response · blocked by simulation
{ "status": "blocked", "reason": "WILL_REVERT", "simulation": { "revert_reason": "EVM error: OutOfFunds", … } }

onchain_status comes from the receipt: confirmed, reverted, or pending if no receipt arrived within 45 seconds. The spend is written to the ledger as soon as the transaction is broadcast.

Ask: "Send 0.001 test ETH to 0x2222…2222 on Base Sepolia."

execute_swap

write · policy-gatedtrading

Swaps at the best DEX route from the agent wallet. It runs swap_quote with the agent wallet as sender (price impact, token risk, policy, simulation), goes through the approval flow, then rebuilds the route right before sending so the price is fresh; min_out still protects the trade. Swap routes come from KyberSwap, which does not cover testnets, so this tool needs a mainnet chain the owner opted in to.

Selling an ERC-20 (since v0.3.1): if the router's allowance is lower than the amount, the swap becomes a two-step plan: approve the router for the exact amount (never unlimited), then swap. Both steps are simulated together in one eth_simulateV1 block, so the swap is checked against the new allowance before anything is signed, and one human approval covers both steps. The approve is sent first and must confirm before the swap is sent. If the swap then fails, the response says so; the exact allowance stays in place, covers only this amount and is used by the next identical swap. Native-token sells are a single step.

ParamTypeDescription
chainenumDefault base-sepolia; in practice a mainnet listed in LYDION_EXECUTION_CHAINS
sell requiredstringNative symbol (ETH), curated symbol (USDC) or contract address
buy requiredstringSymbol or contract address
amount requireddecimal stringAmount to sell in whole units
slippage_bpsint 1–300Default 50 (0.5%)
approval_id6 hex charsApproval granted for exactly these arguments
response · sent
{ "status": "sent", "hash": "0x41d0…77b2", "sold": { "symbol": "ETH", "amount": "0.01" },
  "bought_min": "16.98", "symbol": "USDC", "approved_by": "3F9A1C" }
response · ERC-20 sell from an unfunded wallet, blocked before signing
{ "status": "blocked", "reason": "simulation reverts: TransferHelper: TRANSFER_FROM_FAILED (selling an ERC-20 needs enough USDC in the wallet)",
  "plan": [
    { "step": "approve", "symbol": "USDC", "spender": "0x6131…37b5", "amount": "5", "exact": true, "current_allowance": "0" },
    { "step": "swap", "to": "0x6131…37b5" } ],
  "quote": { "simulation": { "steps": [ { "method": "approve(address,uint256)", "status": "success" }, { "method": "swap(...) · KyberSwap router", "status": "reverted" } ] } } }

The approval is bound to chain, sell, buy, amount and slippage_bps, not to the calldata, because the route is rebuilt before sending. Other statuses: failed with step: "approve" (the approve did not confirm, the swap was not sent) or step: "swap" (the swap reverted after the approve was mined).

x402_pay

write · policy-gatedpayments

Fetches a URL. If it answers HTTP 402, Lydion picks a supported option (scheme exact, USDC on Base or Base Sepolia), checks max_usd and the policy, signs an EIP-3009 TransferWithAuthorization with the agent wallet, retries the request with the payment, and returns the paid content plus the settlement receipt. The merchant's facilitator submits the transfer on-chain; the agent pays no gas.

ParamTypeDescription
url requiredURLResource to fetch and pay for
max_usdnumber ≤ 1000Refuse if the price is above this
approval_id6 hex charsApproval granted for exactly this payment
ProtocolRequirements arrive inPayment sent inReceipt in
x402 v1JSON body (maxAmountRequired, network base-sepolia)X-PAYMENT header, base64 JSONX-PAYMENT-RESPONSE
x402 v2PAYMENT-REQUIRED header, base64 (amount, network eip155:84532)PAYMENT-SIGNATURE header, base64 JSONPAYMENT-RESPONSE

The EIP-712 domain (name, version) is read from the token contract itself, not from the 402 response: USDC on Base mainnet signs as "USD Coin", on Base Sepolia as "USDC", both version "2". A signature with the wrong name would be rejected by the token. Each authorization uses a random 32-byte nonce and is valid for the merchant's maxTimeoutSeconds.

response · paid
{ "status": "paid", "http_status": 200, "amount_usd": 0.02, "network": "base-sepolia", "pay_to": "0x2222…2222",
  "receipt": { "success": true, "transaction": "0xabab…abab", "network": "base-sepolia", "payer": "0xB6c6…445a" },
  "approved_by": "policy", "content_type": "application/json", "body": "{\"city\":\"Dubai\",\"temp_c\":31}" }

Other statuses: free (no 402, body returned as is), blocked (no supported option, above max_usd, policy deny, or an invalid approval), pending_approval (see the approval flow) and payment_failed (the merchant rejected the payment; nothing is recorded in the ledger).

Ask: "Buy today's weather data for Dubai from api.meteo.xyz, max 5 cents."

list_allowances

read-onlyexecution

Active ERC-20 approvals a wallet has granted, by default the agent wallet, each with a verdict. Rows come from the GoPlus token approval index and are checked against a live allowance(owner, spender) call, so an approval already revoked on-chain is dropped even if the index lags. Pairs passed in pairs are read on-chain directly: GoPlus has no index for testnets, so on Base Sepolia this is how you check an allowance. Spender type comes from the chain (eth_getCode), reputation from GoPlus and check_address.

ParamTypeDescription
chainenumDefault base-sepolia. Any supported chain; listing never signs
owner0x…Wallet to inspect. Default: the agent wallet
pairs[{ token, spender }]Up to 50 token/spender pairs to read on-chain as well
VerdictWhen
REVOKESpender is flagged (GoPlus approval data or address reputation), unlimited approval to a wallet, or an unverified contract
REVIEWUnlimited approval to a contract, or any approval to a wallet
OKLimited approval to a contract
response
{ "chain": "ethereum", "owner": "0x176f…0a132",
  "summary": { "active": 16, "revoke": 1, "review": 7, "ok": 8 },
  "allowances": [{ "verdict": "REVOKE", "reasons": ["spender is flagged: honeypot related address, doubt list"],
    "token": { "address": "0x4d5f…14e8", "symbol": "aEthWETH", "decimals": 18 }, "spender": "0x8934…b2b9",
    "allowance": { "raw": "13002843345627627870220", "human": "13002.84334562762787022" },
    "spender_risk": { "is_contract": true, "verified": true, "flagged": true, "flags": [ … ] }, "source": "goplus", "live_checked": true }, … ],
  "sources": { "goplus": "ok (16 approvals)", "rpc_pairs": 0 },
  "next": "Call revoke_allowance with the token and spender of each REVOKE row." }

An amount of 2255 or more is reported as "unlimited". When GoPlus is unavailable or rate-limited the response carries a warning and only pairs are checked; pairs whose allowance() call fails are listed under unreadable.

Ask: "Which token approvals does your wallet still have open? Revoke the risky ones."

revoke_allowance

write · policy-gatedexecution

Sets an allowance of the agent wallet back to zero by sending approve(spender, 0) to the token. A revoke moves no value, but it is still a signing action, so it runs exactly the send_transaction gate: execution chains, LYDION_EXECUTION, simulation, policy and owner approval. Under the default policy a $0 call fits the micro-allowance and is sent without a human; if the owner's policy or a simulation warning asks for approval, the tool returns pending_approval and says so. If the allowance is already zero it returns nothing_to_revoke and signs nothing.

ParamTypeDescription
chainenumDefault base-sepolia. Must be in LYDION_EXECUTION_CHAINS
token required0x…ERC-20 token contract
spender required0x…Spender whose allowance to revoke
approval_id6 hex charsApproval granted for exactly this revoke
response · sent
{ "status": "sent", "hash": "0x5be1…90c4", "onchain_status": "confirmed", "approved_by": "policy",
  "revoke": { "token": "0x036c…cf7e", "symbol": "USDC", "spender": "0x3333…3333", "previous_allowance": "unlimited", "calldata": "0x095ea7b3…" } }

The approval is bound to the calldata, so an approval for one spender cannot be used to revoke (or re-approve) another. Statuses: sent, pending_approval, blocked and nothing_to_revoke.

approval_status

read-onlyapprovals

Status of one approval request: pending, approved, denied or expired. The agent can only read approvals; no tool can grant one.

ParamTypeDescription
approval_id required6 hex charsId returned with pending_approval
response
{ "id": "3F9A1C", "status": "approved", "kind": "x402", "summary": "Pay $5 USDC to api.meteo.xyz for …", "value_usd": 5,
  "reasons": ["owner requires approval for non-micro spends"], "expires_at": "2026-11-24T12:15:00.000Z", "decided_by": "telegram:owner" }

list_approvals

read-onlyapprovals

The 20 most recent approval requests, newest first, in the same shape as approval_status. No parameters.

list_grants

read-onlyapprovals

Spend grants the owner created (see Spend grants): active grants plus those that expired, ran out or were revoked in the last 24 hours, newest first, with spent and remaining USD. status is active, used_up, expired, revoked or unscoped (a swap grant for plain kyberswap made before 0.7.1: listed until it expires, covers nothing). scope says what a grant covers: { "kind": "counterparty" } for a merchant host or address, { "kind": "swap", "chain", "sellToken" } for a swap grant. The agent can read grants but no tool can create, extend or revoke one. No parameters.

response
{ "grants": [{ "id": "G7C21E0", "counterparty": "api.meteo.xyz", "maxUsdTotal": 25, "maxUsdPerTx": null,
    "spentUsd": 5, "remainingUsd": 20, "expiresAt": "2026-11-24T13:02:00.000Z", "createdAt": "2026-11-24T12:02:00.000Z",
    "createdVia": "telegram:owner (approval 3F9A1C)", "scope": { "kind": "counterparty" }, "status": "active" }],
  "limits": { "maxHours": 24, "maxUsd": 50 } }

Resources

Besides tools, Lydion exposes MCP resources: read-only documents a client can attach to the context.

URITypeContent
lydion://policyapplication/jsonThe active spending policy (limits, allow/deny lists)

Configuration

All configuration lives in environment variables, set in your MCP client config. Defaults are deliberately conservative.

VariableDefaultMeaning
LYDION_DAILY_LIMIT_USD50Total the agent may spend per UTC day
LYDION_PER_TX_LIMIT_USD25Above this, a human must approve
LYDION_HARD_CAP_USD500Above this, always denied, even with approval
LYDION_EQ_PARITY_BAND_PCT0.5Parity Guard: max premium (%) a tokenized stock may trade above the real share
LYDION_EQ_MAX_TRADE_USD / LYDION_EQ_MAX_POSITION_USD / LYDION_EQ_MARKET_HOURS_ONLY100 / 500 / trueEquity guardrails: per-trade cap (above → approval), per-ticker position cap (above → deny), regular hours only
LYDION_ACCOUNTeoasmart: the agent acts from an ERC-4337 Coinbase Smart Wallet owned by its key (atomic multi-call, sponsored gas)
LYDION_BUNDLER_URL / LYDION_PAYMASTER_URLPimlico public / (empty)Bundler and paymaster RPC for smart mode; {chainId} is replaced. The public bundler is rate-limited: use your own key in production
LYDION_MICRO_ALLOWANCE_USD1Micro-payments at or below this pass automatically (within the daily limit)
LYDION_MAX_MICRO_PER_HOUR10More micro-payments than this in a rolling 60 minutes need approval
LYDION_MAX_TX_PER_HOUR20More spends of any size than this in a rolling 60 minutes need approval
LYDION_COUNTERPARTY_LIMITS(empty)Daily USD budget per merchant or recipient address, e.g. api.example.com=5,0xabc…=20. Above it, a human must approve
LYDION_ALLOWLIST(empty)Comma-separated merchants or recipient addresses (swaps count as kyberswap). If set, anyone else above the micro allowance is denied; listed ones still go through every limit
LYDION_DENYLIST(empty)Always denied
LYDION_REQUIRE_APPROVALtrueRequire approval for every non-micro spend
LYDION_LEDGER_LOG~/.lydion-mcp/ledger.jsonlAppend-only, hash-chained spend ledger. If only LYDION_LEDGER is set, it defaults to the same folder
LYDION_LEDGER~/.lydion-mcp/ledger.jsonPre-0.6 daily ledger. Today's entries are imported once into an empty log; it is no longer written
LYDION_GRANTSgrants.json next to the ledger logWhere spend grants are stored. In-flight grant reservations live next to the ledger log (ledger.claims.json)
LYDION_GRANT_MAX_HOURS24Longest spend grant the owner can create
LYDION_GRANT_MAX_USDdaily limitLargest spend grant total (never above the hard cap)

Execution, approvals and HTTP

VariableDefaultMeaning
LYDION_AGENT_KEY(unset)Agent wallet private key (0x + 64 hex). Overrides the key file
LYDION_AGENT_KEY_FILE~/.lydion-mcp/agent-key.jsonKey file created by init-wallet (mode 600)
LYDION_EXECUTIONonoff disables every execution tool
LYDION_EXECUTION_CHAINSbase-sepoliaComma-separated chains where the agent may sign. Mainnets are opt-in
LYDION_APPROVALS~/.lydion-mcp/approvals.jsonWhere approval requests are stored
LYDION_APPROVAL_TTL_MIN15Minutes before an undecided request expires
LYDION_TELEGRAM_BOT_TOKEN(unset)Bot token from @BotFather, enables Telegram approvals (simulation summary, Approve once / Approve + 1h grant / Deny)
LYDION_TELEGRAM_CHAT_ID(unset)The only chat whose button presses are accepted
LYDION_APPROVAL_WEBHOOK(unset)URL that receives every approval request as JSON (email, Slack, anything via Zapier / Make / n8n)
LYDION_APPROVAL_WEBHOOK_SECRET(unset)Signs the webhook body: X-Lydion-Signature: sha256=<HMAC-SHA256 hex>
LYDION_HTTP_TOKEN(unset)Bearer token for POST /mcp in HTTP mode (16+ chars, required)
LYDION_ADMIN_TOKEN(unset)Bearer token for the approval endpoints and the owner dashboard. Must differ from the agent token
LYDION_HTTP_HOST127.0.0.1Bind address in HTTP mode (also --host; port via --port or PORT, default 3333)

Recommended profiles

Research agentDAILY=5 · MICRO=0.10 · REQUIRE_APPROVAL=trueReads data and pays cents for APIs, never trades.
AssistantDAILY=50 · PER_TX=25 · ALLOWLIST=kyberswapSmall swaps through the KyberSwap aggregator, larger ones need a tap.
Treasury botDAILY=2000 · PER_TX=250 · HARD_CAP=1000Higher limits, strict allowlist, full ledger review.

Policy engine

The policy engine is the core of Lydion. It is about 390 lines of plain, auditable code (server/src/policy.js) that turns a proposed spend into one of three decisions:

allowWithin every limit. Typically an x402 micro-payment.
needs_approvalOver a soft limit. A human must confirm.
denyBreaks a hard rule. Nothing can override it.
Proposed spend Hard rules flagged recipient · denylist > hard cap · not allowlisted Micro allowance? ≤ $1 and daily budget left ≤ 10 micro this hour Soft limits per-tx · daily remaining per-counterparty · per-hour require-approval flag pass no fail DENY yes ALLOW over NEEDS_APPROVAL within
Evaluation order: hard rules first (any failure is final), then the micro allowance, then soft limits.
Terminal showing three policy decisions: allow, needs approval and deny
Real decisions from the test suite with LYDION_DAILY_LIMIT_USD=50 and LYDION_ALLOWLIST=uniswap.

Why it's injection-proof

Limits are read from environment variables when the process starts and enforced in code. The model can only ask for a decision through policy_check; no tool exists that changes the policy at runtime. A prompt-injected agent can request a $10,000 transfer, and the engine returns deny.

Velocity and counterparty limits

The micro allowance makes small payments frictionless, so the engine also watches the rate. An agent stuck in a loop could otherwise make fifty $1 payments and drain a $50 budget without a human ever seeing one. Over a rolling 60 minutes of recorded spends:

  • More than LYDION_MAX_MICRO_PER_HOUR (10) micro-payments: the next micro-payment needs approval, with the reason more than 10 micro-payments in the last hour.
  • More than LYDION_MAX_TX_PER_HOUR (20) spends of any size: the next spend needs approval, with more than 20 transactions in the last hour.
  • A spend that would take a merchant or recipient past its daily budget in LYDION_COUNTERPARTY_LIMITS needs approval, with above daily budget for api.example.com ($4.00 of $5). Keys are matched case-insensitively against the merchant (or the recipient address when there is no merchant).

These are soft limits: they raise the decision to needs_approval, never to deny, and they apply even to spends that would otherwise pass as micro-payments.

The ledger

Every spend Lydion makes is appended as one line to ~/.lydion-mcp/ledger.jsonl. Lines are never rewritten, so history is kept across days and restarts, and daily totals, per-counterparty totals and the hourly window are all computed from it. Each line is hash-chained to the one before:

ledger.jsonl · one line
{ "seq": 7, "at": "2026-11-20T09:12:04.511Z", "day": "2026-11-20", "valueUsd": 1.5, "counterparty": "api.example.com",
  "memo": "x402 api.example.com 0x…", "prev": "41d0…", "hash": "9c1f…" }

hash is the SHA-256 of the entry's canonical JSON (keys sorted, without hash) and prev is the hash of the previous entry (64 zeros for the first). Changing, deleting or inserting any line breaks the chain from that point, and verify_ledger reports where. Spends made under a spend grant carry a grant field with its id, inside the hash. A ledger written by an older version (ledger.json) is imported once, for today's entries.

Execution & approvals (v0.3)

From v0.3 an agent can act, not just read: send transactions, swap and pay x402 merchants from its own small wallet. There is exactly one code path that signs (server/src/execute.js), and every action passes the same gate in order:

  1. Simulate. The transaction is dry-run on live state with simulate_tx. Anything that would revert or trips a high-severity warning (drainer approval, flagged counterparty) is blocked before it can be signed.
  2. Policy. The policy engine decides on the USD value leaving the wallet: allow, needs_approval or deny. Deny is final.
  3. Human approval. If the policy asks for a human, or the simulation raised medium warnings, the action is parked as an approval request and the owner is notified.
  4. Sign and send. Only then does the wallet sign and broadcast.
  5. Ledger. The spend is recorded, so daily limits hold across restarts.

Opt-in chains

Execution runs only on chains listed in LYDION_EXECUTION_CHAINS. The default is base-sepolia, a testnet: nothing real can be spent until the owner opts in to a mainnet explicitly, for example LYDION_EXECUTION_CHAINS=base-sepolia,base. LYDION_EXECUTION=off disables execution entirely and leaves the read-only tools working. Test ETH is still valued at the ETH price, so limits behave on testnet exactly as they would on mainnet.

The agent wallet

Running from source? The CLI examples on this page use npx lydion-mcp <command>. From a source checkout, run the same command from the server/ folder as node src/index.js <command>, e.g. node src/index.js init-wallet.
terminal
npx lydion-mcp init-wallet
# Created a new agent wallet.
#   address   0xB6c6…445a
#   key file  ~/.lydion-mcp/agent-key.json  (keep it private; it never leaves this machine)
#   executes  base-sepolia  (LYDION_EXECUTION_CHAINS)

The key is stored in ~/.lydion-mcp/agent-key.json with file mode 600 (or passed as LYDION_AGENT_KEY). No tool returns it and it is never logged; wallet_info shows only the address. Treat it as a hot wallet: fund it with what you are willing to let the agent spend, not your savings. For testing, use Base Sepolia ETH and USDC from a faucet.

Approvals

An approval request is bound to a SHA-256 hash of the exact action parameters (chain, recipient, value, calldata; or URL, payee, asset and amount for x402). It can be used once and expires after 15 minutes (LYDION_APPROVAL_TTL_MIN). An approved $5 payment therefore cannot be swapped for a $500 one or replayed. The agent has no tool that can approve: it can only read the status.

TelegramSet LYDION_TELEGRAM_BOT_TOKEN and LYDION_TELEGRAM_CHAT_ID. Each request arrives as a compact message with the simulation summary (assets out and in with USD, allowances granted, risk verdict, counterparty, policy reasons) and three buttons: Approve once (single use, bound to the exact parameters), Approve + 1h grant (also creates a spend grant for that counterparty) and Deny. Only callbacks from that chat are accepted.
CLInpx lydion-mcp approvals lists requests; npx lydion-mcp approve <id> or deny <id> decides. grant, grants and revoke-grant manage spend grants. Works with no extra setup.
Admin HTTPPOST /approvals/<id>/approve (or /deny) with Authorization: Bearer $LYDION_ADMIN_TOKEN. The admin token must differ from the agent token; the server refuses to start otherwise.
Webhook · emailSet LYDION_APPROVAL_WEBHOOK and every request is POSTed as JSON within 5 s (a slow or broken endpoint never blocks the tool). Point it at Zapier, Make, n8n or a small function that sends an email (e.g. via Resend). With LYDION_APPROVAL_WEBHOOK_SECRET the body is signed with HMAC-SHA256 in X-Lydion-Signature.
ExpiryUndecided requests expire. A pending, denied, expired or already-used approval makes the tool return blocked with the reason.
webhook payload · POST to LYDION_APPROVAL_WEBHOOK
{ "type": "approval_requested",
  "approval": { "id": "3F9A1C", "summary": "Pay $5 USDC to api.meteo.xyz for https://api.meteo.xyz/v1/forecast",
                "value_usd": 5, "reasons": ["owner requires approval for non-micro spends"], "expires_at": "2026-11-24T12:15:00.000Z" },
  "approve_hint": "npx lydion-mcp approve 3F9A1C  (or deny 3F9A1C)" }

// verify on the receiver (Node):
// crypto.createHmac('sha256', SECRET).update(rawBody).digest('hex') === header.slice(7)

The pending response tells the agent which channels were reached: "notified_via": ["telegram", "webhook"], or ["none"] when only the CLI is set up.

Spend grants (0.7)

A spend grant is a time-boxed, scoped pre-approval: up to $X to counterparty Y for N hours, optionally with a per-spend cap. While it is active, a matching spend that the policy would park for approval passes instead, with the reason covered by grant G7C21E0 ($20.00 of $25 left, expires 2026-11-24 13:02 UTC). Everything else still asks.

  • What a grant can waive: the per-transaction limit, the remaining daily budget, "owner requires approval", velocity limits and per-counterparty budgets.
  • What it never touches: a deny (hard cap, denylist, flagged counterparty, allowlist miss), simulation warnings, unpriced outgoing value and tokenized-stock buys. Those behave exactly as without a grant.
  • Counterparty: the merchant host for x402 (api.meteo.xyz) or the to address of a plain transfer. Swaps are scoped to the token sold on one chain: kyberswap:<chain>:<sellTokenAddress>, e.g. kyberswap:base:0x833589fcd6edb6e08f4c7c32d4f71b54bda02913 for selling USDC on Base (the native coin is 0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee), so a grant made from one swap does not cover selling anything else. Budgets, lists and the ledger still use kyberswap as the counterparty. Grants match exactly, lowercased.
  • Older swap grants: before 0.7.1 a swap grant was for plain kyberswap and covered every swap. Such grants no longer cover anything; they are listed with status unscoped until they expire (24 h at most) and can still be revoked. A plain kyberswap grant can no longer be created.
  • Room: spends under a grant are written to the ledger with a grant field inside the hash chain, and the room left is computed from those entries. The executor re-checks the grant and reserves its room right before signing, under the same cross-process lock as the ledger, so parallel calls cannot overspend it, even from two Lydion processes sharing one ledger (stdio and HTTP). A reservation is released when the spend is recorded or fails, and lapses after 10 minutes otherwise.
  • Owner only: grants are created from Telegram or the CLI, never by the agent. LYDION_GRANT_MAX_HOURS (24) and LYDION_GRANT_MAX_USD (the daily limit) cap every grant; expired and revoked grants are ignored. The agent sees them through list_grants and spending_report.

Approve + 1h grant in Telegram approves the request once and creates a grant for its counterparty (for a swap: selling the same token on the same chain) of max(request value, per-tx limit) for one hour, capped by LYDION_GRANT_MAX_USD. The approved request itself does not use the grant. The button is offered for x402 payments, swaps and plain transfers; not for contract calls (a grant to a token contract would cover transfers to anyone) or tokenized-stock buys.

terminal
npx lydion-mcp grant api.meteo.xyz 20 4 --per-tx 5
# G7C21E0 granted: up to $20 to api.meteo.xyz (max $5/tx) until 2026-11-24 16:02 UTC
npx lydion-mcp grants
# G7C21E0  active   api.meteo.xyz  $20 of $20 left (max $5/tx)  expires 2026-11-24 16:02 UTC
npx lydion-mcp grant kyberswap:base:0x833589fcd6edb6e08f4c7c32d4f71b54bda02913 30 2   # swaps selling USDC on Base
npx lydion-mcp revoke-grant G7C21E0

Allowance hygiene

Simulation stops a bad approval before it is signed, but approvals the wallet granted earlier stay open until someone revokes them. list_allowances lists them with a verdict per row (REVOKE, REVIEW, OK), and revoke_allowance sets one back to zero through the same gate as every other signing action. A zero approval grants nothing, so the simulation does not block a revoke because its spender is flagged; that is exactly the case where revoking matters most.

A full flow

x402_pay with a $5 price (above the $1 micro allowance)
// 1 · agent → x402_pay({ url: "https://api.meteo.xyz/v1/forecast" })
{ "status": "pending_approval", "approval_id": "3F9A1C", "expires_at": "2026-11-24T12:15:00.000Z",
  "reasons": ["owner requires approval for non-micro spends"], "notified_via": ["telegram"],
  "next": "Ask the owner to approve (…), then call this tool again with the same arguments and approval_id" }

// 2 · owner taps ✅ Approve in Telegram   (or: npx lydion-mcp approve 3F9A1C)

// 3 · agent → x402_pay({ url: "https://api.meteo.xyz/v1/forecast", approval_id: "3F9A1C" })
{ "status": "paid", "amount_usd": 5, "approved_by": "3F9A1C", "receipt": { "success": true, … }, "body": "…" }

// 4 · the same approval_id again → { "status": "blocked", "reason": "approval 3F9A1C was already used" }

Every step of this flow, including the replay and wrong-parameter cases, is covered by server/test/execution.js against a local x402 merchant that verifies the EIP-3009 signature.

x402 payments

x402 revives the long-unused HTTP 402 Payment Required status code for machine payments. Instead of API keys and monthly plans, a server answers 402 with a price, the client pays a few cents in a stablecoin, and retries the request with a payment proof. This fits AI agents well: no sign-ups, pay per use, settled on-chain.

Agent + Lydion Paid API 1 · GET /v1/weather/dubai 2 · 402 Payment Required · 0.02 USDC on Base 3 · policy_check → allow (micro) 4 · retry with X-PAYMENT / PAYMENT-SIGNATURE (signed) 5 · 200 OK + data · settled on-chain
All five steps run in x402_pay: the price is checked against the policy, the agent wallet signs an EIP-3009 authorization, and the merchant settles it on-chain. x402_quote stops after step 3.

Remote agents (HTTP)

Besides stdio, Lydion can serve MCP over Streamable HTTP, for agents that run on another machine or in the cloud. The server is stateless: every request to POST /mcp gets a fresh MCP server instance.

terminal
LYDION_HTTP_TOKEN=$(openssl rand -hex 24) \
LYDION_ADMIN_TOKEN=$(openssl rand -hex 24) \
npx lydion-mcp http --port 3333
# [lydion-mcp] v0.7.1 ready over http://127.0.0.1:3333/mcp · wallet 0xB6c6…445a · execution base-sepolia
EndpointAuthPurpose
POST /mcpBearer LYDION_HTTP_TOKENMCP JSON-RPC (Streamable HTTP). Other methods return 405
GET /healthnone{ "ok": true, "name": "lydion-mcp", "version": "0.7.1" }
GET /approvalsBearer LYDION_ADMIN_TOKENRecent approval requests
POST /approvals/<id>/approve · /denyBearer LYDION_ADMIN_TOKENOwner decision
  • It binds to 127.0.0.1 by default. Use --host 0.0.0.0 (or LYDION_HTTP_HOST) only behind TLS, for example a reverse proxy.
  • LYDION_HTTP_TOKEN is required and must be at least 16 characters; the server will not start without it.
  • The admin endpoints are disabled unless LYDION_ADMIN_TOKEN is set, and it must differ from the agent token, so the agent can never approve its own spends.
client config (any MCP client with Streamable HTTP)
{
  "mcpServers": {
    "lydion": {
      "url": "https://lydion.your-host.example/mcp",
      "headers": { "Authorization": "Bearer <LYDION_HTTP_TOKEN>" }
    }
  }
}

Owner console

lydion-mcp doctor checks your setup and prints a ✓ / ! / ✗ checklist with one fix per problem. It covers Node, every limit (velocity and counterparty budgets too), execution chains (warns when a mainnet is on), the wallet address (never the key), RPC reachability per chain, the Telegram, webhook or CLI approval channel, ledger integrity and today's spend, the approvals store and the HTTP bind. Tokens are masked to their first 4 characters. It exits with 1 if anything is ✗.

terminal
npx lydion-mcp doctor
#   ✓ execution            base-sepolia (testnet only)
#   ✓ rpc base-sepolia     chainId 84532 · 210 ms
#   ✓ ledger               ~/.lydion-mcp/ledger.jsonl · 12 entries · chain intact · head 3f9a1c0e7b2d…
#   ! owner console        dashboard disabled: no owner token
#       fix: set LYDION_ADMIN_TOKEN=$(openssl rand -hex 24) and run `lydion-mcp http`

When LYDION_ADMIN_TOKEN is set, the HTTP transport also serves a read-only dashboard. Open http://127.0.0.1:3333/dashboard?token=<owner token>. The page keeps the token in the tab's sessionStorage, removes it from the address bar and refreshes every 10 s. It shows today's spend against the limit, counterparty budgets, last-hour velocity, 30-day history, ledger integrity, pending and recent approvals, the wallet and enabled chains, and spend grants.

EndpointAuthPurpose
GET /dashboard?token= or Bearer LYDION_ADMIN_TOKENSelf-contained page (inline CSS/JS, no CDN, works offline)
GET /dashboard/dataBearer LYDION_ADMIN_TOKENThe same data as JSON
  • Read-only: no approve or deny buttons and no write endpoints. Decisions stay with Telegram, the CLI and POST /approvals/<id>/….
  • Constant-time token check; Cache-Control: no-store, X-Content-Type-Options: nosniff, Referrer-Policy: no-referrer and a strict nonce-based CSP.
  • Without an owner token the dashboard returns 404.

[ Browser extension · v0.3.0 ]

Lydion Guard (browser extension)

See what you sign. Lydion Guard brings the checks the MCP server runs for AI agents to people signing in a browser. When any website asks your wallet to sign, Guard reads the request first, simulates it on live chain state and shows a verdict before MetaMask, Rabby or Coinbase Wallet opens.

What it does

  • Transaction firewall. Intercepts eth_sendTransaction on any dApp and runs the same simulation core as simulate_tx: assets leaving and arriving with USD values, approvals granted, revert reason, gas. You then Reject or Continue to wallet.
  • Batches (EIP-5792). Intercepts wallet_sendCalls, with or without atomicRequired. Every call is decoded and checked on its own, the batch is simulated in order in one block, and the verdict is the worst of the calls. The overlay lists each call, for example Call 2 of 3: approve unlimited USDC to 0x2222…2222.
  • NFT approvals. setApprovalForAll(operator, true) on ERC-721 / ERC-1155 is DO NOT SIGN when the operator is a plain wallet or a flagged address and REVIEW when it is a contract, with the collection name: Gives 0x… control of ALL your Basenames NFTs. Revoking (false) shows an info line. A single ERC-721 approve(to, tokenId) to a plain wallet is REVIEW.
  • Signature firewall. Decodes Permit (EIP-2612) and Permit2 signature requests, the most common one-click drain. Flags unlimited amounts, spenders that are plain wallets or flagged addresses, and long deadlines.
  • Look-alike address check. Address poisoning: scammers send dust or zero-value transfers from vanity addresses that share the first and last characters with an address you really use, hoping you copy the fake one from your history. Guard remembers the addresses you actually sent to or approved (the 200 most recent, on your device) and compares every new native transfer, ERC-20 transfer / transferFrom and approve target, NFT operator, permit spender (EIP-2612, DAI-style, Permit2) and to / recipient field in typed data with them, including every call of a batch. Same first 4 and last 4 characters but a different address: DO NOT SIGN, with the differing middle shown. Same last 4 only, and never used before: REVIEW. A known address shows how many times you used it.
  • Scan with Lydion. Select or right-click any 0x… address on a page (X, Telegram Web, a DEX) to get a 0–100 token risk score, or the reputation of a wallet.
  • Popup. On / off, pause on the current site, counters of checked / warned / blocked requests, the latest checks, and how many addresses Guard remembers, with a Clear button.

Works with MetaMask, Rabby, Coinbase Wallet and any wallet that exposes an EIP-1193 provider or announces itself through EIP-6963. Chains: Ethereum, Base, Arbitrum, Optimism, Polygon, BNB Chain, Avalanche, plus Base Sepolia and Sepolia.

How the overlay decides

Guard uses the verdicts documented for simulate_tx, so a human and an agent see the same answer for the same transaction:

VerdictWhat you see
SAFE TO SIGNSucceeds, no warnings. A compact confirmation; the wallet opens as usual.
REVIEWMedium warnings, for example an unlimited approval to a known contract, setApprovalForAll to a contract, or an asset that could not be priced.
DO NOT SIGNHigh warnings: approval or Permit to a plain wallet, setApprovalForAll to a plain wallet or flagged operator, a flagged counterparty, a look-alike of an address you used before. In a batch, any single call is enough.
WILL REVERTThe transaction would fail on-chain and only burn gas. The reason is shown.

You always decide. Continue to wallet passes the original, unmodified request to your wallet; Reject returns the standard "user rejected" error (EIP-1193 code 4001) to the website.

Install

Lydion Guard is in beta. The Chrome Web Store and Firefox Add-ons listings are on the way; until they are live, install it from source (two minutes, no build step):

  1. Unzip lydion-guard-*-chrome.zip from the latest release (or use the extension/ folder of the repository).
  2. Open chrome://extensions (or brave://extensions) and switch on Developer mode.
  3. Click Load unpacked and select the unzipped folder (or extension/).
  4. Pin Lydion Guard to the toolbar. Open any dApp: the next signature request goes through Guard first.
  1. Download or clone the repository.
  2. Open about:debugging#/runtime/this-firefox.
  3. Click Load Temporary Add-on… and pick extension/manifest.json.
  4. Temporary add-ons are removed when Firefox restarts. A permanent install comes with the Firefox Add-ons listing.

Store status

StoreStatus
Chrome Web StoreIn review soon: load unpacked from GitHub until then.
Firefox Add-onsIn review soon: load it as a temporary add-on until then.

One codebase (Manifest V3) for both. Only install Lydion Guard from the links on this site: crypto extensions are a common target for look-alike clones.

Permissions

PermissionWhy it is needed
storageSettings, local counters and remembered addresses for the look-alike check
contextMenusThe Scan with Lydion right-click item
activeTabLets the popup read the current tab's site when you click it, for Pause on this site. No access to other tabs or history.
Content scripts on all sitesAny site can ask your wallet to sign, so Guard must be present on every page to see the request first. It does not read page content otherwise.
Host access: PublicNode, GoPlus, DefiLlama, CoinGeckoSimulation, risk and price lookups. Nothing else is contacted.

Privacy

No account, no telemetry, no backend of ours. Guard never touches keys or seed phrases: it reads the request on its way to the wallet, and that is all. When a site asks you to sign, the transaction goes to PublicNode for simulation, the addresses involved to GoPlus for reputation, and token addresses to DefiLlama / CoinGecko for prices. The addresses Guard remembers for the look-alike check stay in your browser's local extension storage: they never leave your device and are never sent to any service. Clear them any time from the popup. Full details: Privacy policy.

Limits Guard shows what a request would do on current chain state. State can change between the check and the signature, and risk data comes from third-party heuristics. It reduces risk; it cannot remove it.

Security model

Prompt injectionPolicy is enforced outside the model. No tool can modify limits.
Malicious tokensscan_token flags honeypots, mint authority, taxes and unlocked LP before a buy.
Drainer addressesRecipients are reputation-checked inside policy_check. Flagged means deny.
Bad inputJSON-schema validation rejects malformed addresses, unknown chains and negative amounts.
Key exposureThe agent wallet key lives in a mode-600 file or an env var on your machine. No tool returns it; wallet_info shows only the address.
Hot walletThe agent spends from its own small wallet, never your main one. Fund it with what you are willing to risk; mainnets are opt-in per chain.
Self-approvalNo tool can approve. Approvals come from Telegram (one chat only), the CLI, or an admin token the agent never sees.
Swapped or replayed actionsAn approval is bound to a hash of the exact parameters, is single-use and expires in 15 minutes.
Blind signingEvery transaction is simulated before signing; reverts and drainer patterns are blocked outright.
Third-party dataData sources can be wrong or down. Lydion reports errors explicitly and the agent should treat "unknown" as risky.
Disclaimer Lydion reduces risk but cannot remove it. Risk scores come from third-party heuristics. This is not financial advice; you are responsible for funds your agents control.

Equity Rails (phase 4: quotes since 0.4, guardrails since 0.5)

Stocks are moving on-chain as tokenized equities: tokens that track a real share and trade 24/7 on Solana, Arbitrum, Base and other chains. Agents will want to manage them the same way they manage crypto. Equity Rails extends Lydion to stocks, using the same policy engine and adding one equities-specific safety layer.

Parity Guard

A tokenized share should trade close to its underlying stock. When liquidity is thin or the market is closed, it can drift, and an agent buying at a 3% premium simply loses money. Before every buy, Parity Guard compares the on-chain price with the exchange reference price and blocks the trade when the premium is outside your band.

It is live as parity_check. A real response from 2026-11-24, with the US market open:

parity_check { ticker: "TSLA" }
"reference": { "price": 386.37, "kind": "live" }
TSLAx   "premium_pct": -0.477   "verdict": "WITHIN_BAND"
TSLAon  "premium_pct": -0.28    "verdict": "WITHIN_BAND"

Verified tokenized stocks

Lydion only prices tokens it has verified: each contract address comes from the CoinGecko coin API and its symbol() was read on-chain on Ethereum (and Arbitrum for xStocks). Both issuers target one token per underlying share; small persistent gaps can come from dividend handling, fees or after-hours trading.

TickerTokenIssuerEthereum contract
TSLATSLAxBacked · xStocks0x8ad3c73f833d3f9a523ab01476625f269aeb7cf0
TSLAonOndo Global Markets0xf6b1117ec07684d3958cad8beb1b302bfd21103f
AAPLAAPLxBacked · xStocks0x9d275685dc284c8eb1c79f6aba7a63dc75ec890a
AAPLonOndo Global Markets0x14c3abf95cb9c93a8b82c1cdcb76d72cb87b2d4c
NVDANVDAxBacked · xStocks0xc845b2894dbddd03858fd2d643b4ef725fe0849d
NVDAonOndo Global Markets0x2d1f7226bd1f780af6b9a49dcc0ae00e8df4bdee
SPYSPYxBacked · xStocks0x90a2a4c76b5d8c0bc892a69ea28aa775a8f2dd48
SPYonOndo Global Markets0xfedc5f4a6c38211c1338aa411018dfaf26612c08

xStocks are also deployed at the same address on Arbitrum and BNB Chain; Ondo tokens have separate BNB Chain contracts. All addresses are in server/src/equities.js.

Market hours

market_hours knows the NYSE calendar (holidays, observed days, 13:00 ET early closes) and daylight saving time, so an agent can tell a live reference price from last night's close.

Equity guardrails

RuleExampleWhy
LYDION_EQ_MARKET_HOURS_ONLYtrueEquity buys only during the regular NYSE session (live)
LYDION_EQ_PARITY_BAND_PCT0.5Parity Guard for the exact token: above the band, buys are denied (live)
LYDION_EQ_MAX_TRADE_USD100Per-trade cap: bigger buys need a human (live)
LYDION_EQ_MAX_POSITION_USD500Per-ticker position cap including current holdings: above it, denied (live)
(no setting)alwaysNo leverage: only verified 1:1 tokenized shares are on the registry (live)
LYDION_EQ_SECTOR_CAP_PCT30Caps exposure to any one sector (planned)

Tools

Live: get_equity_quote · parity_check · market_hours (0.4) and equity_policy_check (0.5, enforced by execute_swap). Next: corporate_actions (dividends, splits, earnings) and sector caps.

Note Tokenized equities are regulated differently from country to country and may be unavailable where you live. Lydion will only route to venues you allowlist. Nothing here is investment advice.

$LYDN token

Status $LYDN launches on Pons, the launchpad on Robinhood Chain. The contract address is posted on this site first, before any announcement; anything else is not Lydion.
FieldValue
TickerLYDN
ChainRobinhood Chain
LaunchpadPons
ContractPublished here at launch

The software does not depend on the token: the MCP server and Lydion Guard are MIT licensed, free to run and work without holding anything. Any future token utility (for example around a hosted gateway) is a roadmap idea, not a shipped feature. Not financial advice.

Roadmap

  • Phase 1 · Q3 2026GenesisMarket and wallet tools on 7 EVM chains, stdio transport, MIT license.
  • Phase 2 · Q4 2026GuardrailsPolicy engine + ledger ✓, risk scanner ✓, x402 quotes ✓, docs & live playground ✓, guarded swap quotes ✓, pre-sign transaction simulation ✓. Still to do: npm publish and MCP registries.
  • Phase 3 · Q1 2027Wallets & paymentsAgent wallet ✓, policy-gated execution ✓, x402 settlement in USDC ✓, Telegram / CLI / HTTP approvals ✓, HTTP transport ✓, Lydion Guard browser extension (now v0.3), live on the Chrome Web Store and Firefox Add-ons ✓. Velocity limits, per-counterparty budgets, hash-chained ledger and allowance hygiene (0.6) ✓. Spend grants, Telegram one-tap grants, doctor and owner dashboard (0.7) ✓. ERC-20 sells with exact allowances ✓, email approvals via signed webhook ✓. ERC-4337 smart accounts ✓ (LYDION_ACCOUNT=smart: Coinbase Smart Wallet, atomic batches, optional paymaster). Next: scoped session keys enforced on-chain, security audit #1.
  • Phase 4 · Q1–Q2 2027Equity RailsTokenized stock quotes & Parity Guard ✓, market hours ✓, equity guardrails ✓ (equity_policy_check, enforced in execute_swap). Next: corporate-action awareness, sector caps, read-only brokerage sync. See Equity Rails.
  • Phase 5 · nextToken$LYDN launch on Pons (Robinhood Chain). Then: audit #2 before any staking contracts, CoinGecko / CoinMarketCap applications.
  • Phase 6 · Q3 2027Gateway networkHosted gateway and node operators, x402 fee share, Solana support, tier-2 exchange listings.
  • Phase 7 · Q4 2027 →Agent economyAgent-to-agent marketplace, tier-1 exchange listings, multi-language SDKs, on-chain governance.

FAQ

Do I need an API key or wallet?

No API keys: everything runs on free public endpoints. The 16 read-only tools need no wallet. To let the agent act, the owner creates a small agent wallet with npx lydion-mcp init-wallet (from source: node src/index.js init-wallet).

Can my agent actually move money today?

Yes, from v0.3, within limits. It can send transactions, swap (native coin or ERC-20, with an exact allowance) and pay x402 merchants from its own wallet, and only after simulation, the policy engine and, when the policy asks, your approval. By default it can do this only on the Base Sepolia testnet; mainnets are opt-in through LYDION_EXECUTION_CHAINS.

Does Lydion Guard replace my wallet?

No. It sits in front of your wallet: it reads the signature request, shows what it would do, and then passes the original request to MetaMask, Rabby or any other wallet if you continue. Your wallet still holds your keys and does the signing.

Does Lydion Guard see my keys?

No. It never touches keys, seed phrases or passwords. It only reads the request a website sends to the wallet, before the wallet receives it. See the privacy policy.

Which AI models work with it?

Any model behind an MCP-capable client: Claude (Desktop, Code), Cursor, Windsurf, Zed, Cline, the OpenAI Agents SDK, or your own agent built on the MCP SDK.

Is my data sent anywhere?

Only the queries a tool needs: token ids to CoinGecko, addresses to the RPC and GoPlus. Lydion has no telemetry.

What happens when a data source is down?

The tool returns isError: true with the reason. Requests time out after 12 seconds, so the agent is never left hanging.

How is this different from giving the agent an exchange API key?

An exchange key lets the model do anything the key allows. Lydion's policy engine sits in between with limits, allowlists and approvals that the model cannot change.

Contributing

Lydion is MIT-licensed and contributions are welcome. A new tool is about 20 lines: register it inside createServer() in server/src/tools.js with a zod schema and a handler, put data access in data.js, and add a call to test/smoke.js. Anything that signs must go through execute.js.

server/src/tools.js
server.registerTool('my_tool', {
  title: 'My tool',
  description: 'What it does and when the agent should use it.',
  inputSchema: { address: Address, chain: Chain },
  annotations: { readOnlyHint: true },
}, safe(async ({ address, chain }) => {
  return { address, chain, result: '…' };
}));

Good first issues: ERC-20 balances, a second swap aggregator as a price cross-check, Solana RPC support, more chains. See the issues on GitHub.