Skip to main content
Glama

foundry-mcp

npm version License: MIT

MCP server that exposes Foundry (forge, cast, anvil) CLI tools to AI assistants via the Model Context Protocol.

Prerequisites

Related MCP server: evmSDK MCP Server

Install

npm install -g @maliketh/foundry-mcp

Or run directly with npx:

npx @maliketh/foundry-mcp

Usage

Add to your MCP client configuration:

{
  "mcpServers": {
    "foundry": {
      "command": "npx",
      "args": ["foundry-mcp"]
    }
  }
}

The server communicates over stdio and exposes 39 tools across three categories.

Tools

Forge (17 tools)

Tool

Description

forge_init

Scaffold a new Foundry project

forge_build

Compile contracts

forge_test

Run tests with filtering, verbosity, gas reporting

forge_script

Run Solidity scripts

forge_create

Deploy contracts

forge_verify

Verify contracts on block explorers

forge_coverage

Generate coverage reports

forge_snapshot

Create gas snapshots

forge_fmt

Format Solidity code

forge_lint

Lint Solidity code

forge_clean

Remove build artifacts

forge_install

Install dependencies

forge_tree

Show dependency tree

forge_inspect

Inspect contract artifacts (ABI, bytecode, storage layout, etc.)

forge_selectors

List function selectors

forge_config

Show project configuration

forge_clone

Clone a verified contract from a block explorer

Cast (21 tools)

Tool

Description

cast_call

Call a contract function (read-only)

cast_send

Send a transaction

cast_estimate

Estimate gas for a transaction

cast_balance

Get ETH balance

cast_nonce

Get account nonce

cast_block

Get block information

cast_tx

Get transaction details

cast_receipt

Get transaction receipt

cast_gas_price

Get current gas price

cast_code

Get deployed bytecode

cast_storage

Read storage slots

cast_logs

Query event logs

cast_abi_encode

ABI-encode function arguments

cast_abi_decode

ABI-decode data

cast_calldata_decode

Decode calldata

cast_convert

Convert between formats (wei, hex, bytes32, base)

cast_keccak

Compute keccak256 hash

cast_sig

Get function selector

cast_interface

Generate Solidity interface from ABI

cast_rpc

Make raw JSON-RPC calls

cast_wallet

Generate, derive, and sign with wallets

Anvil (1 tool)

Tool

Description

anvil

Start a local devnet or check its status

Development

git clone https://github.com/jrigada/foundry-mcp.git
cd foundry-mcp
npm install
npm run build
npm test          # runs 162 tests

License

MIT

Available Tools

39 tools
anvilB

Start or check a local Anvil development node. Supports forking from a live network. Default port: 8545.

Inputs: action (required), port, balance, chainId, +5 more.

cast_abi_decodeB

Decode ABI-encoded hex data back into human-readable values (cast abi-decode).

Inputs: data (required), signature (required), input.

cast_abi_encodeC

ABI-encode values for a given Solidity function signature (cast abi-encode).

Inputs: signature (required), args.

cast_balanceC

Query the ETH balance of an address (cast balance).

Inputs: rpcUrl (required), address (required), ether, blockTag.

cast_blockB

Get block information (cast block). If no blockTag is given, returns the latest block number (cast block-number).

Inputs: rpcUrl (required), json, field, blockTag.

cast_callA

Read-only call to a deployed contract — no gas spent, no state change (cast call).

Inputs: to (required), rpcUrl (required), signature (required), args, +2 more.

cast_calldata_decodeB

Decode raw transaction calldata into function arguments (cast calldata-decode).

Inputs: calldata (required), signature (required).

cast_codeC

Get the deployed bytecode of a contract (cast code).

Inputs: rpcUrl (required), address (required), blockTag.

cast_convertB

Convert between Ethereum value formats (cast to-wei, from-wei, to-hex, to-dec, to-bytes32, to-base).

Inputs: value (required), operation (required), base, unit, +1 more.

cast_estimateC

Estimate gas for a transaction (cast estimate).

Inputs: to (required), rpcUrl (required), signature (required), args, +2 more.

cast_gas_priceC

Get the current gas price (cast gas-price).

Inputs: rpcUrl (required).

cast_interfaceC

Generate a Solidity interface from a contract address or ABI file (cast interface).

Inputs: addressOrPath (required), name, rpcUrl, etherscanApiKey.

cast_keccakC

Compute the Keccak-256 hash of data (cast keccak).

Inputs: data (required).

cast_logsC

Filter and retrieve event logs (cast logs).

Inputs: rpcUrl (required), json, topics, address, +3 more.

cast_nonceC

Query the transaction nonce of an address (cast nonce).

Inputs: rpcUrl (required), address (required), blockTag.

cast_receiptB

Get a transaction receipt by hash (cast receipt).

Inputs: rpcUrl (required), txHash (required), json, field, +1 more.

cast_rpcA

Send a raw JSON-RPC request (cast rpc). Escape hatch for any RPC method not covered by other tools.

Inputs: method (required), rpcUrl (required), params.

cast_sendC

Send a state-changing transaction to a deployed contract (cast send).

Inputs: to (required), rpcUrl (required), aws, gcp, +13 more.

cast_sigA

Get the 4-byte function selector from a function signature (cast sig).

Inputs: signature (required).

cast_storageC

Read a raw storage slot of a contract (cast storage).

Inputs: slot (required), rpcUrl (required), address (required), blockTag.

cast_txC

Get transaction details by hash (cast tx).

Inputs: rpcUrl (required), txHash (required), json, field.

cast_walletB

Wallet utilities: generate new wallets, derive addresses, or sign messages (cast wallet).

Inputs: action (required), count, message, privateKey.

forge_buildC

Compile a Foundry project (forge build). Returns compiler output including warnings and errors.

Inputs: projectPath (required), profile, extraArgs.

forge_cleanB

Remove build artifacts from a Foundry project (forge clean).

Inputs: projectPath (required).

forge_cloneB

Clone a verified contract from a block explorer into a local Foundry project (forge clone).

Inputs: address (required), chain, destination, etherscanApiKey.

forge_configB

Display the fully resolved Foundry configuration (forge config). Shows all settings from foundry.toml merged with defaults and environment overrides.

Inputs: projectPath (required), profile.

forge_coverageC

Generate a test coverage report (forge coverage).

Inputs: projectPath (required), filter, profile, reportType, +1 more.

forge_createB

Deploy a contract (forge create). Returns the deployed contract address, transaction hash, and deployer. Requires a signing method (private key, keystore, hardware wallet, etc.).

Inputs: rpcUrl (required), projectPath (required), contractPath (required), aws, +16 more.

forge_fmtA

Format Solidity source files (forge fmt). Use check=true to verify formatting without changes.

Inputs: projectPath (required), check.

forge_initC

Scaffold a new Foundry project (forge init).

Inputs: projectPath (required), noGit, commit, template.

forge_inspectA

Inspect a contract's compiled artifacts (forge inspect). Retrieve ABI, bytecode, storage layout, method identifiers, gas estimates, and more.

Inputs: field (required), projectPath (required), contractPath (required), profile.

forge_installA

Install dependencies for a Foundry project (forge install). If git submodule errors occur, try with noGit=true.

Inputs: projectPath (required), noGit, commit, dependencies.

forge_lintC

Lint Solidity source files (forge lint).

Inputs: projectPath (required), profile.

forge_scriptA

Run a Forge script (forge script). Use for deployments, migrations, and complex on-chain interactions. Pass broadcast=true to send transactions on-chain.

Inputs: scriptPath (required), projectPath (required), aws, gcp, +16 more.

forge_selectorsB

List all function selectors from compiled contracts (forge selectors list).

Inputs: projectPath (required), profile, contractName.

forge_snapshotA

Create or compare gas snapshots (forge snapshot). Use diff=true to compare against existing .gas-snapshot, check=true to fail on changes.

Inputs: projectPath (required), diff, check, filter, +2 more.

forge_testB

Run tests in a Foundry project (forge test). Supports filtering by test name, contract, and path. Can fork from a live network and generate gas reports.

Inputs: projectPath (required), filter, forkUrl, profile, +5 more.

forge_treeC

Display the dependency tree of a Foundry project (forge tree).

Inputs: projectPath (required), profile.

forge_verifyB

Verify a deployed contract on a block explorer (forge verify-contract). Supports Etherscan, Sourcify, and Blockscout.

Inputs: projectPath (required), contractPath (required), contractAddress (required), profile, +6 more.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    B3.2/5.0

    Scored across 39 tools

    Disambiguation4/5

    Most tools map cleanly to distinct Foundry/Cast/Anvil commands, with clear separation between read-only (cast_call) and write (cast_send) operations. Minor ambiguity exists between forge_script and forge_create for deployments, between cast_abi_decode and cast_calldata_decode, and around cast_rpc as a broad escape hatch.

    Naming Consistency5/5

    Names follow a very consistent snake_case verb_noun pattern with clear forge_ and cast_ prefixes grouping related commands. The lone anvil tool is named after its CLI command and remains predictable in context.

    Tool Count2/5

    With 39 tools, the surface is heavy for an agent to navigate and includes many thin one-command wrappers that could be consolidated. While each wrapper maps to a real command, the count exceeds the practical 15-25 range for coherent selection.

    Completeness4/5

    The set covers the core Forge, Cast, and Anvil workflows well: build, test, deploy, verify, inspect, cast reads/writes, ABI helpers, and Anvil startup. Some gaps remain, such as stopping an Anvil node, chain-id/proof-style cast utilities, and less common Forge maintenance commands.

    Maintenance

    ActivityInactive
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • F
      license
      Not graded
      quality
      B
      maintenance
      Enables agents to interact with Ethereum, Base and configurable EVM chains over stdio using the shared command catalog, covering contract reads, prepared and policy-guarded execution, wallet management, Socket swaps and bridging, simulation, monitoring and saved contracts.
      -
    • A
      license
      Not graded
      quality
      B
      maintenance
      Exposes code-review and issue-triage tools to AI assistants over stdio, letting them evaluate unified pull-request diffs for maintainer remarks, slice diffs into categorized AST hunks, and classify GitHub issues by priority while synthesizing minimal reproduction stubs.
      1
      Apache 2.0