@zhubby/bxmcp
v0.1.0
Published
MCP server for build operations
Downloads
13
Readme
bxmcp
MCP server for build operations.
安装
npm install -g @org/bxmcp使用
bxmcp --kubeconfig /path/to/kubeconfig --namespace default说明
该包包含预编译二进制(darwin/linux/windows,amd64/arm64)。
bxmcp - BuildKit MCP Server
基于 Kubernetes 的容器镜像构建系统,通过 MCP (Model Context Protocol) 为 AI Agent 提供构建能力。
架构
┌─────────────┐ ┌─────────────┐ ┌─────────────────────────────────┐
│ AI Agent │────▶│ MCP Server │────▶│ Kubernetes Cluster │
│ │ │ (bxmcp-mcp) │ │ │
└─────────────┘ └─────────────┘ │ ┌─────────────┐ │
│ │ Controller │ │
│ │ │ │
│ └──────┬──────┘ │
│ │ │
│ ▼ │
│ ┌─────────────────────────┐ │
│ │ BuildKit Pod │ │
│ │ ┌─────────┐ ┌─────────┐ │ │
│ │ │uploader │▶│ buildkit│ │ │
│ │ │ (init) │ │ (main) │ │ │
│ │ └─────────┘ └─────────┘ │ │
│ └─────────────────────────┘ │
└─────────────────────────────────┘组件
- bxmcp-mcp: MCP Server,对 AI Agent 暴露
build.create、build.get、build.logs工具 - bxmcp-controller: Kubernetes Controller,管理 Build CRD 的生命周期
- bxmcp-uploader: Init Container,接收并解压构建上下文
- bxmcp-crd: Build CRD 定义
- bxmcp-common: 共享类型和工具
快速开始
前置条件
- Rust 1.75+
- Kubernetes 集群 (kind/minikube/k3d 或远程集群)
- kubectl 已配置
构建
# 构建所有组件
cargo build --release
# 构建 Docker 镜像
docker build -f docker/Dockerfile.controller -t bxmcp/controller:latest .
docker build -f docker/Dockerfile.uploader -t bxmcp/uploader:latest .
docker build -f docker/Dockerfile.mcp -t bxmcp/mcp:latest .部署
# 安装 CRD
kubectl apply -f deploy/kubernetes/crd.yaml
# 创建命名空间和 RBAC
kubectl apply -f deploy/kubernetes/rbac.yaml
# 部署 Controller
kubectl apply -f deploy/kubernetes/controller.yaml使用 MCP Server
MCP Server 通过 stdio 与 AI Agent 通信:
# 本地运行(需要 kubeconfig)
./target/release/bxmcp-mcpMCP Tools
build.create
创建新的构建任务。
输入:
{
"imageRef": "registry.example.com/myapp:v1.0",
"push": true,
"platforms": ["linux/amd64"],
"dockerfilePath": "Dockerfile",
"buildArgs": {"VERSION": "1.0.0"},
"registrySecret": "my-registry-cred"
}输出:
{
"buildId": "build-20260125-143052-a1b2c3d4",
"uploadUrl": "https://build-gw.example.com/builds/build-20260125-143052-a1b2c3d4/upload",
"uploadToken": "xxxxx",
"expiresAt": "2026-01-25T15:00:00Z"
}build.get
查询构建状态。
输入:
{
"buildId": "build-20260125-143052-a1b2c3d4"
}build.logs
获取构建日志。
输入:
{
"buildId": "build-20260125-143052-a1b2c3d4",
"container": "build",
"tailLines": 100
}上传构建上下文
获取 uploadUrl 和 uploadToken 后,使用 HTTP POST 上传 tar 包:
cd /path/to/your/project
tar czf - . | curl -X POST \
-H "Authorization: Bearer ${UPLOAD_TOKEN}" \
--data-binary @- \
"${UPLOAD_URL}"配置
Controller 环境变量
| 变量 | 默认值 | 说明 |
|------|--------|------|
| BXMCP_NAMESPACE | build-system | 操作的命名空间 |
| BXMCP_UPLOADER_IMAGE | bxmcp/uploader:latest | Uploader 镜像 |
| BXMCP_BUILDKIT_IMAGE | moby/buildkit:buildx-stable-1 | BuildKit 镜像 |
| BXMCP_INGRESS_HOST | - | Ingress 域名 |
| BXMCP_INGRESS_PATH_PREFIX | /builds | Ingress 路径前缀 |
Uploader 环境变量
| 变量 | 默认值 | 说明 |
|------|--------|------|
| LISTEN_ADDR | 0.0.0.0:8080 | 监听地址 |
| WORKSPACE | /workspace | 工作目录 |
| UPLOAD_TOKEN_FILE | /var/run/secrets/upload/token | Token 文件路径 |
| MAX_UPLOAD_BYTES | 2147483648 | 最大上传大小 (2GB) |
License
MIT
