agentleFS
QbandevQbandev/infura-mcp-server/AGENTS.md

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 code style.

    Of the AGENTS.md files we read, the 35,196 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.

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
  1. Very specific:

    Read smart contract state via eth_call

    line 12
  2. Distinctive:

    Check network status and chain IDs

    line 15
  3. Distinctive:

    Use these to check wallet and contract information.

    line 26
  4. Distinctive:

    Use these to retrieve block data and metadata.

    line 36
  5. Distinctive:

    Use these to get transaction details and receipts.

    line 50
  6. Distinctive:

    Use these to read smart contract state.

    line 63
  7. Distinctive:

    Use this to query contract events.

    line 73
  8. Distinctive:

    Use these to get network status and metadata.

    line 81
  9. Distinctive:

    Use these for gas estimation and fee data.

    line 93
  10. Very specific:

    Use eth_getTransactionReceipt to verify confirmation:

    line 152
  11. Distinctive:

    When querying event logs that may return large result sets, use pagination to retrieve results in manageable chunks.

    line 187
  12. Very specific:

    When pagination parameters are used, the response includes a pagination object:

    line 211
  13. Very specific:

    Check pagination.has_more to determine if more results exist

    line 247
  14. Very specific:

    Use pagination.next_offset as the offset for the next request

    line 248
  15. Distinctive:

    Use limit values between 100-1000 depending on log complexity

    line 253
  16. Very specific:

    Always check has_more rather than calculating from totals

    line 254
  17. Distinctive:

    Use one of these string values:

    line 307
  18. Very specific:

    All tools support an optional response_format parameter that controls how results are returned:

    line 341
  19. Very specific:

    Use json (default): when you need to process the data programmatically, extract specific fields, perform calculations, or pass data to …

    line 350
  20. Very specific:

    Use markdown: when displaying results directly to humans, creating reports, or when readability is more important than raw data access.

    line 352
  21. Very specific:

    If network is not specified, queries default to mainnet (Ethereum mainnet).

    line 389
  22. Very specific:

    Always include the network parameter for clarity:

    line 393
  23. Distinctive:

    If you receive rate limit errors:

    line 459
  24. Distinctive:

    Wait a few seconds before retrying

    line 460
  25. Very specific:

    Add an address filter to reduce results

    line 468
  26. Very specific:

    Add topics filters to narrow results

    line 469
  27. Distinctive:

    Do not retry on:

    line 478
  28. Very specific:

    Use "latest" for current state: - When you need the current blockchain state, use tag: "latest".

    line 488
  29. Distinctive:

    Handle hex values properly: - All numeric values are returned as hex strings.

    line 492
  30. Distinctive:

    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 …

    line 517
  31. Distinctive:

    Use block numbers for consistency: - If making multiple related queries, use a specific block number rather than "latest" to ensure …

    line 519
  32. Distinctive:

    Filter logs efficiently: - Always provide the most specific filters possible (address, topics) to reduce response size.

    line 521
  33. Very specific:

    Check block number first: - Use eth_blockNumber to get the latest block, then use that number for subsequent queries.

    line 523
  34. Distinctive:

    All tools are read-only and cannot modify blockchain state

    line 527
  35. Common:

    Never ask users to share private keys - this server cannot use them

    line 528
  36. Very specific:

    Check if it's a contract: eth_getCode (empty = EOA, non-empty = contract)

    line 538
  37. Very specific:

    Check sync status: eth_syncing

    line 555

≈ “Common” is an estimate: at least 1 in 5 of the 45,344 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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
AGENTS.md

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.

ToolPurposeKey Parameters
eth_getBalanceGet ETH balance of an addressaddress, tag, network
eth_getTransactionCountGet nonce (transaction count)address, tag, network
eth_getCodeGet contract bytecodeaddress, tag, network

Block Queries (7 tools)

Use these to retrieve block data and metadata.

ToolPurposeKey Parameters
eth_blockNumberGet latest block numbernetwork
eth_getBlockByHashGet block by its hashblockHash, fullTransactions, network
eth_getBlockByNumberGet block by numberblockNumber, fullTransactions, network
eth_getBlockTransactionCountByHashCount transactions in blockblockHash, network
eth_getBlockTransactionCountByNumberCount transactions in blockblockNumber, network
eth_getUncleCountByBlockHashCount uncles in blockblockHash, network
eth_getUncleCountByBlockNumberCount uncles in blockblockNumber, network

Transaction Queries (6 tools)

Use these to get transaction details and receipts.

ToolPurposeKey Parameters
eth_getTransactionByHashGet transaction by hashtransactionHash, network
eth_getTransactionReceiptGet transaction receipttransactionHash, network
eth_getTransactionByBlockHashAndIndexGet transaction by positionblockHash, index, network
eth_getTransactionByBlockNumberAndIndexGet transaction by positionblockNumber, index, network
eth_getUncleByBlockHashAndIndexGet uncle blockblockHash, index, network
eth_getUncleByBlockNumberAndIndexGet uncle blockblockNumber, index, network

Contract Interactions (3 tools)

Use these to read smart contract state.

ToolPurposeKey Parameters
eth_callExecute read-only contract callto, data, network
eth_estimateGasEstimate gas for a callto, data, from, value, network
eth_getStorageAtRead contract storage slotaddress, position, tag, network

Log Queries (1 tool)

Use this to query contract events.

ToolPurposeKey Parameters
eth_getLogsQuery event logsfromBlock, toBlock, address, topics, network

Network Information (5 tools)

Use these to get network status and metadata.

ToolPurposeKey Parameters
eth_chainIdGet chain IDnetwork
net_versionGet network versionnetwork
net_listeningCheck if node is listeningnetwork
net_peerCountGet connected peer countnetwork
web3_clientVersionGet client versionnetwork

Gas and Fees (4 tools)

Use these for gas estimation and fee data.

ToolPurposeKey Parameters
eth_gasPriceGet current gas pricenetwork
eth_feeHistoryGet historical fee datablockCount, newestBlock, rewardPercentiles, network
eth_protocolVersionGet protocol versionnetwork
eth_syncingGet sync statusnetwork

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 for balanceOf(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:

  1. Make initial request with limit to get first page and total count
  2. Check pagination.has_more to determine if more results exist
  3. Use pagination.next_offset as the offset for the next request
  4. Continue until has_more is false

Best practices for pagination:

  • Use limit values between 100-1000 depending on log complexity
  • Always check has_more rather 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:

TagDescription
latestMost recent mined block
earliestGenesis block (block 0)
pendingPending state/transactions
safeLatest safe head block
finalizedLatest 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:

0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef

The 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:

FormatDescriptionUse Case
jsonRaw JSON response (default)Programmatic data processing
markdownHuman-readable formatted outputDisplaying 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 markdown when 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 mainnet
  • sepolia - Ethereum testnet

Layer 2 Networks

  • arbitrum-mainnet, arbitrum-sepolia - Arbitrum
  • optimism-mainnet, optimism-sepolia - Optimism
  • base-mainnet, base-sepolia - Base
  • linea-mainnet, linea-sepolia - Linea
  • polygon-mainnet, polygon-amoy - Polygon
  • zksync-mainnet, zksync-sepolia - zkSync Era
  • scroll-mainnet, scroll-sepolia - Scroll
  • blast-mainnet, blast-sepolia - Blast
  • mantle-mainnet, mantle-sepolia - Mantle

Alternative L1s

  • avalanche-mainnet, avalanche-fuji - Avalanche C-Chain
  • bsc-mainnet, bsc-testnet - BNB Smart Chain
  • celo-mainnet, celo-alfajores - Celo
  • palm-mainnet, palm-testnet - Palm

Other Networks

  • starknet-mainnet, starknet-sepolia - Starknet
  • opbnb-mainnet, opbnb-testnet - opBNB
  • swellchain-mainnet, swellchain-testnet - Swellchain
  • unichain-mainnet, unichain-sepolia - Unichain

Popular Network Use Cases

Use CaseRecommended Network
Production DeFi queriesmainnet
NFT data on Polygonpolygon-mainnet
Low-cost testingsepolia, polygon-amoy
L2 transactionsarbitrum-mainnet, base-mainnet, optimism-mainnet
BNB Chain databsc-mainnet

Error Handling

Common Errors

ErrorCauseSolution
Invalid Ethereum addressAddress format incorrectEnsure 0x + 40 hex characters
Invalid hashHash format incorrectEnsure 0x + 64 hex characters
Invalid block tagUnrecognized block referenceUse latest, earliest, pending, safe, finalized, or hex block number
Invalid networkNetwork not supportedCheck the supported networks list
INFURA_API_KEY not setMissing API keyConfigure the environment variable

Rate Limit Errors

If you receive rate limit errors:

  1. Wait a few seconds before retrying
  2. Reduce query frequency
  3. Batch related queries together when possible

Timeout Errors

For eth_getLogs queries that timeout:

  1. Reduce the block range (use smaller fromBlock to toBlock range)
  2. Add an address filter to reduce results
  3. Add topics filters 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

  1. Always specify network explicitly - Even for mainnet, include network: "mainnet" for clarity.
  2. Use "latest" for current state - When you need the current blockchain state, use tag: "latest".
  3. Check transaction receipts for confirmation - A transaction in eth_getTransactionByHash may still be pending. Use eth_getTransactionReceipt to verify inclusion in a block.
  4. Handle hex values properly - All numeric values are returned as hex strings. Convert them for display.
  5. 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 ETH

Wei to Gwei (for gas prices):

Gwei = Wei / 10^9
Example: 0x3b9aca00 (hex) = 1000000000 (decimal) = 1 Gwei

Hex to Decimal:

0x10d4f00 = 17649408 (decimal)

Efficient Querying

  1. 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.
  2. Use block numbers for consistency - If making multiple related queries, use a specific block number rather than "latest" to ensure consistency.
  3. Filter logs efficiently - Always provide the most specific filters possible (address, topics) to reduce response size.
  4. Check block number first - Use eth_blockNumber to 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

  1. Get ETH balance: eth_getBalance
  2. Get transaction count (nonce): eth_getTransactionCount
  3. Check if it's a contract: eth_getCode (empty = EOA, non-empty = contract)

Analyze a Transaction

  1. Get transaction details: eth_getTransactionByHash
  2. Get receipt for status and logs: eth_getTransactionReceipt
  3. Get the block it was included in: eth_getBlockByNumber

Monitor Contract Events

  1. Get current block: eth_blockNumber
  2. Query recent logs: eth_getLogs with appropriate filters
  3. Parse log data to understand events

Check Network Status

  1. Get chain ID: eth_chainId
  2. Check sync status: eth_syncing
  3. Get current gas price: eth_gasPrice

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.