使用说明
游牧民族mcp
HashiCorp Nomad的MCP(模型上下文协议)服务器。使AI代理能够通过标准MCP接口与Nomad集群交互。
安装
从源代码构建
go install github.com/danfedick/nomad-mcp@latest
或者克隆并构建:
git clone https://github.com/danfedick/nomad-mcp.git
cd nomad-mcp
go build -o nomad-mcp .
配置
设置标准Nomad环境变量:
export NOMAD_ADDR="https://nomad.example.com:4646"
export NOMAD_TOKEN="your-acl-token" # if ACLs enabled
export NOMAD_CACERT="/path/to/ca.pem" # if using TLS
客户端设置
克劳德桌面版
添加 ~/.config/claude/claude_desktop_config.json (Linux)或 ~/Library/Application Support/Claude/claude_desktop_config.json (macOS):
{
"mcpServers": {
"nomad": {
"command": "/path/to/nomad-mcp",
"env": {
"NOMAD_ADDR": "https://nomad.example.com:4646",
"NOMAD_TOKEN": "your-token"
}
}
}
}
克劳德博特
通过添加到MCP配置中 clawdbot configure --section mcp:
mcp:
servers:
nomad:
command: /path/to/nomad-mcp
env:
NOMAD_ADDR: https://nomad.example.com:4646
NOMAD_TOKEN: your-token
游标/其他MCP客户端
服务器使用stdio传输。配置您的客户端以运行二进制文件并通过stdin/stdout进行通信。
工具参考
工作
nomad_job_list
列出群集中的所有作业。
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| namespace | string | no | 要查询的命名空间(默认值:“default”) |
| filter | string | no | 筛选表达式 |
示例:
"List all jobs"
"Show me running jobs in the production namespace"
"What jobs are currently pending?"
nomad_job_status
获取特定作业的详细状态,包括其分配。
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| job_id | 字符串 | 是 | 作业id |
| 命名空间 | 字符串 | 否 | 命名空间 |
示例:
"Get status of the 'web' job"
"Show me details for the api-server job in production"
"What's happening with the traefik job?"
nomad_job_run
从HCL或JSON规范部署作业。
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| spec | string | yes | 作业规范(HCL或JSON) |
| detach | boolean | no | 立即返回,不进行监视 |
示例:
"Deploy this job: [paste HCL spec]"
"Run this Nomad job and wait for it to be healthy"
nomad_job_stop
停止正在运行的作业。
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| job_id | 字符串 | 是 | 作业id |
| purge | boolean | no | 完全清除作业(删除历史记录) |
| 命名空间 | 字符串 | 否 | 命名空间 |
示例:
"Stop the web job"
"Stop and purge the old-api job"
"Shut down the batch-processor in staging"
nomad_job_scale
将作业的任务组扩展到特定计数。
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| job_id | 字符串 | 是 | 作业id |
| group | string | yes | 任务组名称 |
| count | number | yes | 所需实例计数 |
| 命名空间 | 字符串 | 否 | 命名空间 |
示例:
"Scale the web job to 5 instances"
"Scale down api-server to 2 replicas"
"Set the worker group in batch-job to 10"
分配
nomad_alloc_list
列出作业的分配。
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| job_id | 字符串 | 是 | 作业id |
| 命名空间 | 字符串 | 否 | 命名空间 |
示例:
"Show allocations for the web job"
"List all instances of the api service"
nomad_alloc_status
获取详细的分配信息。
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| alloc_id | string | yes | 分配id(前缀OK) |
示例:
"Get status of allocation abc123"
"Show me details for alloc 7f3e"
nomad_alloc_logs
从分配中获取stdout或stderr日志。
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| alloc_id | string | yes | 分配id |
| task | string | no | 任务名称(如果省略,则使用第一个任务) |
| stderr | boolean | no | 获取stderr而不是stdout |
| tail | number | no | 距离末尾的字节数(默认值:50000) |
示例:
"Show me logs for the web job"
"Get stderr from allocation abc123"
"Show the last 10000 bytes of logs from the api task"
"What errors is the worker showing?"
nomad_alloc_restart
重新启动分配或特定任务。
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| alloc_id | string | yes | 分配id |
| task | string | no | 特定任务(如果省略,则重新启动所有任务) |
示例:
"Restart allocation abc123"
"Restart the nginx task in alloc 7f3e"
"Bounce the web service"
节点
nomad_node_list
列出群集中的所有节点。
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| filter | string | no | 筛选表达式 |
示例:
"List all nodes"
"Show me nodes that are ready"
"Which nodes are currently draining?"
nomad_node_status
获取节点详细信息及其分配。
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| node_id | string | yes | 节点id(前缀OK) |
示例:
"Show status of node abc123"
"What's running on node-1?"
"Get details for the node starting with 7f3e"
nomad_node_drain
启用或禁用节点排放以进行维护。
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| node_id | 字符串 | 是 | 节点id |
| enable | boolean | yes | 启用(真)或禁用(假)排放 |
| deadline_seconds | number | no | 排水截止日期(秒) |
示例:
"Drain node-1 for maintenance"
"Stop draining node abc123"
"Drain node-2 with a 5 minute deadline"
"Enable drain on the node starting with 7f3e"
部署
nomad_deployment_list
列出部署。
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| 命名空间 | 字符串 | 否 | 命名空间 |
示例:
"List all deployments"
"Show recent deployments in production"
"What deployments are running?"
nomad_deployment_status
获取部署详细信息。
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| deployment_id | string | yes | 部署id |
示例:
"Get status of deployment abc123"
"How's the latest deployment going?"
nomad_deployment_promote
推广金丝雀部署。
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| deployment_id | string | yes | 部署id |
| all | boolean | no | 升级所有任务组 |
示例:
"Promote deployment abc123"
"The canaries look good, promote the deployment"
"Promote all task groups in the current deployment"
服务
nomad_service_list
列出已注册的服务(Nomad本机服务发现)。
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| 命名空间 | 字符串 | 否 | 命名空间 |
示例:
"List all services"
"What services are registered?"
"Show services in the production namespace"
nomad_service_info
获取包括端点在内的服务详细信息。
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| service_name | string | yes | 服务名称 |
| 命名空间 | 字符串 | 否 | 命名空间 |
示例:
"Get info for the web service"
"Show me the endpoints for api-server"
"Where is the redis service running?"
变量
nomad_var_list
列出变量。
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| prefix | string | no | 路径前缀筛选器 |
| 命名空间 | 字符串 | 否 | 命名空间 |
示例:
"List all variables"
"Show variables under nomad/jobs/"
nomad_var_get
获取变量的值。
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| path | string | yes | 变量路径 |
| 命名空间 | 字符串 | 否 | 命名空间 |
示例:
"Get the variable at nomad/jobs/web/config"
"Read the database config variable"
nomad_var_put
创建或更新变量。
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| path | string | yes | 变量路径 |
| items | object | yes | 要存储的键值对 |
| 命名空间 | 字符串 | 否 | 命名空间 |
示例:
"Store DATABASE_URL=postgres://... in nomad/jobs/api/config"
"Update the web config variable with new values"
簇
nomad_cluster_status
获取集群状态,包括领导者、成员和节点。
示例:
"What's the cluster status?"
"Is the cluster healthy?"
"Who's the current leader?"
"Show me the server members"
nomad_eval_list
列出最近的评估。
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| job_id | string | no | 按作业id筛选 |
| status | string | no | 按状态筛选 |
| limit | number | no | 最大结果(默认值:25) |
示例:
"List recent evaluations"
"Show blocked evaluations"
"What evaluations are pending for the web job?"
对话示例
以下是您可能与使用游牧mcp的AI代理进行的一些现实对话:
检查服务
You: "How's the web service doing?"
Agent: [calls nomad_job_status with job_id="web"]
"The web service is running with 3 healthy allocations across
2 nodes. All instances are in the 'running' state. The last
deployment completed successfully 2 hours ago."
调查问题
You: "The API seems slow, can you check the logs?"
Agent: [calls nomad_job_status with job_id="api"]
[calls nomad_alloc_logs with the allocation ID]
"I found some concerning entries in the API logs. There are
several timeout errors connecting to the database. The errors
started about 15 minutes ago. Would you like me to restart
the allocations or check the database service?"
流量扩展
You: "We're about to get a traffic spike, scale the frontend to 10"
Agent: [calls nomad_job_scale with job_id="frontend", group="web", count=10]
"Scaled the frontend web group to 10 instances. The new
allocations are being placed now. I'll check back in a moment...
[calls nomad_job_status]
All 10 instances are now running and healthy."
节点维护
You: "We need to patch node-3, can you drain it?"
Agent: [calls nomad_node_drain with node_id="node-3", enable=true]
"I've enabled drain on node-3. Nomad is migrating 4 allocations
to other nodes. Current progress:
- web: 2/2 migrated
- api: 1/2 migrated (1 in progress)
The node should be clear in about 2 minutes."
部署管理
You: "Deploy this new version of the worker service"
Agent: [calls nomad_job_run with the spec]
"Deployment started. Using canary strategy - 1 canary instance
is being launched first.
[calls nomad_deployment_status]
The canary is healthy and passing health checks. Ready to
promote when you give the go-ahead."
You: "Looks good, promote it"
Agent: [calls nomad_deployment_promote]
"Promoted the deployment. Rolling out to remaining instances...
All 5 instances updated and healthy. Deployment complete!"
安全
MCP服务器从继承权限 NOMAD_TOKEN。使用具有适当ACL策略的令牌:
只读访问
namespace "*" {
policy = "read"
}
node {
policy = "read"
}
操作员完全访问权限
namespace "*" {
policy = "write"
}
node {
policy = "write"
}
agent {
policy = "write"
}
相关
许可证
麻省理工学院
