👋 让LLMs通过Just说话的方式
这是一个生产就绪的MCP服务器,提供了与Just命令运行器的无缝集成,使AI助手能够通过标准化的MCP协议发现、执行和检查Justfile食谱。
如果不是很明显的话,让LLMs使用Just而不是bash的好处在于,通过MCP运行Just命令提供了一个上下文保存的抽象层,它们不需要浪费上下文去打开或读取bash文件、Python脚本或其他构建工件。LLM通过MCP只需获取命令、参数和提示——这些在它们的记忆中是“可用的命令”。
不再需要观看LLMs执行just -l来获取命令列表,不可避免地开始阅读justfile,然后尝试编写justfile语法(就像Makefile一样),破坏justfile并创建糟糕的体验。Just不断演进的语法在前沿模型中目前没有足够的语料库——我们需要更多包含justfile的流行仓库进入训练数据集。
Just-mcp从根本上比bash更安全。如果你经常浏览HackerNews,每天至少会看到一个关于操作员的LLMs开始忘记、产生幻觉并最终崩溃的故事——删除文件并做一些不想要的事情。给LLMs无监督且不受限制的bash访问而不仔细监控上下文消耗是一个灾难配方。
**使用Justfile解决了这个问题。**即使LLM修改了自己的justfile,下一个上下文也会被justfile记忆化(希望在一个幂等的git仓库中)。这种抽象保护了LLM免受命令行复杂性的困扰,其中幻觉或当前工作目录的注意力跟踪会导致它失控并坠落悬崖。
Just-mcp非常适合任何进行代理执行的人:
Just有一些有用的模式来引入:
b00t mcp create just-mcp -- bash just-mcp --stdio "${REPO_ROOT}"
b00t mcp export just-mcp
list_recipes - 列出justfile中的所有可用食谱run_recipe - 执行特定食谱,可选参数get_recipe_info - 获取特定食谱的详细信息validate_justfile - 验证justfile的语法和语义错误选择你喜欢的安装方法:
# 全局安装
npm install -g just-mcp
# 或使用npx(无需安装)
npx just-mcp --stdio
# 使用pip安装
pip install just-mcp
# 或使用uvx(推荐)
uvx just-mcp --stdio
# 从crates.io安装
cargo install just-mcp
# 或从源代码构建
git clone https://github.com/promptexecution/just-mcp
cd just-mcp
cargo build --release
# 从GitHub容器注册表拉取最新镜像
docker pull ghcr.io/promptexecution/just-mcp:latest
# 使用Docker运行
docker run --rm -v $(pwd):/workspace ghcr.io/promptexecution/just-mcp:latest --stdio
# 本地构建
docker build -t just-mcp:local .
docker run --rm -v $(pwd):/workspace just-mcp:local --stdio
可用的Docker镜像标签:
latest - 最新的稳定版本X.Y.Z - 特定版本(例如,0.1.0)X.Y - 最新的补丁版本(例如,0.1)X - 最新的次要版本(例如,0)添加到你的Claude Desktop MCP配置中:
{
"mcpServers": {
"just-mcp": {
"command": "npx",
"args": ["-y", "just-mcp", "--stdio"]
}
}
}
{
"mcpServers": {
"just-mcp": {
"command": "uvx",
"args": ["just-mcp", "--stdio"]
}
}
}
{
"mcpServers": {
"just-mcp": {
"command": "/path/to/just-mcp",
"args": ["--stdio"]
}
}
}
{
"mcpServers": {
"just-mcp": {
"command": "docker",
"args": [
"run",
"--rm",
"-i",
"-v",
"${workspaceFolder}:/workspace",
"ghcr.io/promptexecution/just-mcp:latest",
"--stdio"
]
}
}
}
# 作为MCP服务器运行
just-mcp --stdio
# 在特定目录下运行
just-mcp --directory /path/to/project --stdio
# 使用Docker
docker run --rm -v $(pwd):/workspace ghcr.io/promptexecution/just-mcp:latest --stdio
# 运行所有测试(33个测试)
cargo test
# 运行特定测试套件
cargo test --test basic_mcp_test # 协议合规性测试
cargo test --test mcp_integration_working # SDK集成测试
basic_mcp_test.rs - 使用原始JSON-RPC直接进行协议合规性测试mcp_integration_working.rs - 使用rmcp客户端进行类型安全SDK集成测试just-mcp/
├── src/main.rs # CLI二进制文件
├── just-mcp-lib/ # 核心库
│ ├── parser.rs # Justfile解析
│ ├── executor.rs # 食谱执行
│ ├── validator.rs # 验证逻辑
│ ├── environment.rs # 环境管理
│ └── mcp_server.rs # MCP协议实现
├── tests/ # 集成测试
└── justfile # 示例食谱
// 列出可用食谱
await client.callTool("list_recipes", {});
// 带参数执行食谱
await client.callTool("run_recipe", {
"recipe_name": "build",
"args": "[\"--release\"]"
});
// 获取食谱信息
await client.callTool("get_recipe_info", {
"recipe_name": "test"
});
// 验证justfile
await client.callTool("validate_justfile", {
"justfile_path": "./custom.justfile"
});
此项目遵循_b00t_开发方法论:
just build # 构建项目
just test # 运行测试
just server # 启动MCP服务器
just clean # 清理构建工件
此项目根据LICENSE许可。
cog.toml,包括适当的提交类型和变更日志设置commit-msg)和预推送测试ci.yml):多平台测试(Ubuntu、Windows、macOS)、格式化、clippy、提交检查release.yml):自动化版本控制、生成变更日志、GitHub发布和crates.io发布build-binaries.yml):跨平台二进制编译,用于npm和pip包container.yaml):多平台Docker镜像构建(linux/amd64、linux/arm64)推送到GitHub容器注册表linux/amd64和linux/arm64构建多平台镜像Cargo.toml文件,包含完整元数据(描述、关键词、类别、许可证等)CHANGELOG.md,用于发布追踪.gitignore,包含Rust特定条目feat:、fix:、docs:等前缀进行自动版本控制main分支触发自动化发布和crates.io发布just-mcp-lib),然后发布二进制crate(just-mcp)# npm(JavaScript/TypeScript生态系统)
npm install -g just-mcp
# 或
npx just-m
cp --stdio
# pip(Python生态系统)
pip install just-mcp
# 或
uvx just-mcp --stdio
# cargo(Rust生态系统)
cargo install just-mcp
# 下载预构建的二进制文件
wget https://github.com/promptexecution/just-mcp/releases/latest/download/just-mcp-x86_64-unknown-linux-gnu.tar.gz
# 或使用Docker
docker pull ghcr.io/promptexecution/just-mcp:latest
# 或从GitHub发布下载
wget https://github.com/promptexecution/just-mcp/releases/latest/download/just-mcp