MCP注册表(2025-09-08)————发布者CLI命令参考
翻译自:https://github.com/modelcontextprotocol/registry/blob/main/docs/reference/cli/commands.md
mcp-publisher CLI 工具的完整命令参考。
请参阅发布指南,了解使用CLI发布服务器的详细步骤。
安装
通过 Homebrew 安装(macOS/Linux):
$ brew install mcp-publisher
全局选项
所有命令支持:
--help,-h- 显示命令帮助--registry- 注册表URL(默认值:https://registry.modelcontextprotocol.io)
命令
mcp-publisher init
生成一个带有自动检测功能的server.json模板。
用法:
mcp-publisher init [options]
行为:
- 在当前目录中创建
server.json - 自动检测包管理器(如
package.json、setup.py等) - 在可能的情况下预填充字段
- 提示输入缺失的必填字段
示例输出:
{
"name": "io.github.username/server-name",
"description": "TODO: Add server description",
"version": "1.0.0",
"packages": [
{
"registry_type": "npm",
"identifier": "detected-package-name",
"version": "1.0.0"
}
]
}
mcp-publisher login <method>
使用注册表进行认证。
认证方法:
GitHub互动
mcp-publisher login github [--registry=URL]
- 打开浏览器进行GitHub OAuth流程
- 授予对
io.github.{username}/*和io.github.{org}/*命名空间的访问权限。
GitHub OIDC(持续集成/持续交付)
mcp-publisher login github-oidc [--registry=URL]
- 自动使用 GitHub Actions OIDC 令牌
- 在工作流中需要具有
id-token: write权限。 - 不需要浏览器交互。
另请参阅[从 GitHub Actions 发布的指南]。
DNS 验证
mcp-publisher login dns --domain=example.com --private-key=HEX_KEY [--registry=URL]
- 验证域名所有权通过DNS TXT记录
- 授予对
com.example.*命名空间的访问权限 - 需要 Ed25519 私钥(64 个字符的十六进制)。
设置:
# 生成密钥对
openssl genpkey -algorithm Ed25519 -out key.pem
# 获取用于DNS记录的公钥
openssl pkey -in key.pem -pubout -outform DER | tail -c 32 | base64
# 添加DNS TXT记录:
# example.com. IN TXT "v=MCPv1; k=ed25519; p=PUBLIC_KEY"
# 提取用于登录的私钥
openssl pkey -in key.pem -noout -text | grep -A3 "priv:" | tail -n +2 | tr -d ' :\n'
HTTP验证
mcp-publisher login http --domain=example.com --private-key=HEX_KEY [--registry=URL]
- 通过HTTPS端点验证域所有权
- 授予对
com.example.*命名空间的访问权限 - 需要 Ed25519 私钥(64 个字符的十六进制)。
设置:
# 生成密钥对(与DNS相同)
openssl genpkey -algorithm Ed25519 -out key.pem
# 托管公钥到以下地址:
# https://example.com/.well-known/mcp-registry-auth
# 内容:v=MCPv1; k=ed25519; p=PUBLIC_KEY
匿名(测试)
mcp-publisher login none [--registry=URL]
- 没有身份验证 - 仅供本地测试
- 仅适用于本地注册表实例
mcp-publisher publish
将服务器发布到注册表。
有关发布流程的详细指南,请参阅发布指南。
用法:
mcp-publisher publish [options]
选项:
--file=PATH- 指向 server.json 的路径 (默认:./server.json)--registry=URL- 覆盖注册表 URL--dry-run- 验证但不发布
流程:
- 根据模式验证
server.json - 验证包所有权(参见[官方注册要求])
- 检查命名空间认证
- 发布到注册库
示例:
# 基本发布
mcp-publisher publish
# 干运行验证
mcp-publisher publish --dry-run
# 自定义文件位置
mcp-publisher publish --file=./config/server.json
mcp-publisher logout
清除存储的身份验证凭据。
用法:
mcp-publisher 注销
行为:
- 删除
~/.mcp_publisher_token - 不会在服务器端撤销令牌
配置
令牌存储
认证令牌以JSON格式存储在~/.mcp_publisher_token中。
{
"token": "jwt-token-here",
"registry_url": "https://registry.modelcontextprotocol.io",
"expires_at": "2024-12-31T23:59:59Z"
}