只是一个MCP命令运行器
一个模型上下文协议(MCP)服务器,它公开 就 食谱作为MCP工具,允许AI助手发现和执行Justfiles中定义的项目命令。
 ](https://www.npmjs.com/package/just-runner-mcp)
快速开始
使用npx安装并运行MCP服务器:
# Install just command runner if not already installed
# See https://github.com/casey/just#installation
# Run the MCP server pointing to a directory with a Justfile
npx just-runner-mcp --justfile ./path/to/your/justfile
# Or run from current directory (will search for Justfile)
npx just-runner-mcp
# Test via MCP inspector web UI
npx -y @modelcontextprotocol/inspector -- npx -y just-runner-mcp --justfile tests/support/basic.justfileMCP客户端配置
添加到您的MCP客户端配置中(例如,Claude Desktop):
{
"mcpServers": {
"just-runner": {
"command": "npx",
"args": ["just-runner-mcp", "--justfile", "/path/to/your/project"]
}
}
}为什么只是?
就 是一个命令运行器,用于在 justfile。这是向AI助手公开命令/脚本的有效选择,因为:
- 语法简单:Justfiles使用干净、易于阅读和编写的灵感语法
- 跨平台:适用于Linux、macOS、Windows和其他类Unix系统
- 语言不可知论:食谱可以用任何语言编写(bash、python等)
- 自我记录:食谱可以包括描述其作用的文档注释
- 参数化食谱可以接受论点,使其灵活且可重复使用
- 依赖管理:食谱可以依赖于其他食谱,确保正确的执行顺序
工具生成
MCP服务器自动解析Justfiles,并为每个配方生成MCP工具。每个工具都以配方命名,包括:
- 名字:justfile中的配方名称
- 描述:摘自文件评论(以…开头的行
#食谱上方) - 参数:自动检测配方参数及其默认值和类型
例如,这个justfile配方:
# Compile Latex Document. FILEPATH must be an absolute path
compile-latex FILEPATH:
tectonic {{FILEPATH}}
# Compile Typst Document. FILEPATH must be an absolute path
compile-typst FILEPATH:
typst compile --format pdf {{FILEPATH}}
typst compile --format png {{FILEPATH}} "page-{0p}-of-{t}.png"将向MCP客户端公开以下工具:
{
"tools": [
{
"name": "compile-latex",
"description": "Run just recipe: compile-latex\nCompile Latex Document. FILEPATH must be an absolute path",
"inputSchema": {
"type": "object",
"properties": {
"FILEPATH": {
"type": "string",
"description": "Required"
}
},
"required": ["FILEPATH"]
}
},
{
"name": "compile-typst",
"description": "Run just recipe: compile-typst\nCompile Typst Document. FILEPATH must be an absolute path",
"inputSchema": {
"type": "object",
"properties": {
"FILEPATH": {
"type": "string",
"description": "Required"
}
},
"required": ["FILEPATH"]
}
}
]
}CLI选项
MCP服务器支持多种命令行选项:
Usage: just-mcp [options]
Expose Justfile recipes as MCP tools
Options:
--justfile
Path to Justfile (default: "Justfile")
--just-binary
Path to just binary (default: "just")
--timeout Timeout for recipe execution in milliseconds (default: 30000)
--list-tools Print available tools and exit
--help Show help message
-h display help for command例子
本节演示了一个开发项目的实用Justfile及其生成的MCP工具。每个食谱都成为AI助手可以发现和执行的工具。
简单开发Justfile
以下是一个典型开发工作流程的justfile:
# Install project dependencies
install:
npm install
# Start the development server
dev port="3000":
echo "Starting dev server on port {{port}}"
npm run dev -- --port {{port}}
# Run all tests
test:
npm test
# Deploy to staging environment
deploy-staging: build test
echo "Deploying to staging..."
./scripts/deploy.sh stagingMCP工具输出
当你奔跑时 just-runner-mcp --list-tools,您将得到以下JSON响应,显示所有可用工具:
{
"tools": [
{
"name": "install",
"description": "Run just recipe: install\nInstall project dependencies",
"inputSchema": {
"type": "object",
"properties": {},
"required": []
}
},
{
"name": "dev",
"description": "Run just recipe: dev\nStart the development server",
"inputSchema": {
"type": "object",
"properties": {
"port": {
"type": "string",
"description": "Parameter: port (default: 3000)"
}
},
"required": []
}
},
{
"name": "test",
"description": "Run just recipe: test\n",
"inputSchema": {
"type": "object",
"properties": {},
"required": []
}
},
{
"name": "deploy-staging",
"description": "Run just recipe: deploy-staging\nDeploy to staging environment",
"inputSchema": {
"type": "object",
"properties": {},
"required": []
}
}
]
}有了这些工具,人工智能助手可以帮助您完成常见的开发任务,如“安装依赖项”、“在端口8080上启动开发服务器”、“运行测试”或“部署到测试阶段”。
替代方案
还有其他方法可以将Just与MCP集成:
- 只是mcp -一个基于Rust的MCP服务器,提供更全面的Justfile支持和处理。这个货物包提供了额外的功能,而不仅仅是将食谱作为工具暴露给LLM。
此存储库(just-runner-mcp)采取了一种最小化的方法,专门专注于将Just recipes作为MCP工具公开,供AI助手发现和执行。
发展
# Run all tests
just test
# Run specific test file
just test tests/integration.test.ts许可证
此项目根据MIT许可证获得许可-请参阅 许可证 文件以获取详细信息。
