Ankr Agent RPC
June 30, 2026 · View on GitHub
A Model Context Protocol (MCP) server that gives AI agents token-efficient access to blockchain data through Ankr RPC.
Each data tool calls rpc.ankr.com with the TORPC Accept-Token-Tier: 2 header, so responses come back ABI-decoded and compressed: contract calls and event logs are decoded into named arguments, hex becomes decimal, and verbose fields (logsBloom, header roots) are dropped — typically 25–58% fewer tokens on decode-heavy reads (transactions, receipts, logs).
Evolves the former
@asphere/aapi-mcp-server(now deprecated and aliased to this package). The two Advanced-API tools (getAccountBalance,getTokenPrice) are kept; the routed TORPC tools below are new.
Tools
Raw-RPC, TORPC tier-2 (compressed):
getTransaction— transaction + receipt by hash, ABI-decodedgetLogs— event logs, decoded + paged (cursor)getBlock— block header (+ optional decoded txs)
Mixed / indexer (AAPI) / passthrough:
getBalances— native coin (tier-1) + ERC-20 token balances with USD (AAPI)getWalletActivity— address transaction history (AAPI), pagedresolveContract— is-contract, best-effort ERC-20 metadata, EIP-1967 proxy (tier-0 passthrough)searchChain— classify & resolve a tx/block hash, address, ENS, or block numberexpandResult— continue a paged result via an opaque cursor
Advanced API (kept):
getAccountBalance,getTokenPrice
Discovery:
listChains— supported chains, max TORPC tier, AAPI availability
Every tool result carries _meta.tier (the TORPC tier actually applied — 0 for passthrough/AAPI, 2 for compressed reads), so the agent never mistakes uncompressed data for compressed.
Setup
Get a free key at ankr.com/rpc.
Claude Desktop / Cursor / Windsurf
{
"mcpServers": {
"ankr-agent-rpc": {
"command": "npx",
"args": ["-y", "@asphere/agent-rpc-mcp"],
"env": { "ANKR_API_KEY": "<YOUR_KEY>" }
}
}
}
Cursor command form: env ANKR_API_KEY=<YOUR_KEY> npx -y @asphere/agent-rpc-mcp
Supported blockchains
- TORPC raw-RPC tools: eth, bsc, polygon, arbitrum, optimism, base, avalanche (tier-2 verified on eth; the engine is shared, broader verification tracked for v2)
- Advanced API tools: Ethereum, BSC, Polygon, Arbitrum, Avalanche, Base, Fantom, Gnosis, Linea, Optimism, and more (+ testnets)
Call listChains for the live capability matrix.
TORPC tiers
| Tier | Meaning |
|---|---|
| 0 | passthrough (standard JSON-RPC) |
| 1 | hex → decimal + field rename |
| 2 | full: ABI decode (function/event + named args) + log collapse + logsBloom drop |
Negotiation: request header Accept-Token-Tier: 0\|1\|2 → response header Token-Tier. Spec: github.com/w3tech/torpc.
Local development
pnpm install
pnpm run build # tsc -> dist/
ANKR_API_KEY=<key> node dist/index.js # stdio
Transports: index.ts (stdio, the MVP surface) and http.ts (Streamable HTTP remote — see DEPLOY.md). The legacy SSE remote has been removed in favor of Streamable HTTP.
License
MIT.