infura-mcp-server / rules
Cursor rule4 starsChanged 18 months agoMITView on GitHub
This document provides comprehensive guidance for AI assistants on: - 29 read-only Ethereum JSON-RPC tools usage patterns - Blockchain integration and technical architecture - Security best practices - Development guidelines - Common troubleshooting scenarios The Infura MCP Server is a Model Context Protocol (MCP) server that provides 29 read-only Ethereum JSON-RPC tools with multi-network support. It enables AI assistants like Claude Desktop and Cursor to interact with Ethereum blockchain data through Infura's infrastructure. Primary Networks (fully tested): **Additional Infura Networks…
- Reads credentials
Where files are headingNew Cursor rule files have more rules about planning and tracking tasks, and fewer about code style.
Of the Cursor rule files we read, the 1,527 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.
- AGENTS.mdAGENTS.md
The file
Show its rules and text
We split this infura-mcp-server.mdc into the rules it gives an agent
13 rules. About 0 are common, 10 are distinctive, and 3 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈10
Distinctive · estimate
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 135
Use English for all code, documentation, and comments
- Very specific: line 136
Follow ES module syntax (import/export)
- Distinctive: line 137
Use camelCase for variables and functions
- Distinctive: line 138
Use PascalCase for class names
- Distinctive: line 139
Use snake_case for file names
- Very specific: line 169
Access Control: Only repository owner (Qbandev) can trigger releases
- Distinctive: line 171
GPG Signatures: All commits must be GPG signed
- Distinctive: line 172
Audit Logging: All release attempts logged for security monitoring
- Very specific: line 275
Use eth_estimateGas before transactions
- Distinctive: line 277
Consider EIP-1559 fee mechanisms
- Distinctive: line 299
All commits must be GPG signed
- Distinctive: line 300
Follow principle of least privilege
- Distinctive: line 302
Use environment variables for secrets
≈ “Common” is an estimate: at least 1 in 5 of the 3,030 Cursor rule 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
---
description:
globs:
alwaysApply: true
---
---
description: "Comprehensive project context for the Infura MCP Server - provides technical architecture, development guidelines, testing strategy, release automation, and blockchain integration details"
globs:
- "*.js"
- "*.json"
- "package.json"
- "*.md"
- ".github/**/*"
- "tools/**/*"
- "scripts/**/*"
- "test/**/*"
alwaysApply: true
---
# Infura MCP Server Project Context
## 📚 AI Assistant Resources
This document provides comprehensive guidance for AI assistants on:
- 29 read-only Ethereum JSON-RPC tools usage patterns
- Blockchain integration and technical architecture
- Security best practices
- Development guidelines
- Common troubleshooting scenarios
## Project Overview
The Infura MCP Server is a Model Context Protocol (MCP) server that provides 29 read-only Ethereum JSON-RPC tools with multi-network support. It enables AI assistants like Claude Desktop and Cursor to interact with Ethereum blockchain data through Infura's infrastructure.
### Key Statistics
- **Language**: Node.js ES modules (type: "module")
- **Tools**: 29 read-only Ethereum JSON-RPC methods
- **Networks**: 30+ network endpoints across 18 blockchain ecosystems supported
- **Transport**: SSE and stdio modes
- **Version**: Published on npm as `infura-mcp-server`
- **Security**: GPG signed commits, strict release access control
## Technical Architecture
### Core Files
- `mcpServer.js` - Main MCP server implementation
- `index.js` - Entry point and CLI handling
- `tools/` - 29 read-only Ethereum JSON-RPC tools
- `commands/` - Command definitions and metadata
- `lib/` - Utility functions and helpers
- `test/` - Validation and testing scripts
### Supported Networks
**Primary Networks (fully tested):**
```javascript
const PRIMARY_NETWORKS = {
mainnet: 'mainnet',
optimism: 'optimism-mainnet',
arbitrum: 'arbitrum-mainnet',
polygon: 'polygon-mainnet',
base: 'base-mainnet',
sepolia: 'sepolia'
};
```
**Additional Infura Networks (available via INFURA_NETWORK env var):**
- `avalanche-mainnet` / `avalanche-fuji` - Avalanche C-Chain
- `bsc-mainnet` / `bsc-testnet` - Binance Smart Chain
- `celo-mainnet` / `celo-alfajores` - Celo
- `linea-mainnet` / `linea-sepolia` - Linea
- `mantle-mainnet` / `mantle-sepolia` - Mantle
- `palm-mainnet` / `palm-testnet` - Palm
- `scroll-mainnet` / `scroll-sepolia` - Scroll
- `starknet-mainnet` / `starknet-sepolia` - Starknet
- `zksync-mainnet` / `zksync-sepolia` - ZKsync Era
- `blast-mainnet` / `blast-sepolia` - Blast
- `opbnb-mainnet` / `opbnb-testnet` - opBNB
- `swellchain-mainnet` / `swellchain-testnet` - Swellchain
- `unichain-mainnet` / `unichain-sepolia` - Unichain
**Reference**: [Complete Infura Endpoints List](mdc:https:/docs.metamask.io/services/get-started/endpoints)
### Environment Variables
- `INFURA_API_KEY` - Required Infura API key
- `INFURA_NETWORK` - Network selection (defaults to mainnet)
- `DEBUG` - Enable debug logging
## Available Tools (29)
### Account & Balance Tools
- `eth_getBalance` - Get the native token balance of an account.
- `eth_getCode` - Get the compiled smart contract code at an address.
- `eth_getTransactionCount` - Get the number of transactions sent from an address (nonce).
### Block Tools
- `eth_getBlockNumber` - Get the number of the most recent block.
- `eth_getBlockByHash` - Get information on a block by its hash.
- `eth_getBlockByNumber` - Get information on a block by its number.
- `eth_getUncleByBlockHashAndIndex` - Get information about an uncle of a block by hash and index.
- `eth_getUncleByBlockNumberAndIndex` - Get information about an uncle of a block by number and index.
- `eth_getUncleCountByBlockHash` - Get the number of uncles in a block from a block matching the given block hash.
- `eth_getUncleCountByBlockNumber` - Get the number of uncles in a block matching the given block number.
### Transaction Tools
- `eth_getBlockTransactionCountByHash` - Get the number of transactions in a block from a block matching the given hash.
- `eth_getBlockTransactionCountByNumber` - Get the number of transactions in a block matching the given block number.
- `eth_getTransactionByBlockHashAndIndex` - Get information about a transaction by block hash and transaction index position.
- `eth_getTransactionByBlockNumberAndIndex` - Get information about a transaction by block number and transaction index.
- `eth_getTransactionByHash` - Get the information about a transaction requested by transaction hash.
- `eth_getTransactionReceipt` - Get the receipt of a transaction by transaction hash.
### Smart Contract Tools
- `eth_call` - Execute a read-only call to a smart contract.
- `eth_estimateGas` - Estimate the gas necessary to perform a transaction.
- `eth_getStorageAt` - Get the value from a storage position at a given address.
- `eth_getLogs` - Get an array of all logs matching a given filter object.
### Network & Node Tools
- `eth_chainId` - Get the chain ID of the current network.
- `net_isListening` - Check if the client is actively listening for network connections.
- `net_getPeerCount` - Get the number of peers currently connected to the client.
- `net_getVersion` - Get the network ID.
- `web3_getClientVersion` - Get the current client version.
- `eth_getProtocolVersion` - Get the current ethereum protocol version.
- `eth_isSyncing` - Check if the node is currently synchronizing with the network.
### Fee & Gas Tools
- `eth_getFeeHistory` - Get historical gas fee data.
- `eth_getGasPrice` - Get the current price per gas in wei.
## Development Guidelines
### Code Style
- Use English for all code, documentation, and comments
- Follow ES module syntax (`import`/`export`)
- Use camelCase for variables and functions
- Use PascalCase for class names
- Use snake_case for file names
- Implement proper error handling with structured responses
### Testing Strategy
```bash
npm test # Run validation + tools discovery
npm run test:validate # Package.json validation
npm run test:tools # Validate all 29 tools
npm run test:sse # SSE functionality test
```
### Docker Support
```dockerfile
FROM node:20-alpine
WORKDIR /app
COPY package*.json ./
RUN npm ci --only=production
COPY . .
EXPOSE 3000
CMD ["npm", "start"]
```
## Release Automation & Security
### Automated Release System
- **Scripts**: `scripts/release.sh` (bash) and `scripts/release.js` (Node.js)
- **NPM Commands**: `npm run release:patch|minor|major|beta|alpha`
- **GitHub Workflows**: Automated testing, versioning, tagging, and publishing
### Security Features
- **Access Control**: Only repository owner (`Qbandev`) can trigger releases
- **Authorization Job**: Pre-flight security check in GitHub Actions
- **GPG Signatures**: All commits must be GPG signed
- **Audit Logging**: All release attempts logged for security monitoring
### Release Process
1. Authorization verification (owner check)
2. Comprehensive testing (all 29 tools)
3. Version bumping (semantic versioning)
4. Git tagging and changelog generation
5. GitHub release creation
6. Automatic npm publishing
## Error Handling Patterns
### Structured Error Responses
```javascript
return {
isError: true,
error: {
code: 'INFURA_ERROR',
message: 'Human-readable error message',
details: errorDetails
}
};
```
### Common Error Types
- `INFURA_API_ERROR` - Infura service errors
- `INVALID_PARAMETERS` - Parameter validation failures
- `NETWORK_ERROR` - Connection issues
- `RATE_LIMIT_ERROR` - API rate limiting
## MCP Integration
### Transport Modes
- **stdio**: Standard input/output for Claude Desktop
- **SSE**: Server-Sent Events for web applications
### Tool Registration
```javascript
server.setRequestHandler(ListToolsRequestSchema, async () => ({
tools: tools.map(tool => ({
name: tool.name,
description: tool.description,
inputSchema: tool.inputSchema
}))
}));
```
## Claude Desktop Configuration
```json
{
"mcpServers": {
"Infura MCP Server": {
"command": "npx",
"args": ["infura-mcp-server"],
"env": {
"INFURA_API_KEY": "your_api_key_here"
}
}
}
}
```
## Cursor Integration
```json
{
"mcpServers": {
"Infura MCP Server": {
"command": "npx",
"args": ["infura-mcp-server"],
"env": {
"INFURA_API_KEY": "your_api_key_here"
}
}
}
}
```
## Network-Specific Usage
```bash
# Mainnet (default)
INFURA_API_KEY=your_key npx infura-mcp-server
# Polygon
INFURA_API_KEY=your_key INFURA_NETWORK=polygon-mainnet npx infura-mcp-server
# Arbitrum
INFURA_API_KEY=your_key INFURA_NETWORK=arbitrum-mainnet npx infura-mcp-server
# Avalanche C-Chain
INFURA_API_KEY=your_key INFURA_NETWORK=avalanche-mainnet npx infura-mcp-server
# Binance Smart Chain
INFURA_API_KEY=your_key INFURA_NETWORK=bsc-mainnet npx infura-mcp-server
```
## Performance Considerations
### Rate Limiting
- Infura enforces API rate limits
- Implement exponential backoff for retries
- Cache frequently accessed data when appropriate
### Gas Optimization
- Use `eth_estimateGas` before transactions
- Monitor gas prices with `eth_gasPrice`
- Consider EIP-1559 fee mechanisms
## Contributing Guidelines
### Conventional Commits
- `feat:` - New features
- `fix:` - Bug fixes
- `docs:` - Documentation changes
- `test:` - Test additions/changes
- `ci:` - CI/CD changes
- `security:` - Security improvements
### Development Workflow
1. Clone repository
2. Install dependencies: `npm install`
3. Set environment variables
4. Run tests: `npm test`
5. Create feature branch
6. Make changes with GPG signed commits
7. Submit pull request
### Security Requirements
- All commits must be GPG signed
- Follow principle of least privilege
- Validate all user inputs
- Use environment variables for secrets
- Regular security audits of dependencies
## Important Files Reference
- `package.json` - Project metadata and dependencies
- `mcpServer.js` - Core server implementation
- `tools/` - All 29 read-only Ethereum JSON-RPC tools
- `.github/workflows/`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.

