使用说明
Herold代码MCP
用于Heroku平台API的紧凑型MCP服务器,使用代码模式模式:
search+execute+auth_status.
Heroku Code MCP为代理客户端提供了一个小型、令牌高效的Heroku操作控制界面。搭配 英雄技能 当您需要工作流指导、安全检查和Heroku产品上下文以及实时API工具时。
设计参考:
快速开始
默认MCP URL: http://127.0.0.1:3000/mcp
git clone https://github.com/dsouzaAnush/heroku-code-mcp.git
cd heroku-code-mcp
npm install
npm run build
npm test
通过Heroku CLI进行种子身份验证:
heroku auth:whoami
npm run seed:token
启动服务器:
TOKEN_STORE_PATH=./data/tokens.integration.json \
TOKEN_ENCRYPTION_KEY_BASE64="<seed-output-key>" \
PORT=3000 HOST=127.0.0.1 npm run dev
烟雾测试:
curl -sS http://127.0.0.1:3000/healthz
MCP_URL=http://127.0.0.1:3000/mcp USER_ID=default npm run smoke:mcp
在npm发布之前,该包也可以在GitHub上运行:
HOST=127.0.0.1 PORT=3333 \
TOKEN_STORE_PATH="$HOME/.heroku-code-mcp/tokens.json" \
TOKEN_ENCRYPTION_KEY_BASE64="<base64-32-byte-key>" \
WRITE_CONFIRMATION_SECRET="<random-secret>" \
npx -y github:dsouzaAnush/heroku-code-mcp
在代理客户端中安装
克劳德代码
安装技能加MCP接线的配套插件:
claude plugin marketplace add dsouzaAnush/heroku-plugin
claude plugin install heroku@heroku-plugin
claude plugin enable heroku@heroku-plugin
或者直接添加正在运行的MCP服务器:
claude mcp add \
--transport http \
--scope local \
heroku-code-mcp \
http://127.0.0.1:3000/mcp \
--header "x-user-id: default"
克劳德桌面版
在支持的情况下直接使用HTTP端点:
{
"mcpServers": {
"heroku-code-mcp": {
"type": "http",
"url": "http://127.0.0.1:3000/mcp",
"headers": {
"x-user-id": "default"
}
}
}
}
对于需要stdio服务器的桌面构建,请桥接 mcp-remote:
{
"mcpServers": {
"heroku-code-mcp": {
"command": "npx",
"args": ["-y", "mcp-remote", "http://127.0.0.1:3000/mcp", "--allow-http", "--header", "x-user-id:default"]
}
}
}
建立一个 .mcpb 捆绑:
npm run build:mcpb
法典
Codex用途 Herold插件 技能和可选MCP接线:
codex plugin marketplace add dsouzaAnush/heroku-plugin --ref main
启用 heroku-plugin@heroku-plugin 在Codex插件选项卡中,或添加:
[plugins."heroku-plugin@heroku-plugin"]
enabled = true
在上运行此MCP服务器 http://127.0.0.1:3333/mcp 当您想要通过插件使用Heroku API实时工具时。
光标
git clone https://github.com/dsouzaAnush/heroku-plugin.git
cursor agent --plugin-dir heroku-plugin
将MCP服务器添加到 ~/.cursor/mcp.json 或项目本地 .cursor/mcp.json:
{
"mcpServers": {
"heroku-code-mcp": {
"type": "streamable-http",
"url": "http://127.0.0.1:3333/mcp",
"headers": {
"x-user-id": "default"
}
}
}
}
其他MCP客户端
使用流式HTTP:
{
"mcpServers": {
"heroku-code-mcp": {
"transport": "streamable_http",
"url": "http://127.0.0.1:3000/mcp",
"headers": {
"x-user-id": "default"
}
}
}
}
或者连接到stdio:
{
"mcpServers": {
"heroku-code-mcp": {
"command": "npx",
"args": ["-y", "mcp-remote", "http://127.0.0.1:3000/mcp", "--allow-http", "--header", "x-user-id:default"]
}
}
}
运作原理
| 工具 | 它做什么 | 它为什么存在 |
|---|---|---|
auth_status |
报告调用方是否通过Heroku身份验证 | 允许代理在API工作之前干净地分支 |
search |
根据模式和文档上下文对Heroku操作进行排序 | 避免预先暴露数十个端点形状的工具 |
execute |
验证参数/body并调用选定的Heroku操作 | 给出一个确定的执行路径 |
典型流程:
- 呼叫
auth_status. - 呼叫
search具有自然语言意图。 - 选一个
operation_id. - 呼叫
execute随着path_params,query_params,以及body. - 对于写入,请运行
dry_run=true,然后用重播confirm_write_token和ALLOW_WRITES=true.
示例:
{
"query": "list apps",
"limit": 5
}
{
"operation_id": "GET /apps"
}
{
"operation_id": "PATCH /apps/{app_identity}",
"path_params": {
"app_identity": "my-app"
},
"body": {
"maintenance": true
},
"dry_run": true
}
安全和配置
突变(POST, PATCH, PUT, DELETE)默认情况下被阻止。要允许写入,请设置 ALLOW_WRITES=true,请求一次模拟运行,并使用返回的结果进行重播 confirm_write_token。敏感的标头和正文字段已被编辑。
关键环境变量:
ALLOW_WRITESREQUEST_TIMEOUT_MSMAX_RETRIESCATALOG_CACHE_PATHREAD_CACHE_TTL_MSEXECUTE_MAX_BODY_BYTESEXECUTE_BODY_PREVIEW_CHARS
完整示例: .env.example
基准测试
2026年2月22日,在同一台机器上捕获了基准,并对这两种实现进行了说明。
| 公制 | heroku-code-mcp |
官方Heroku MCP | 德尔塔 |
|---|---|---|---|
| 刀具数量 | 3 | 37 | 91.9%下降 |
| 工具列表有效负载字节数 | 1469 | 25500 | 94.2%降低 |
| 工具列表近似标记 | 368 | 6375 | 94.2%降低 |
| 连接平均值 | 14.8毫秒 | 10168.7毫秒 | 快687倍 |
list_tools 平均值 |
4.3毫秒 | 10.3毫秒 | 快2.4倍 |
| 读取平均值 | 528.0毫秒(execute GET /apps) |
9697.4毫秒(list_apps) |
速度提高18.4倍 |
图表:
完整的方法论和工件都存在 BENCHMARKS.md 和 benchmarks/results/.
开发与发布
本地验证:
npm run build
npm test
npm run validate:server
npm run publish:dry-run
此仓库使用免费的GitHub操作:
validate.yml运行构建、测试,server.json验证和npm包在PR上进行模拟运行并推送main.release.yml运行于v*标签,构建.mcpb,更新发布server.json,创建或更新GitHub Release,并通过GitHub OIDC发布到MCP注册表。- Dependabot每周检查npm和GitHub Actions的依赖关系。
需要时手动发布:
npm publish --access public
mcp-publisher login github
mcp-publisher publish server.json
对于基于CI的npm发布,为repo配置npm可信发布 dsouzaAnush/heroku-code-mcp 和工作流程 release.yml,然后使用以下命令运行发布工作流 publish_npm=true.
仓库的规划
src/schema/*:摄取、操作规范化和缓存src/search/*:搜索索引和排名src/execute/*:验证和Heroku API执行src/auth/*:OAuth和加密令牌存储tests/*:编目、搜索和执行测试benchmarks/results/*:基准工件server.json:MCP注册表元数据
品牌和故障排除
此仓库包括官方Heroku文字标记和以下标记 assets.根据 Heroku品牌指南.
常见修复:
- MCP检查器连接错误:确认URL
http://127.0.0.1:3000/mcp以及服务器健康状况。 AUTH_REQUIRED:种子令牌或完成OAuth。- 写入被阻止:确认
ALLOW_WRITES=true并发送模拟运行确认令牌。 - 响应体大:查询范围窄或输出上限低。
