Pact-Community-Organization/pact-mcp

GitHub: Pact-Community-Organization/pact-mcp

为 AI 代理提供安全、可审计的 Pact 5 智能合约开发与 Kadena Chainweb 链上交互能力的 MCP 服务器。

Stars: 0 | Forks: 1

# pact-mcp — Pact & Chainweb 的 MCP 服务器 [![CI](https://static.pigsec.cn/wp-content/uploads/repos/cas/ad/ad5834178f7599af9fdda11629d49cae07f2997beec49821b2920eff5bfd50e7.svg)](https://github.com/Pact-Community-Organization/pact-mcp/actions/workflows/ci.yml) [![npm](https://img.shields.io/npm/v/@pact-community/mcp-pact.svg?label=mcp-pact)](https://www.npmjs.com/package/@pact-community/mcp-pact) [![License: Apache-2.0](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](LICENSE) [![Node >= 20.11](https://img.shields.io/badge/node-%3E%3D20.11-brightgreen.svg)](package.json) **Model Context Protocol 服务器,为您的 AI 代理提供安全、可审计的访问权限, 以支持 Kadena Chainweb 上的 Pact 5 开发循环。** 运行 REPL 测试、扫描模块以发现关键的语言陷阱、估算 gas,以及 查询或提交至 Chainweb 节点 — 所有这些都可以通过 Claude、Cursor、VS Code 或任何 兼容 MCP 的客户端完成。每个工具都在严格且经过测试的 安全基线背后运行,且没有任何工具会触及私钥。 ``` { "mcpServers": { "pact": { "command": "npx", "args": ["-y", "@pact-community/mcp-pact"], "env": { "PACT_COMMUNITY_WORKSPACE_ROOT": "/path/to/your/project" } } } } ``` ## 服务器 | 服务器 | 安装 | 工具 | 功能描述 | |--------|---------|-------|--------------| | **Pact Tooling** — [`@pact-community/mcp-pact`](packages/mcp-pact/) | [![npm](https://img.shields.io/npm/v/@pact-community/mcp-pact.svg)](https://www.npmjs.com/package/@pact-community/mcp-pact) | 6 | 运行 REPL 测试、关键陷阱扫描、gas 估算、接口差异对比、格式检查 | | **Chainweb API** — [`@pact-community/mcp-chainweb`](packages/mcp-chainweb/) | [![npm](https://img.shields.io/npm/v/@pact-community/mcp-chainweb.svg)](https://www.npmjs.com/package/@pact-community/mcp-chainweb) | 11 | `/local` 模拟、预签名的 `/send`、poll、表读取、SPV 证明、模块部署 | 两者均已收录在官方 [MCP registry](https://registry.modelcontextprotocol.io) 中,名称分别为 `io.github.Pact-Community-Organization/pact` 和 `io.github.Pact-Community-Organization/chainweb`。 ## 安装 ### VS Code (一键安装) 在 VS Code 中使用 GitHub Copilot?只需一键即可安装: [![Install Pact Tooling in VS Code](https://img.shields.io/badge/VS_Code-Install_Pact_Tooling-0098FF?logo=visualstudiocode&logoColor=white)](vscode:mcp/install?%7B%22name%22%3A%22pact%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40pact-community/mcp-pact%22%5D%2C%22env%22%3A%7B%22PACT_COMMUNITY_WORKSPACE_ROOT%22%3A%22%24%7BworkspaceFolder%7D%22%2C%22PACT_COMMUNITY_PACT_BIN%22%3A%22pact%22%7D%7D) [![Install Chainweb API in VS Code](https://img.shields.io/badge/VS_Code-Install_Chainweb_API-0098FF?logo=visualstudiocode&logoColor=white)](vscode:mcp/install?%7B%22name%22%3A%22chainweb%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40pact-community/mcp-chainweb%22%5D%2C%22env%22%3A%7B%22PACT_COMMUNITY_WORKSPACE_ROOT%22%3A%22%24%7BworkspaceFolder%7D%22%2C%22PACT_COMMUNITY_CHAINWEB_MODE%22%3A%22devnet%22%2C%22PACT_COMMUNITY_CHAINWEB_PROFILE%22%3A%22devnet%22%2C%22PACT_COMMUNITY_CHAINWEB_BASE_URL%22%3A%22http%3A//localhost%3A8081%22%2C%22PACT_COMMUNITY_CHAINWEB_NETWORK_ID%22%3A%22development%22%7D%7D) 该按钮会打开 VS Code 并预填配置。您也可以在 **MCP Servers** 视图中搜索,或通过命令行添加: ``` code --add-mcp '{"name":"pact","command":"npx","args":["-y","@pact-community/mcp-pact"],"env":{"PACT_COMMUNITY_WORKSPACE_ROOT":"${workspaceFolder}","PACT_COMMUNITY_PACT_BIN":"pact"}}' ``` ### Claude Code ``` claude mcp add pact -e PACT_COMMUNITY_WORKSPACE_ROOT=/path/to/your/project \ -- npx -y @pact-community/mcp-pact ``` ### 任意 MCP 客户端 将这两个服务器添加到您的客户端配置中: ``` { "mcpServers": { "pact": { "command": "npx", "args": ["-y", "@pact-community/mcp-pact"], "env": { "PACT_COMMUNITY_WORKSPACE_ROOT": "/path/to/your/project", "PACT_COMMUNITY_PACT_BIN": "pact" } }, "chainweb": { "command": "npx", "args": ["-y", "@pact-community/mcp-chainweb"], "env": { "PACT_COMMUNITY_WORKSPACE_ROOT": "/path/to/your/project", "PACT_COMMUNITY_CHAINWEB_MODE": "devnet", "PACT_COMMUNITY_CHAINWEB_PROFILE": "devnet", "PACT_COMMUNITY_CHAINWEB_BASE_URL": "http://localhost:8081", "PACT_COMMUNITY_CHAINWEB_NETWORK_ID": "development" } } } } ``` 每个服务器的 README 文档都详细记录了其完整的工具列表和环境变量: [Pact Tooling](packages/mcp-pact/README.md) · [Chainweb API](packages/mcp-chainweb/README.md)。 ## 开始的 10 分钟 1. **安装 Pact CLI** — Pact Tooling 使用它来进行 REPL 运行和 gas 估算。从 [kadena-io/pact-5](https://github.com/kadena-io/pact-5/releases) 下载发布版本,将 `pact` 添加到您的 `PATH` 中,并使用 `pact --version` 进行验证。 2. **添加服务器** 到您的客户端,使用上述配置,并将 `PACT_COMMUNITY_WORKSPACE_ROOT` 指向您的合约项目。 3. **询问您的代理:** - *“扫描 `contracts/token.pact` 以发现关键的 Pact 5 陷阱”* — 标记非二进制的 `+`、`enforce` 内部的 DB 读取、内置覆盖等问题。 - *“运行 `tests/token.repl` 并总结失败原因”* — 使用真实的 Pact 解释器执行文件 并解析结果。 - *“对比 `token.pact` 与 `token-v2.pact` 的公共接口差异”* — 报告添加/删除/更改的函数,以及该更改是否具有破坏性。 - *“链 0 上的当前区块高度是多少?”* — 查询 Chainweb 节点。 Pact Tooling 中的所有功能仅需 CLI 即可运行 — 无需节点。Chainweb API 适用于任何兼容 Chainweb 的节点:将 `PACT_COMMUNITY_CHAINWEB_BASE_URL` 指向您的 devnet,或使用只读的 `testnet06` / `mainnet` 配置文件查询公共网络。 ## 安全性 两个服务器都执行相同的经过测试的基线(详见 [SECURITY.md](SECURITY.md)): - **绝不使用私钥。** `chainweb_send`、`chainweb_deploy_module` 和 `chainweb_continue_pact` 要求交易必须在外部签名(Ledger、 `@kadena/client` 等),并以预签名形式传入。 - **只读公共网络。** `testnet06` 和 `mainnet` 配置文件会使用 `PROFILE_WRITE_BLOCKED` 阻止所有写入工具。 - **审计日志** 记录每次工具调用及其 SHA-256 输入哈希(绝不包含原始 输入)。 - **提示词注入去除** 在所有工具输出到达模型之前对其进行处理。 - **工具模式锁定** — 如果其工具模式发生偏移,服务器将拒绝启动。 - **网络和文件系统白名单**,无 shell 执行,且拒绝以 root 身份运行。 ## 兼容性 | 服务器 | 本地 devnet | Testnet | Mainnet | |--------|:---:|:---:|:---:| | Pact Tooling | ✅ | — | — | | Chainweb API | ✅ | ✅ 只读 | ✅ 只读 | ## 贡献 ``` git clone https://github.com/Pact-Community-Organization/pact-mcp.git cd pact-mcp pnpm install pnpm build pnpm test ``` 需要 Node.js >= 20.11 和 pnpm >= 9。有关工作流、代码规范以及如何添加或更改工具,请参阅 [CONTRIBUTING.md](CONTRIBUTING.md)。 ## 许可证 [Apache-2.0](LICENSE)
标签:AI代理, Kadena, MCP, MITM代理, Pact, SOC Prime, 区块链, 开发工具, 智能合约, 暗色界面, 自动化攻击