npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@amyseer/sol-compiler-mcp

v1.2.0

Published

Solidity智能合约编译MCP服务,支持导入解析和OpenZeppelin,带自动版本检测

Readme

Solidity编译器MCP服务

一个基于Model Context Protocol (MCP)的Solidity智能合约编译服务,专为web3tgbot项目优化,支持完整的导入解析功能。

核心特性

  • ✅ 智能导入解析 - 自动处理OpenZeppelin等第三方库导入
  • ✅ 简单API - 仅需传递Solidity源码即可完成编译
  • ✅ 多种路径支持 - 处理相对路径、绝对路径和包路径导入
  • ✅ 完整编译信息 - 提供ABI、字节码、部署字节码和燃气估算
  • ✅ 适配MCP协议 - 与任何MCP客户端无缝协作
  • ✅ 版本检测 - 自动检测代码中的Solidity版本并提供相应错误提示

版本历史

v1.2.0

  • 新增Solidity版本检测功能
  • 增强错误处理,更友好的错误提示
  • 提高OpenZeppelin库兼容性

v1.1.0

  • 修复ES模块兼容性问题
  • 改善导入路径解析

v1.0.0

  • 首次发布

安装

# 全局安装(推荐用于CLI使用)
npm install -g @amyseer/sol-compiler-mcp

# 作为项目依赖安装
npm install @amyseer/sol-compiler-mcp

快速开始

启动服务

服务可以作为独立进程运行,或被其他MCP客户端调用:

# 使用CLI启动
npx @amyseer/sol-compiler-mcp serve

# 或者全局安装后启动
sol-compiler-mcp serve

在web3tgbot中使用

本服务专为web3tgbot项目优化。确保在web3tgbot的MCP配置中包含solidity-compiler:

{
  "mcpServers": {
    "solidity-compiler": {
      "command": "npx",
      "args": ["@amyseer/[email protected]", "serve"]
    }
  }
}

版本兼容性

本服务当前使用的依赖版本:

  • Solidity 编译器: v0.8.20
  • OpenZeppelin 库: v5.0.1 (支持Solidity ^0.8.20)

如果您正在编译使用较旧版本的合约(如Solidity 0.7.x),请注意它们可能与当前的OpenZeppelin库不兼容。您应该使用相应版本的OpenZeppelin库,例如:

  • Solidity 0.7.x → OpenZeppelin 4.x
  • Solidity 0.8.x → OpenZeppelin 5.x

API说明

本服务实现了以下MCP功能:

工具

  • compile-contract
    • 参数:
      • contractSource(必填):Solidity合约源代码或文件路径
      • contractName(可选):指定要编译的合约名称,未提供时会自动从源码提取
    • 返回:
      • 编译成功状态
      • 合约名称
      • 合约字节码
      • 部署后的字节码
      • 合约ABI
      • 燃气估算

资源

  • solidity-info://compiler-version - 显示当前使用的Solidity编译器版本
  • solidity-info://example-contract - 提供示例ERC20合约
  • solidity-info://info - 显示服务信息和可用资源
  • solidity-info://node-modules - 显示已配置的node_modules路径

导入路径支持

本服务支持以下类型的导入路径:

  1. 相对路径导入:import "./Contract.sol" 或 import "../Contract.sol"
  2. 绝对路径导入:import "/path/to/Contract.sol"
  3. 包导入:import "@openzeppelin/contracts/token/ERC20/ERC20.sol"
  4. 本地导入:import "Contract.sol"(在当前目录或contracts目录中查找)

与web3tgbot集成

在web3tgbot项目中,本服务用于编译由用户通过Telegram机器人创建的ERC20代币。集成使用以下流程:

  1. web3tgbot通过src/erc20/compile.ts中的SolidityCompiler类调用本服务
  2. 用户的合约代码通过contractSource参数传递
  3. 本服务处理代码中的所有导入语句,特别是OpenZeppelin合约
  4. 编译结果(字节码、ABI等)返回给web3tgbot,用于后续部署

依赖项

  • Node.js 18.0.0+
  • solc 0.8.20+
  • @openzeppelin/contracts 5.0.1+
  • @modelcontextprotocol/sdk 1.10.2+

调试

如果遇到编译问题,可以检查stderr输出中的日志,它包含详细的编译和导入解析信息。

服务会自动记录以下内容:

  • 导入解析过程和路径尝试
  • 编译警告和错误
  • 依赖检查结果
  • Solidity版本检测信息

开发说明

# 克隆仓库
git clone https://github.com/amyseer/sol-compiler-mcp.git
cd sol-compiler-mcp

# 安装依赖
npm install

# 构建项目
npm run build

# 启动服务
npm run serve

许可证

MIT