foundry-mcp
Allows interaction with Ethereum-based networks, including deploying contracts, querying chain state, sending transactions, and managing local nodes via Anvil.
Provides tools for compiling, testing, inspecting, and formatting Solidity smart contracts, as well as generating documentation and gas estimates.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@foundry-mcprun my forge tests"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
@maxencerb/foundry-mcp
A comprehensive Model Context Protocol (MCP) server for the Foundry Ethereum development toolkit. This server enables AI assistants like Claude to interact with Forge, Cast, Anvil, and Chisel directly.
Features
80+ Tools covering all major Foundry commands
Resources for project configuration, ABIs, bytecode, and documentation
Prompts for common workflows (deployment, testing, security review)
Self-documenting with live
--helpintegration and official docs fetching
Tools Overview
Category | Tools | Description |
Forge | 18 | Build, test, deploy, verify contracts |
Cast | 38 | Interact with EVM chains, encode/decode data |
Anvil | 16 | Local node management, state manipulation |
Chisel | 6 | Solidity REPL operations |
Help | 6 | Live documentation from |
Related MCP server: Foundry MCP Project
Prerequisites
# Install Foundry
curl -L https://foundry.paradigm.xyz | bash
foundryupInstallation
# Using bun
bunx @maxencerb/foundry-mcp
# Or install globally
bun install -g @maxencerb/foundry-mcpUsage
With Claude Code
Add the MCP server using the CLI:
# Add with environment variables
claude mcp add --transport stdio --env RPC_URL=http://localhost:8545 foundry -- bunx @maxencerb/foundry-mcp
# Or add project-scoped (creates .mcp.json)
claude mcp add --transport stdio --scope project foundry -- bunx @maxencerb/foundry-mcpOr create a .mcp.json file in your project root:
{
"mcpServers": {
"foundry": {
"command": "bunx",
"args": ["@maxencerb/foundry-mcp"],
"env": {
"RPC_URL": "${RPC_URL:-http://localhost:8545}"
}
}
}
}With Claude Desktop
Add to your Claude Desktop configuration (~/Library/Application Support/Claude/claude_desktop_config.json on macOS):
{
"mcpServers": {
"foundry": {
"command": "bunx",
"args": ["@maxencerb/foundry-mcp"],
"env": {
"RPC_URL": "http://localhost:8545"
}
}
}
}With Other MCP Clients
# Run the server directly
bunx @maxencerb/foundry-mcp
# Or if installed globally
foundry-mcpEnvironment Variables
Variable | Description | Default |
| Default RPC endpoint for chain interactions | - |
| Default private key for transactions (⚠️ testing only) | - |
| Path to Foundry project | Current directory |
Available Tools
Forge Tools
Tool | Description |
| Initialize a new Foundry project |
| Compile Solidity contracts |
| Run tests with filtering and forking |
| Generate test coverage reports |
| Execute deployment scripts |
| Deploy a single contract |
| Verify contracts on block explorers |
| Inspect ABI, bytecode, storage layout |
| Flatten contract sources |
| Show import remappings |
| Show dependency tree |
| Remove build artifacts |
| Install dependencies |
| Update dependencies |
| Format Solidity code |
| Generate gas snapshots |
| Generate documentation |
| List function selectors |
Cast Tools
Chain & Block:
cast_block, cast_block_number, cast_chain, cast_chain_id, cast_client, cast_gas_price, cast_base_fee
Account:
cast_balance, cast_nonce, cast_code, cast_storage
Transactions:
cast_call, cast_send, cast_publish, cast_tx, cast_receipt, cast_run, cast_estimate, cast_logs
Encoding/Decoding:
cast_abi_encode, cast_abi_decode, cast_calldata, cast_calldata_decode, cast_sig, cast_sig_event, cast_4byte, cast_4byte_decode
Utilities:
cast_to_wei, cast_from_wei, cast_to_hex, cast_to_dec, cast_to_base, cast_keccak, cast_resolve_name, cast_lookup_address, cast_compute_address, cast_create2, cast_interface, cast_age, cast_wallet_new, cast_wallet_address, cast_wallet_sign, cast_format_bytes32, cast_parse_bytes32, cast_concat_hex
Anvil Tools
Tool | Description |
| Start a local Ethereum node |
| Stop a running node |
| Check node status |
| Mine blocks |
| Set account balance |
| Set contract bytecode |
| Set storage slot value |
| Impersonate an account |
| Stop impersonating |
| Create state snapshot |
| Revert to snapshot |
| Set next block timestamp |
| Increase block time |
| Toggle auto-mining |
| Reset fork state |
| List dev accounts |
Chisel Tools
Tool | Description |
| Evaluate Solidity expression |
| Run Solidity statements |
| List saved sessions |
| Load a session |
| View session source |
| Clear cache |
Help Tools
Tool | Description |
| Get forge CLI help (supports subcommands) |
| Get cast CLI help (supports subcommands) |
| Get anvil CLI help |
| Get chisel CLI help |
| Get installed Foundry versions |
| List available commands for a tool |
Available Resources
Resource | URI | Description |
Config |
| Project's foundry.toml |
Remappings |
| Import remappings |
Contracts |
| List of .sol files |
ABI |
| Contract ABI |
Bytecode |
| Contract bytecode |
Storage Layout |
| Storage layout |
Method IDs |
| Function selectors |
Gas Estimates |
| Gas estimates |
Documentation |
| Official Foundry docs |
Doc Links |
| Documentation URLs |
Available Prompts
Prompt | Description |
| Guide for deploying a contract |
| Help debug a failing test |
| Generate tests for a contract |
| Explain storage layout |
| Review for gas optimization |
| Security review checklist |
| Test against forked state |
| Create deployment script |
| Look up command documentation |
Development
# Clone the repository
git clone https://github.com/maxencerb/foundry-mcp.git
cd foundry-mcp
# Install dependencies
bun install
# Run in development mode
bun run dev
# Type check
bun run typecheck
# Test with MCP Inspector
bun run inspectContributing
Fork the repository
Create a feature branch
Add a changeset:
bunx changesetSubmit a pull request
Security Notice
⚠️ Never use private keys with real funds when using this MCP server. LLMs can make mistakes and send unintended transactions. Use only for testing and development with test accounts.
Documentation
License
MIT
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/maxencerb/foundry-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server