Sourcify MCP服务器
用于Sourcify智能合约验证的模型上下文协议(MCP)服务器。该服务器通过MCP工具公开Sourcify的API v2功能,允许AI助手验证智能合约、查找已验证的合约并搜索类似的合约。
特性
- 合同查询:列出并检索带有详细信息的已验证合同
- 合同验证:使用标准和CREATE2部署验证智能合约
- 工作状态:轮询验证作业状态
- 相似性搜索:查找具有相似字节码的合约
- 字段选择:请求特定的合同字段以尽量减少带宽
- 代理检测:自动检测8种代理类型
- 错误处理:通过用户友好的消息进行全面的错误处理
- 类型安全:完全支持TypeScript和运行时验证
可用工具
1. sourcify_list_contracts
列出具有分页支持的特定区块链的已验证合同。
参数:
chainId(必填):区块链IDlimit(可选):合同数量(最多200,默认50)sort(可选):排序顺序为“asc”或“desc”afterMatchId(可选):匹配ID进行分页
2. sourcify_get_contract
获取特定已验证合同的详细信息。
参数:
chainId(必填):区块链IDaddress(必填):合同地址fields(可选):要包含的字段数组omit(可选):要排除的字段数组
可用字段:
creationBytecode,runtimeBytecode,deployment,sources,compilationabi,userdoc,devdoc,storageLayout,metadatastdJsonInput,stdJsonOutput,proxyResolution,all
3. sourcify_verify_contract
提交智能合约进行验证(基于会话)。
参数:
address(必填):合同地址chain(必填):链ID或名称files(必需):将文件名映射到内容的对象compilerVersion(可选):Solidity编译器版本creatorTxHash(可选):创建交易哈希chosenContract(可选):如果有多个,则具体合同
4. sourcify_verify_create2
验证CREATE2部署的合约。
参数:
deployerAddress(必填):部署者地址salt(必填):CREATE2盐create2Address(必填):生成的CREATE2地址files(必填):源文件abiEncodedConstructorArguments(可选):构造函数参数compilerVersion(可选):编译器版本chosenContract(可选):具体合同
5. sourcify_check_job_status
检查验证作业的状态。
参数:
jobId(必填):验证作业ID
6. sourcify_find_similar_contracts
查找具有相似字节码的合约。
参数:
bytecode(必填):要搜索的运行时字节码chainId(可选):用于缩小搜索范围的链ID
安装
npm install发展
# Run in development mode with hot reload
npm run dev
# Build the project
npm run build
# Run the built server
npm start
# Run tests
npm test
# mcp test with UI, this will open a web interface where you can test all tools interactively.
npx @modelcontextprotocol/inspector node dist/index.js配置
创建一个 .env 文件基于 .env.example:
PORT=3000
HOST=localhost
SOURCIFY_BASE_URL=https://sourcify.dev/server
API_TIMEOUT=30000与MCP客户端一起使用
添加到MCP客户端配置中:
{
"mcpServers": {
"sourcify": {
"command": "node",
"args": ["/path/to/sourcify-mcp/dist/index.js"]
}
}
}API 文档
许可证
麻省理工学院
