Labsco
MCP SERVER

Foundry MCP Server

by PraneshASP

Drive Forge, Cast and Anvil from the conversation - read contracts, send transactions, and decompile bytecode you have no source for.

Chain State, Explorers & Contract Tooling
Summary
Onchain investigation and Solidity work in the same session.

The reading half - traces, storage, decompiled bytecode - is where this earns its place: an unverified contract stops being opaque. The writing half is real too, and the project is blunt about the risk: give it a key with testnet funds only, because a model that hallucinates here spends money.

What it is

An MCP layer over the Foundry toolchain. It keeps a persistent Forge workspace at ~/.mcp-foundry-workspace, so Solidity files, scripts and installed dependencies survive between calls.

What you get
  • Start, stop and inspect a local Anvil instance, or point the same tools at any RPC endpoint
  • Read-only contract calls, transactions, receipts, raw storage slots and event logs
  • Replay a published transaction locally, and look up a function or event signature from the 4byte directory
  • Write Solidity into the workspace, install dependencies, and run a Forge script
  • Unit conversion between wei, gwei and hex, deployed-address computation, bytecode size and gas estimates
  • Heimdall analysis: disassemble bytecode, decode calldata without an ABI, decompile to Solidity, or draw a control flow graph
Requirements

Node.js v18+ and the Foundry toolchain (Forge, Cast, Anvil) installed. Heimdall-rs is needed only for the bytecode-analysis tools. Run it with npx @pranesh.asp/foundry-mcp-server. RPC_URL and PRIVATE_KEY are both optional environment variables - without a private key the server is read-only.

Setup effort

One command — npx @pranesh.asp/foundry-mcp-server