展示HN:通过一个YAML文件为编码代理提供MCP访问权限,以进行代码检查/测试/格式化。
这是我为自己构建的一个有趣的小项目。创建一个 YAML 文件来定义你的开发命令(如 lint、格式化、测试等),然后通过 MCP 将这些命令暴露给编码代理。
有点像 package.json 中的脚本,但针对代理运行时,并且命令通过 MCP 调用。
1. 简单设置:只需一个 YAML 文件即可为你的编码代理创建一个自定义的 MCP 服务器。将 YAML 文件添加到你的代码库中,以便与团队共享。
2. 工具发现:编码代理知道可用的开发工具以及它们所需的确切参数。无需再猜测命令行字符串。
3. 提高安全性:限制代理可以运行的命令。验证代理生成的参数(例如,确保文件路径在项目内部,而不是 `~/.ssh/id_rsa`)。
4. 在任何支持 MCP 的地方都能工作:Cursor、Windsurf、Cline 等等。
5. 提高速度:使用 MCP 可以解锁并行执行,生成命令所需的令牌更少,并消除需要迭代的命令中的错误。
6. 还有更多:去除 ANSI 代码/控制字符,加载 .env 文件,定义所需的秘密而无需将其检查入库,支持退出代码/stdout/stderr 等等。
<a href="https://github.com/scosman/hooks_mcp" rel="nofollow">https://github.com/scosman/hooks_mcp</a>
查看原文
Fun little project I built for myself. Create a YAML file for your dev-commands (lint, format, tests, etc), then expose those to coding agents via MCP.<p>Kinda like package.json scripts, but for agent runtimes, and commands are invoked via MCP.<p>1. Simple setup: one YAML file is all it takes to create a custom MCP server for your coding agents. Add the YAML to your repo to share with your team.<p>2. Tool discovery: coding agents know which dev-tools are available and the exact arguments they require. No more guessing CLI strings.<p>3. Improved security: limit which commands agents can run. Validate the arguments agents generate (e.g. ensure a file path is inside the project, not `~/.ssh/id_rsa`).<p>3. Works anywhere MCP works: Cursor, Windsurf, Cline, etc<p>4. Speed: using MCP unlocks parallel execution, requires fewer tokens for generating commands, and eliminates errors in commands requiring iteration.<p>5. And more: strip ANSI codes/control characters, .env file loading, define required secrets without checking them in, supports exit codes/stdout/stderr, etc<p><a href="https://github.com/scosman/hooks_mcp" rel="nofollow">https://github.com/scosman/hooks_mcp</a>