Foundry MCP Server
A simple, lightweight and fast MCP (Model Context Protocol) server that provides Solidity development capabilities using the Foundry toolchain (Forge, Cast, and Anvil).
Overview
This server connects LLM assistants to the Foundry ecosystem, enabling them to:
Interact with nodes (local Anvil instances or remote RPC endpoints)
Analyze smart contracts and blockchain data
Perform common EVM operations using Cast
Manage, deploy, and execute Solidity code and scripts
Work with a persistent Forge workspace
Features
Network Interaction
Start and manage local Anvil instances
Connect to any remote network (just specify the RPC)
Get network/chain information
Contract Interaction
Call contract functions (read-only)
Send transactions to contracts (if
PRIVATE_KEY
is configured)Get transaction receipts
Read contract storage
Analyze transaction traces
Retrieve contract ABIs and sources from block explorers
Solidity Development
Maintain a dedicated Forge workspace
Create and edit Solidity files
Install dependencies
Run Forge scripts
Deploy contracts
Utility Functions
Calculate contract addresses
Check contract bytecode size
Estimate gas costs
Convert between units (hex to decimals, etc.,)
Generate wallets
Get event logs
Lookup function and event signatures
Usage
The server is designed to be used as an MCP tool provider for MCP Clients. When connected to a client, it enables the clients(claude desktop, cursor, client, etc.,) to perform Solidity and onchain operations directly.
Requirements
Foundry toolchain (Forge, Cast, Anvil)
Manual Setup
Ensure Foundry tools (Forge, Cast, Anvil) are installed on your system:
curl -L https://foundry.paradigm.xyz | bash foundryupClone and build the server.
bun i && bun build ./src/index.ts --outdir ./dist --target nodeUpdate your client config (eg: Claude desktop):
PRIVATE_KEY
is optional
Setup using NPM Package
Coming soon
Configuration
The server supports the following environment variables:
RPC_URL
: Default RPC URL to use when none is specified (optional)PRIVATE_KEY
: Private key to use for transactions (optional)
Do not add keys with mainnet funds. Even though the code uses it safely, LLMs can hallicunate and send malicious transactions. Use it only for testing/development purposes. DO NOT trust the LLM!!
Workspace
The server maintains a persistent Forge workspace at ~/.mcp-foundry-workspace
for all Solidity files, scripts, and dependencies.
Tools
Anvil
anvil_start
: Start a new Anvil instanceanvil_stop
: Stop a running Anvil instanceanvil_status
: Check if Anvil is running and get its status
Cast
cast_call
: Call a contract function (read-only)cast_send
: Send a transaction to a contract functioncast_balance
: Check the ETH balance of an addresscast_receipt
: Get the transaction receiptcast_storage
: Read contract storage at a specific slotcast_run
: Run a published transaction in a local environmentcast_logs
: Get logs by signature or topiccast_sig
: Get the selector for a function or event signaturecast_4byte
: Lookup function or event signature from the 4byte directorycast_chain
: Get information about the current chain
Forge
forge_script
: Run a Forge script from the workspaceinstall_dependency
: Install a dependency for the Forge workspace
File Management
create_solidity_file
: Create or update a Solidity file in the workspaceread_file
: Read the content of a file from the workspacelist_files
: List files in the workspace
Utilities
convert_eth_units
: Convert between EVM units (wei, gwei, hex)compute_address
: Compute the address of a contract that would be deployedcontract_size
: Get the bytecode size of a deployed contractestimate_gas
: Estimate the gas cost of a transaction
Usage in Claude Desktop App 🎯
Once the installation is complete, and the Claude desktop app is configured, you must completely close and re-open the Claude desktop app to see the tavily-mcp server. You should see a hammer icon in the bottom left of the app, indicating available MCP tools, you can click on the hammer icon to see more details on the available tools.
Now claude will have complete access to the foundry-mcp server. If you insert the below examples into the Claude desktop app, you should see the foundry-mcp server tools in action.
Examples
Transaction analysis:
Querying Balances:
Sending transactions:
Deploying contracts/Running scripts:
Acknowledgments ✨
Model Context Protocol for the MCP specification
Anthropic for Claude Desktop
Disclaimer
The software is being provided as is. No guarantee, representation or warranty is being made, express or implied, as to the safety or correctness of the software. They have not been audited and as such there can be no assurance they will work as intended, and users may experience delays, failures, errors, omissions, loss of transmitted information or loss of funds. The creators are not liable for any of the foregoing. Users should proceed with caution and use at their own risk.
This server cannot be installed
hybrid server
The server is able to function both locally and remotely, depending on the configuration or use case.
A lightweight, fast MCP server that provides onchain capabilities for the LLMs and Agents.
Related MCP Servers
- AsecurityAlicenseAqualityAn MCP server providing unified access to blockchain operations, bridging, swapping, and crypto trading strategies for AI agents.Last updated -37189GPL 3.0
- AsecurityAlicenseAqualityAn MCP server that enables LLMs to perform blockchain operations on the Base network through natural language commands, including wallet management, balance checking, and transaction execution.Last updated -4122MIT License
- AsecurityFlicenseAqualityAn MCP server that fetches real-time documentation for popular libraries like Langchain, Llama-Index, MCP, and OpenAI, allowing LLMs to access updated library information beyond their knowledge cut-off dates.Last updated -12
- AsecurityFlicenseAqualityA lightweight MCP server that provides a unified interface to various LLM providers including OpenAI, Anthropic, Google Gemini, Groq, DeepSeek, and Ollama.Last updated -6654