构建系统统一接口服务

makefilehub是一个通用的MCP服务器,为Claude Code提供跨不同构建系统的统一任务运行接口。

  • by Fuabioo
  • Rust
  • 本地部署
  • 更新于
在 GitHub 查看 Fuabioo/makefilehub

使用说明

makefilehub

用于跨不同构建系统运行任务的通用MCP(模型上下文协议)服务器。

makefilehub 为Claude Code提供了一个统一的交互界面:

  • Makefile -GNU制造
  • justfile -just命令运行器
  • 自定义脚本 -run.sh、build.sh等。

特性

  • 自动检测 按可配置优先级构建系统
  • 符合XDG标准 分层配置
  • 环境变量插值 ($VAR, ${VAR})
  • Shell命令插值 ($(command))
  • 服务依赖性管理 用于复杂的重建编排
  • MCP工具 用于无缝集成Claude代码

安装

来源

cargo install --path .

使用货物

cargo install makefilehub

MCP集成

将makefilehub添加到Claude代码中:

claude mcp add --transport stdio --scope user makefilehub makefilehub mcp

CLI使用情况

# Start MCP server (for Claude Code)
makefilehub mcp

# Run a task in the current directory
makefilehub run build
makefilehub run test

# Run a task in a specific project
makefilehub run build -p /path/to/project
makefilehub run build -p my-service  # uses configured service

# Force a specific runner
makefilehub run build -r just
makefilehub run build -r make
makefilehub run build -r ./run.sh

# Pass arguments
makefilehub run build -a TARGET=release -a DEBUG=0
makefilehub run test -- --verbose --filter pattern

# List available tasks
makefilehub list
makefilehub list -f json

# Detect build system
makefilehub detect
makefilehub detect -p /path/to/project

# Show project configuration
makefilehub config my-service

# Rebuild service with dependencies
makefilehub rebuild web-api
makefilehub rebuild web-api -s frontend --skip-deps

MCP工具

run_task

在项目中运行任务/目标。自动检测构建系统。

{
  "task": "build",
  "project": "/path/to/project",
  "runner": "make",
  "args": {"TARGET": "release"},
  "positional_args": ["--verbose"]
}

list_tasks

列出项目中可用的任务/目标。

{
  "project": "/path/to/project",
  "runner": "just"
}

检测轮

检测项目使用的构建系统。

{
  "project": "/path/to/project"
}

get_project_config

获取项目/服务的解析配置。

{
  "project": "my-service"
}

重建服务

使用依赖关系处理构建服务。

{
  "service": "web-api",
  "services": ["frontend"],
  "skip_deps": false,
  "skip_recreate": false
}

配置

配置文件按顺序加载(从低到高优先级):

  1. /etc/makefilehub/config.toml
  2. ~/.config/makefilehub/config.toml
  3. ~/.makefilehub.toml
  4. ./.makefilehub.toml (项目根)

示例配置

[defaults]
runner_priority = ["make", "just", "script"]
default_script = "./run.sh"
timeout = 300

[defaults.task_aliases]
build = ["build", "compile"]
test = ["test", "check"]

[runners.make]
command = "make"

[runners.just]
command = "just"

[runners.script]
scripts = ["./run.sh", "./build.sh"]

[services.web-api]
project_dir = "$HOME/projects/web-api"
runner = "script"
depends_on = ["frontend"]
force_recreate = ["nginx"]

[services.web-api.tasks]
build = "build"
up = "up"

插值

  • $VAR 或 ${VAR} -环境变量

安全说明:Shell命令插值($(command))出于安全考虑,已将其删除。 来自不受信任的源(例如克隆的存储库)的配置文件可以执行任意代码。

例子:

[services.dynamic]
project_dir = "${PROJECTS_DIR}/my-project"

[services.home-based]
project_dir = "$HOME/projects/my-app"

构建系统优先级

当没有配置显式运行器时,makefilehub会按以下顺序自动检测:

  1. Makefile - Makefile, makefile, GNUmakefile
  2. justfile - justfile, Justfile, .justfile
  3. 脚本 - ./run.sh, ./build.sh等等。(可配置)

发展

# Install development tools
just setup

# Run tests
just test

# Run linter
just lint

# Run all checks
just check

# Build release
just release

许可证

麻省理工学院