infura-mcp-server
AGENTS.md4 starsChanged 18 months agoMITView on GitHub
Guidance for AI agents (Claude, GPT, Cursor, etc.) using the Infura MCP Server to interact with blockchain data. This MCP server provides 29 read-only Ethereum JSON-RPC tools that enable AI agents to query blockchain data across 37+ supported networks. All operations are read-only and cannot modify blockchain state. What you can do: - Query account balances, nonces, and contract bytecode - Retrieve block and transaction data - Read smart contract state via eth_call - Query event logs from contracts -…
- Reads credentials
Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about checking a change actually works.
Of the AGENTS.md files we read, the 11,691 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
In this repositoryOne other file it gives its agents.
- .cursor/rules/infura-mcp-server.mdcCursor rule
The file
Show its rules and text
We split this AGENTS.md into the rules it gives an agent
37 rules. About 1 is common, 19 are distinctive, and 17 are very specific to this project.
≈1
Common · estimate
Many files like this have a rule of this kind.
≈19
Distinctive · estimate
This author's own choices. Worth a look.
17
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 12
Read smart contract state via eth_call
- Distinctive: line 15
Check network status and chain IDs
- Distinctive: line 26
Use these to check wallet and contract information.
- Distinctive: line 36
Use these to retrieve block data and metadata.
- Distinctive: line 50
Use these to get transaction details and receipts.
- Distinctive: line 63
Use these to read smart contract state.
- Distinctive: line 73
Use this to query contract events.
- Distinctive: line 81
Use these to get network status and metadata.
- Distinctive: line 93
Use these for gas estimation and fee data.
- Very specific: line 152
Use eth_getTransactionReceipt to verify confirmation:
- Distinctive: line 187
When querying event logs that may return large result sets, use pagination to retrieve results in manageable chunks.
- Very specific: line 211
When pagination parameters are used, the response includes a pagination object:
- Very specific: line 247
Check pagination.has_more to determine if more results exist
- Very specific: line 248
Use pagination.next_offset as the offset for the next request
- Distinctive: line 253
Use limit values between 100-1000 depending on log complexity
- Very specific: line 254
Always check has_more rather than calculating from totals
- Distinctive: line 307
Use one of these string values:
- Very specific: line 341
All tools support an optional response_format parameter that controls how results are returned:
- Very specific: line 350
Use
json(default): when you need to process the data programmatically, extract specific fields, perform calculations, or pass data to … - Very specific: line 352
Use
markdown: when displaying results directly to humans, creating reports, or when readability is more important than raw data access. - Very specific: line 389
If network is not specified, queries default to mainnet (Ethereum mainnet).
- Very specific: line 393
Always include the network parameter for clarity:
- Distinctive: line 459
If you receive rate limit errors:
- Distinctive: line 460
Wait a few seconds before retrying
- Very specific: line 468
Add an address filter to reduce results
- Very specific: line 469
Add topics filters to narrow results
- Distinctive: line 478
Do not retry on:
- Very specific: line 488
Use "latest" for current state: - When you need the current blockchain state, use tag: "latest".
- Distinctive: line 492
Handle hex values properly: - All numeric values are returned as hex strings.
- Distinctive: line 517
Get multiple pieces of data in one flow: - If you need balance and nonce, make both calls rather than asking the user to make separate …
- Distinctive: line 519
Use block numbers for consistency: - If making multiple related queries, use a specific block number rather than "latest" to ensure …
- Distinctive: line 521
Filter logs efficiently: - Always provide the most specific filters possible (address, topics) to reduce response size.
- Very specific: line 523
Check block number first: - Use eth_blockNumber to get the latest block, then use that number for subsequent queries.
- Distinctive: line 527
All tools are read-only and cannot modify blockchain state
- Common: line 528
Never ask users to share private keys - this server cannot use them
- Very specific: line 538
Check if it's a contract: eth_getCode (empty = EOA, non-empty = contract)
- Very specific: line 555
Check sync status: eth_syncing
≈ “Common” is an estimate: at least 1 in 5 of the 16,597 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
AGENTS.md
Guidance for AI agents (Claude, GPT, Cursor, etc.) using the Infura MCP Server to interact with blockchain data.
Overview
This MCP server provides 29 read-only Ethereum JSON-RPC tools that enable AI agents to query blockchain data across 37+ supported networks. All operations are read-only and cannot modify blockchain state.
What you can do:
- Query account balances, nonces, and contract bytecode
- Retrieve block and transaction data
- Read smart contract state via
eth_call - Query event logs from contracts
- Get gas prices and fee estimates
- Check network status and chain IDs
What you cannot do:
- Send transactions or modify blockchain state
- Sign messages or manage private keys
- Deploy or modify smart contracts
Tool Categories
Account Queries (3 tools)
Use these to check wallet and contract information.
| Tool | Purpose | Key Parameters |
eth_getBalance | Get ETH balance of an address | address, tag, network |
eth_getTransactionCount | Get nonce (transaction count) | address, tag, network |
eth_getCode | Get contract bytecode | address, tag, network |
Block Queries (7 tools)
Use these to retrieve block data and metadata.
| Tool | Purpose | Key Parameters |
eth_blockNumber | Get latest block number | network |
eth_getBlockByHash | Get block by its hash | blockHash, fullTransactions, network |
eth_getBlockByNumber | Get block by number | blockNumber, fullTransactions, network |
eth_getBlockTransactionCountByHash | Count transactions in block | blockHash, network |
eth_getBlockTransactionCountByNumber | Count transactions in block | blockNumber, network |
eth_getUncleCountByBlockHash | Count uncles in block | blockHash, network |
eth_getUncleCountByBlockNumber | Count uncles in block | blockNumber, network |
Transaction Queries (6 tools)
Use these to get transaction details and receipts.
| Tool | Purpose | Key Parameters |
eth_getTransactionByHash | Get transaction by hash | transactionHash, network |
eth_getTransactionReceipt | Get transaction receipt | transactionHash, network |
eth_getTransactionByBlockHashAndIndex | Get transaction by position | blockHash, index, network |
eth_getTransactionByBlockNumberAndIndex | Get transaction by position | blockNumber, index, network |
eth_getUncleByBlockHashAndIndex | Get uncle block | blockHash, index, network |
eth_getUncleByBlockNumberAndIndex | Get uncle block | blockNumber, index, network |
Contract Interactions (3 tools)
Use these to read smart contract state.
| Tool | Purpose | Key Parameters |
eth_call | Execute read-only contract call | to, data, network |
eth_estimateGas | Estimate gas for a call | to, data, from, value, network |
eth_getStorageAt | Read contract storage slot | address, position, tag, network |
Log Queries (1 tool)
Use this to query contract events.
| Tool | Purpose | Key Parameters |
eth_getLogs | Query event logs | fromBlock, toBlock, address, topics, network |
Network Information (5 tools)
Use these to get network status and metadata.
| Tool | Purpose | Key Parameters |
eth_chainId | Get chain ID | network |
net_version | Get network version | network |
net_listening | Check if node is listening | network |
net_peerCount | Get connected peer count | network |
web3_clientVersion | Get client version | network |
Gas and Fees (4 tools)
Use these for gas estimation and fee data.
| Tool | Purpose | Key Parameters |
eth_gasPrice | Get current gas price | network |
eth_feeHistory | Get historical fee data | blockCount, newestBlock, rewardPercentiles, network |
eth_protocolVersion | Get protocol version | network |
eth_syncing | Get sync status | network |
Common Patterns
Check an Account Balance
{
"tool": "eth_getBalance",
"parameters": {
"address": "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045",
"tag": "latest",
"network": "mainnet"
}
}The result is in wei (hex). To convert to ETH, divide by 10^18.
Read a Smart Contract (ERC20 balanceOf)
To read an ERC20 token balance, use eth_call with ABI-encoded function data:
{
"tool": "eth_call",
"parameters": {
"to": "0xdAC17F958D2ee523a2206206994597C13D831ec7",
"data": "0x70a08231000000000000000000000000d8dA6BF26964aF9D7eEd9e03E53415D37aA96045",
"network": "mainnet"
}
}The data field contains:
0x70a08231- Function selector forbalanceOf(address)- Followed by the address padded to 32 bytes
Get Transaction Details
{
"tool": "eth_getTransactionByHash",
"parameters": {
"transactionHash": "0x88df016429689c079f3b2f6ad39fa052532c56795b733da78a91ebe6a713944b",
"network": "mainnet"
}
}Check if Transaction is Confirmed
Use eth_getTransactionReceipt to verify confirmation:
{
"tool": "eth_getTransactionReceipt",
"parameters": {
"transactionHash": "0x88df016429689c079f3b2f6ad39fa052532c56795b733da78a91ebe6a713944b",
"network": "mainnet"
}
}A null result means the transaction is pending or not found. Check status field: 0x1 = success, 0x0 = reverted.
Query Event Logs
To get Transfer events from a token contract:
{
"tool": "eth_getLogs",
"parameters": {
"fromBlock": "0x10d4f00",
"toBlock": "0x10d4f10",
"address": "0xdAC17F958D2ee523a2206206994597C13D831ec7",
"topics": ["0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef"],
"network": "mainnet"
}
}The topic 0xddf252ad... is the keccak256 hash of Transfer(address,address,uint256).
Paginating Event Logs
When querying event logs that may return large result sets, use pagination to retrieve results in manageable chunks. This is useful when:
- Querying popular contracts with many events
- Scanning large block ranges
- Avoiding response size limits or timeouts
Enable pagination with pageSize:
{
"tool": "eth_getLogs",
"parameters": {
"fromBlock": "0x10d4f00",
"toBlock": "0x10d5000",
"address": "0xdAC17F958D2ee523a2206206994597C13D831ec7",
"topics": ["0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef"],
"network": "mainnet",
"limit": 100
}
}Pagination response structure:
When pagination parameters are used, the response includes a pagination object:
{
"logs": [...],
"pagination": {
"total": 450,
"count": 100,
"offset": 0,
"limit": 100,
"has_more": true,
"next_offset": 100
}
}Retrieve subsequent pages with offset:
{
"tool": "eth_getLogs",
"parameters": {
"fromBlock": "0x10d4f00",
"toBlock": "0x10d5000",
"address": "0xdAC17F958D2ee523a2206206994597C13D831ec7",
"topics": ["0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef"],
"network": "mainnet",
"limit": 100,
"offset": 100
}
}Pagination workflow:
- Make initial request with
limitto get first page and total count - Check
pagination.has_moreto determine if more results exist - Use
pagination.next_offsetas theoffsetfor the next request - Continue until
has_moreisfalse
Best practices for pagination:
- Use limit values between 100-1000 depending on log complexity
- Always check
has_morerather than calculating from totals - For very large result sets, consider narrowing filters first
- Combine with
response_format: "markdown"for human-readable paginated output
Estimate Gas for a Transaction
{
"tool": "eth_estimateGas",
"parameters": {
"to": "0xdAC17F958D2ee523a2206206994597C13D831ec7",
"data": "0x70a08231000000000000000000000000d8dA6BF26964aF9D7eEd9e03E53415D37aA96045",
"network": "mainnet"
}
}Get Current Gas Price
{
"tool": "eth_gasPrice",
"parameters": {
"network": "mainnet"
}
}Result is in wei (hex). Divide by 10^9 to get Gwei.
Parameter Formats
Addresses
Format: 0x followed by exactly 40 hexadecimal characters.
Valid: 0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045
Invalid: 0xd8dA6BF26964aF9D7eEd9e03E53415D37aA9604 (39 chars)
Invalid: d8dA6BF26964aF9D7eEd9e03E53415D37aA96045 (missing 0x)Transaction and Block Hashes
Format: 0x followed by exactly 64 hexadecimal characters.
Valid: 0x88df016429689c079f3b2f6ad39fa052532c56795b733da78a91ebe6a713944b
Invalid: 0x88df016429689c079f3b2f6ad39fa052532c56795b733da78a91ebe6a713944 (63 chars)Block Tags
Use one of these string values:
| Tag | Description |
latest | Most recent mined block |
earliest | Genesis block (block 0) |
pending | Pending state/transactions |
safe | Latest safe head block |
finalized | Latest finalized block |
0x... | Specific block number in hex (e.g., 0x10d4f00) |
For most queries, use latest to get current state.
Hex Quantities
Format: 0x followed by hex digits with no leading zeros (except 0x0 for zero).
Valid: 0x0, 0x1, 0x10, 0x1a2b3c
Invalid: 0x01, 0x001 (leading zeros not allowed)Topics (for eth_getLogs)
Topics are 32-byte hex values used to filter event logs:
0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3efThe first topic is typically the event signature hash. Subsequent topics are indexed parameters.
Response Format
All tools support an optional response_format parameter that controls how results are returned:
| Format | Description | Use Case |
json | Raw JSON response (default) | Programmatic data processing |
markdown | Human-readable formatted output | Displaying results to users |
When to use each format:
- Use
json(default) when you need to process the data programmatically, extract specific fields, perform calculations, or pass data to other tools. - Use
markdownwhen displaying results directly to humans, creating reports, or when readability is more important than raw data access.
Example with markdown format:
{
"tool": "eth_getBalance",
"parameters": {
"address": "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045",
"tag": "latest",
"network": "mainnet",
"response_format": "markdown"
}
}The markdown format returns a formatted response with headers, tables, and human-readable values (e.g., ETH instead of wei).
Example with json format (default):
{
"tool": "eth_getBalance",
"parameters": {
"address": "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045",
"tag": "latest",
"network": "mainnet"
}
}Returns raw hex values suitable for programmatic processing.
Network Selection
Default Network
If network is not specified, queries default to mainnet (Ethereum mainnet).
Specifying a Network
Always include the network parameter for clarity:
{
"tool": "eth_getBalance",
"parameters": {
"address": "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045",
"tag": "latest",
"network": "polygon-mainnet"
}
}Supported Networks (37 total)
Ethereum
mainnet- Ethereum mainnetsepolia- Ethereum testnet
Layer 2 Networks
arbitrum-mainnet,arbitrum-sepolia- Arbitrumoptimism-mainnet,optimism-sepolia- Optimismbase-mainnet,base-sepolia- Baselinea-mainnet,linea-sepolia- Lineapolygon-mainnet,polygon-amoy- Polygonzksync-mainnet,zksync-sepolia- zkSync Erascroll-mainnet,scroll-sepolia- Scrollblast-mainnet,blast-sepolia- Blastmantle-mainnet,mantle-sepolia- Mantle
Alternative L1s
avalanche-mainnet,avalanche-fuji- Avalanche C-Chainbsc-mainnet,bsc-testnet- BNB Smart Chaincelo-mainnet,celo-alfajores- Celopalm-mainnet,palm-testnet- Palm
Other Networks
starknet-mainnet,starknet-sepolia- Starknetopbnb-mainnet,opbnb-testnet- opBNBswellchain-mainnet,swellchain-testnet- Swellchainunichain-mainnet,unichain-sepolia- Unichain
Popular Network Use Cases
| Use Case | Recommended Network |
| Production DeFi queries | mainnet |
| NFT data on Polygon | polygon-mainnet |
| Low-cost testing | sepolia, polygon-amoy |
| L2 transactions | arbitrum-mainnet, base-mainnet, optimism-mainnet |
| BNB Chain data | bsc-mainnet |
Error Handling
Common Errors
| Error | Cause | Solution |
Invalid Ethereum address | Address format incorrect | Ensure 0x + 40 hex characters |
Invalid hash | Hash format incorrect | Ensure 0x + 64 hex characters |
Invalid block tag | Unrecognized block reference | Use latest, earliest, pending, safe, finalized, or hex block number |
Invalid network | Network not supported | Check the supported networks list |
INFURA_API_KEY not set | Missing API key | Configure the environment variable |
Rate Limit Errors
If you receive rate limit errors:
- Wait a few seconds before retrying
- Reduce query frequency
- Batch related queries together when possible
Timeout Errors
For eth_getLogs queries that timeout:
- Reduce the block range (use smaller
fromBlocktotoBlockrange) - Add an
addressfilter to reduce results - Add
topicsfilters to narrow results
Retry Strategy
Retry on these conditions:
- Rate limit errors (429) - wait 1-5 seconds
- Timeout errors - reduce query scope and retry
- Network errors (5xx) - wait briefly and retry
Do not retry on:
- Validation errors (400) - fix the parameters
- Invalid method errors - check tool name
Best Practices
General Guidelines
- Always specify network explicitly - Even for mainnet, include
network: "mainnet"for clarity. - Use "latest" for current state - When you need the current blockchain state, use
tag: "latest". - Check transaction receipts for confirmation - A transaction in
eth_getTransactionByHashmay still be pending. Useeth_getTransactionReceiptto verify inclusion in a block. - Handle hex values properly - All numeric values are returned as hex strings. Convert them for display.
- Limit eth_getLogs block ranges - Query specific block ranges (e.g., 1000-2000 blocks) to avoid timeouts.
Converting Values
Wei to ETH:
ETH = Wei / 10^18
Example: 0xde0b6b3a7640000 (hex) = 1000000000000000000 (decimal) = 1 ETHWei to Gwei (for gas prices):
Gwei = Wei / 10^9
Example: 0x3b9aca00 (hex) = 1000000000 (decimal) = 1 GweiHex to Decimal:
0x10d4f00 = 17649408 (decimal)Efficient Querying
- Get multiple pieces of data in one flow - If you need balance and nonce, make both calls rather than asking the user to make separate requests.
- Use block numbers for consistency - If making multiple related queries, use a specific block number rather than "latest" to ensure consistency.
- Filter logs efficiently - Always provide the most specific filters possible (address, topics) to reduce response size.
- Check block number first - Use
eth_blockNumberto get the latest block, then use that number for subsequent queries.
Security Notes
- All tools are read-only and cannot modify blockchain state
- Never ask users to share private keys - this server cannot use them
- Validate addresses before querying to provide better error messages
- Be aware that blockchain data is public - balance queries reveal holdings
Example Workflows
Investigate a Wallet
- Get ETH balance:
eth_getBalance - Get transaction count (nonce):
eth_getTransactionCount - Check if it's a contract:
eth_getCode(empty = EOA, non-empty = contract)
Analyze a Transaction
- Get transaction details:
eth_getTransactionByHash - Get receipt for status and logs:
eth_getTransactionReceipt - Get the block it was included in:
eth_getBlockByNumber
Monitor Contract Events
- Get current block:
eth_blockNumber - Query recent logs:
eth_getLogswith appropriate filters - Parse log data to understand events
Check Network Status
- Get chain ID:
eth_chainId - Check sync status:
eth_syncing - Get current gas price:
eth_gasPrice
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

