mcp构建验证器
确定性MCP服务器,执行构建/测试命令,捕获日志,并报告第一个相关错误(如果有的话)。它不会修改代码或尝试修复。
特性
- MCP stdio服务器(TypeScript SDK)
run_build执行命令的工具analyze_logs保守日志解析工具- 中立、确定性、只读行为
需求
- Node.js 18+
设置
npm install
npm run build运行(stdio)
npm start与Codex一起使用
将服务器添加到Codex配置中(示例 ~/.codex/config.toml):
[mcp_servers.build_verifier]
command = "node"
args = ["/home/cicarulez/projects/mcp-build-verifier/dist/index.js"]
[mcp_servers.build_verifier.env]
MCP_TRANSPORT_TYPE = "stdio"然后重新启动Codex会话,以便加载工具。
推荐流量(代理)
MCP服务器仅公开两个工具:
run_buildanalyze_logs
推荐药剂流量:
- 如果(且仅当)任务修改了目标项目中的文件,请调用
run_build随着command和项目cwd. - 通过
stdout和stderr从结果到analyze_logs. - 仅使用返回的第一个错误
analyze_logs. - 如果没有修改文件,则跳过验证。
MCP构建验证流程(示例)
# MCP Build Verification Flow
Run this verification flow only after tasks that change files in this project.
Do not run it for Q&A or other non-editing tasks.
1. Call the `run_build` tool with:
- `command`: the build/test command (e.g., `npm run --workspace backend build` or `npm run --workspace frontend build`)
- `cwd`: `/home/user/projects/Example-App`
2. Read `stdout` and `stderr` from the response.
3. Call `analyze_logs` passing `stdout` and `stderr`.
4. Use ONLY the first error returned by `analyze_logs` to decide next steps.
Notes:
- Do not suggest fixes unless explicitly asked.
- Do not modify files during the verification phase.工具
run_build
输入:
{
"command": "npm test",
"cwd": "/path/to/project"
}输出:
{
"stdout": "...",
"stderr": "...",
"exitCode": 0
}analyze_logs
输入:
{
"stdout": "...",
"stderr": "..."
}输出:
{
"success": false,
"errors": [
{
"type": "typescript",
"code": "TS2307",
"file": "src/index.ts",
"line": 10,
"message": "Cannot find module ..."
}
]
}备注
- 解析是最好的努力,只返回第一个相关错误。
- 不执行修复、重试或文件修改。
