PF

praneshasp/foundry-mcp-server

开发工具

本页由 AI 翻译,技术细节请以原文为准。 查看原文

255 stars 37 forks 质量 75 趋势 18MIT

praneshasp/foundry-mcp-server 是从 https://github.com/praneshasp/foundry-mcp-server. 导入的 MCP 服务器候选

概览

praneshasp/foundry-mcp-server 是从 https://github.com/praneshasp/foundry-mcp-server. 导入的 MCP 服务器候选

概述(AI 翻译)

一个简单、轻便且快速的MCP(模型上下文协议)服务器,提供利用Foundry工具链(Forge、Cast和Anvil)开发Solidity的能力。

概述

该服务器将LLM助手连接到Foundry生态系统,使他们能够:

  • 与节点(本地 Anvil 实例或远程 RPC 端点)交互
  • 分析智能合约和区块链数据
  • 使用Cast执行常见的EVM操作
  • 管理、部署并执行Solidity代码和脚本
  • 使用持久化的 Forge 工作区

特色

网络互动

  • 启动和管理本地 Anvil 实例
  • 连接到任意远程网络(只需指定RPC)
  • 获取网络/链条信息

合同互动

  • 调用合同函数(只读)
  • 将交易发送到合约(如果配置为PRIVATE_KEY)
  • 获取交易收据
  • 读取合同存储
  • 分析交易轨迹
  • 从块探查器检索合同的ABI和源

固体发展

  • 维护专用的锻造工作区
  • 创建和编辑Solidity文件
  • 安装依赖
  • 运行 Forge 脚本
  • 部署合同

效用函数

  • 计算合同地址

本页由 AI 翻译,技术细节请以原文为准。

README

以下为原文 README 节选,完整内容请查看原文。

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

Smart Contract Analysis (Heimdall)

  • Disassemble EVM bytecode into human-readable opcodes
  • Decode raw calldata without requiring ABI
  • Decompile EVM bytecode to Solidity source code and ABI
  • Generate visual control flow graphs for EVM bytecode
  • Detailed transaction inspection with calldata decoding and trace analysis

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

Manual Setup

  1. Ensure Foundry tools (Forge, Cast, Anvil) are installed on your system:

    curl -L https://foundry.paradigm.xyz | bash
    foundryup
    
  2. Clone and build the server.

    bun i && bun build ./src/index.ts --outdir ./dist --target node
    
    
  3. Update your client config (eg: Claude desktop):

 "mcpServers": {
    "foundry": {
      "command": "node",
      "args": [
        "path/to/foundry-mcp-server/dist/index.js"
      ],
      "env" :{
        "PRIVATE_KEY": "0x1234",
      }
    }
 }

[!NOTE] PRIVATE_KEY is optional

Setup using NPM Package

You can now install and run the server directly using npm:

Global Installation

npm install -g @pranesh.asp/foundry-mcp-server

Direct Usage with npx

在 GitHub 查看完整 README

安装

npx @pranesh.asp/foundry-mcp-server
新手?先看 mcpskill.org 教程 →