跳到主要内容

MCP注册表(2025-09-08)————发布者CLI命令参考

· 阅读需 4 分钟

翻译自: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.jsonsetup.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 - 验证但不发布

流程:

  1. 根据模式验证 server.json
  2. 验证包所有权(参见[官方注册要求])
  3. 检查命名空间认证
  4. 发布到注册库

示例:

# 基本发布
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"
}

MCP注册表(2025-09-08)————通用注册表 API 规范

· 阅读需 2 分钟

翻译自:https://github.com/modelcontextprotocol/registry/blob/main/docs/reference/api/generic-registry-api.md

一个标准化的RESTful HTTP API,用于MCP注册表提供一致的端点,以发现和检索MCP服务器。

另请参阅:

浏览完整的API规范

📋 交互式查看完整的 API 规范:在 OpenAPI 查看器中打开 openapi.yaml,例如 Stoplight Elements

官方注册表在此基础上还有一些额外的端点和限制。有关详细信息,请参阅官方注册表 API 规范

快速参考

核心端点

  • GET /v0/servers - 列出所有带有分页功能的服务器
  • GET /v0/servers/{id} - 根据UUID获取服务器详细信息
  • POST /v0/publish - 发布新服务器(可选,注册表特定的身份验证)

认证

  • 读取操作:无需身份验证
  • 写操作:注册表特定的身份验证(如果支持)。

内容类型

所有请求和响应都使用 application/json

基本示例:列出服务器

curl https://registry.example.com/v0/servers?limit=10
{
"servers": [
{
"name": "io.modelcontextprotocol/filesystem",
"description": "Filesystem operations server",
"status": "active",
"version": "1.0.2"
}
],
"metadata": {
"count": 10,
"next_cursor": "eyJ..."
}
}

要查看完整的端点文档,请在架构查看器中查看 OpenAPI 规范。

MCP注册表(2025-09-08)————server.json 格式规范

· 阅读需 11 分钟

翻译自:https://github.com/modelcontextprotocol/registry/blob/main/docs/reference/server-json/generic-server-json.md

server.json 文件是一种标准化的方式,用于描述 MCP 服务器,以便进行注册表发布、客户端发现和包管理。

另请参阅:

  • 有关创建和使用 server.json 文件的逐步说明,请参阅发布指南
  • 有关发布到官方注册表时验证要求的理解,请参阅官方注册表要求

浏览完整架构

📋 以交互方式查看完整规范: 在架构查看器中打开 server.schema.json,例如 json-schema.app

该架构包含所有字段定义、验证规则、示例和详细描述。

官方注册表在此基础上还有一些额外的限制。详情请参见官方注册表要求

例子

基本服务器与NPM包

{
"$schema": "https://static.modelcontextprotocol.io/schemas/2025-07-09/server.schema.json",
"name": "io.modelcontextprotocol.anonymous/brave-search",
"description": "MCP server for Brave Search API integration",
"status": "active",
"website_url": "https://anonymous.modelcontextprotocol.io/examples",
"repository": {
"url": "https://github.com/modelcontextprotocol/servers",
"source": "github"
},
"version": "1.0.2",
"packages": [
{
"registry_type": "npm",
"registry_base_url": "https://registry.npmjs.org",
"identifier": "@modelcontextprotocol/server-brave-search",
"version": "1.0.2",
"transport": {
"type": "stdio"
},
"environment_variables": [
{
"name": "BRAVE_API_KEY",
"description": "Brave Search API Key",
"is_required": true,
"is_secret": true
}
]
}
],
"_meta": {
"io.modelcontextprotocol.registry/publisher-provided": {
"tool": "npm-publisher",
"version": "1.0.1",
"build_info": {
"timestamp": "2023-12-01T10:30:00Z"
}
}
}
}

单体仓库中的带子文件夹的服务器

对于位于大型代码库(单仓库结构)子目录中的MCP服务器,请使用 subfolder 字段来指定相对路径:

{
"$schema": "https://static.modelcontextprotocol.io/schemas/2025-07-09/server.schema.json",
"name": "io.modelcontextprotocol/everything",
"description": "MCP服务器,测试MCP协议的所有功能",
"status": "active",
"repository": {
"url": "https://github.com/modelcontextprotocol/servers",
"source": "github",
"subfolder": "src/everything"
},
"version": "0.6.2",
"packages": [
{
"registry_type": "npm",
"registry_base_url": "https://registry.npmjs.org",
"identifier": "@modelcontextprotocol/everything",
"version": "0.6.2",
"transport": {
"type": "stdio"
}
}
],
"_meta": {
"io.modelcontextprotocol.registry/publisher-provided": {
"tool": "npm-publisher",
"version": "1.0.1",
"build_info": {
"timestamp": "2023-12-01T10:30:00Z"
}
}
}
}

启动MCP服务器所需的常量(固定)参数

假设你的MCP服务器应用程序需要mcp start命令行参数才能以MCP服务器模式启动。将其表示为类似这样的位置参数:

{
"name": "io.github.joelverhagen/knapcode-samplemcpserver",
"description": "随机数和随机天气的示例 NuGet MCP 服务器",
"version": "0.4.0-beta",
"packages": [
{
"registry_type": "nuget",
"registry_base_url": "https://api.nuget.org",
"identifier": "Knapcode.SampleMcpServer",
"version": "0.4.0-beta",
"transport": {
"type": "stdio"
},
"package_arguments": [
{
"type": "positional",
"value": "mcp"
},
{
"type": "positional",
"value": "start"
}
]
}
],
"_meta": {
"io.modelcontextprotocol.registry/publisher-provided": {
"tool": "nuget-publisher",
"version": "2.1.0",
"build_info": {
"timestamp": "2023-11-15T14:22:00Z",
"pipeline_id": "nuget-build-456"
}
}
}
}

这实际上会指示MCP客户端执行 dnx Knapcode.SampleMcpServer@0.4.0-beta -- mcp start,而不是默认的 dnx Knapcode.SampleMcpServer@0.4.0-beta(当未提供 package_arguments 时)。

具有多个软件包的文件系统服务器

json
{
"$schema": "https://static.modelcontextprotocol.io/schemas/2025-07-09/server.schema.json",
"name": "io.github.modelcontextprotocol/filesystem",
"description": "实现文件系统操作的Model Context Protocol (MCP)的Node.js服务器。",
"status": "active",
"repository": {
"url": "https://github.com/modelcontextprotocol/servers",
"source": "github",
"id": "b94b5f7e-c7c6-d760-2c78-a5e9b8a5b8c9"
},
"version": "1.0.2",
"packages": [
{
"registry_type": "npm",
"registry_base_url": "https://registry.npmjs.org",
"identifier": "@modelcontextprotocol/server-filesystem",
"version": "1.0.2",
"transport": {
"type": "stdio"
},
"package_arguments": [
{
"type": "位置参数",
"value_hint": "目标目录",
"description": "访问路径",
"default": "/Users/username/Desktop",
"is_required": true,
"is_repeated": true
}
],
"environment_variables": [
{
"name": "LOG_LEVEL",
"description": "日志级别(debug, info, warn, error)",
"default": "info"
}
]
},
{
"registry_type": "oci",
"registry_base_url": "https://docker.io",
"identifier": "mcp/filesystem",
"version": "1.0.2",
"transport": {
"type": "stdio"
},
"runtime_arguments": [
{
"type": "命名",
"description": "将一个卷挂载到容器中",
"name": "--mount",
"value": "type=bind,src={source_path},dst={target_path}",
"is_required": true,
"is_repeated": true,
"variables": {
"source_path": {
"description": "主机上的源路径",
"format": "文件路径",
"is_required": true
},
"target_path": {
"description": "挂载到容器内的路径。路径应根植于`/project`目录。",
"is_required": true,
"default": "/project"
}
}
}
],
"package_arguments": [
{
"type": "位置参数",
"value_hint": "目标目录",
"value": "/project"
}
],
"environment_variables": [
{
"name": "LOG_LEVEL",
"description": "日志级别(debug, info, warn, error)",
"default": "info"
}
]
}
],
"_meta": {
"io.modelcontextprotocol.registry/publisher-provided": {
"tool": "ci-publisher",
"version": "3.2.1",
"build_info": {
"commit": "a1b2c3d4e5f6789",
"timestamp": "2023-12-01T10:30:00Z",
"pipeline_id": "filesystem-build-789",
"environment": "production"
}
}
}
}

远程服务器示例

{
"name": "io.modelcontextprotocol.anonymous/mcp-fs",
"description": "云托管的MCP文件系统服务器",
"repository": {
"url": "https://github.com/example/remote-fs",
"source": "github",
"id": "xyz789ab-cdef-0123-4567-890ghijklmno"
},
"version": "2.0.0",
"remotes": [
{
"type": "sse",
"url": "http://mcp-fs.anonymous.modelcontextprotocol.io/sse"
}
],
"_meta": {
"io.modelcontextprotocol.registry/publisher-provided": {
"tool": "云部署工具",
"version": "2.4.0",
"build_info": {
"commit": "f7e8d9c2b1a0",
"timestamp": "2023-12-05T08:45:00Z",
"deployment_id": "remote-fs-deploy-456",
"region": "us-west-2"
}
}
}
}

Python包示例

{
"name": "io.github.example/weather-mcp",
"description": "Python MCP服务器,用于天气数据访问",
"repository": {
"url": "https://github.com/example/weather-mcp",
"source": "github",
"id": "def456gh-ijkl-7890-mnop-qrstuvwxyz12"
},
"version": "0.5.0",
"packages": [
{
"registry_type": "pypi",
"registry_base_url": "https://pypi.org",
"identifier": "weather-mcp-server",
"version": "0.5.0",
"runtime_hint": "uvx",
"transport": {
"type": "stdio"
},
"environment_variables": [
{
"name": "WEATHER_API_KEY",
"description": "天气服务的API密钥",
"is_required": true,
"is_secret": true
},
{
"name": "WEATHER_UNITS",
"description": "温度单位(摄氏度、华氏度)",
"default": "摄氏度"
}
]
}
],
"_meta": {
"io.modelcontextprotocol.registry/publisher-provided": {
"tool": "poetry-publisher",
"version": "1.8.3",
"build_info": {
"python_version": "3.11.5",
"timestamp": "2023-11-28T16:20:00Z",
"build_id": "pypi-weather-123",
"dependencies_hash": "sha256:a9b8c7d6e5f4"
}
}
}
}

NuGet (.NET) 包示例

dnx` 工具从 .NET 10 SDK 的 Preview 6 版本开始随附提供。

{
"name": "io.github.joelverhagen/knapcode-samplemcpserver",
"description": "示例 NuGet MCP 服务器,用于生成随机数和随机天气",
"repository": {
"url": "https://github.com/joelverhagen/Knapcode.SampleMcpServer",
"source": "github",
"id": "example-nuget-id-0000-1111-222222222222"
},
"version": "0.5.0",
"packages": [
{
"registry_type": "nuget",
"registry_base_url": "https://api.nuget.org",
"identifier": "Knapcode.SampleMcpServer",
"version": "0.5.0",
"runtime_hint": "dnx",
"transport": {
"type": "stdio"
},
"environment_variables": [
{
"name": "WEATHER_CHOICES",
"description": "用逗号分隔的天气描述列表,供随机选择。",
"is_required": true,
"is_secret": false
}
]
}
],
"_meta": {
"io.modelcontextprotocol.registry/publisher-provided": {
"tool": "dotnet-publisher",
"version": "8.0.100",
"build_info": {
"dotnet_version": "8.0.0",
"timestamp": "2023-12-10T12:15:00Z",
"configuration": "Release",
"target_framework": "net8.0",
"build_number": "20231210.1"
}
}
}
}

复杂的 Docker 服务器及多个参数

json
{
"name": "io.github.example/database-manager",
"description": "用于数据库操作的MCP服务器,支持多种数据库类型",
"repository": {
"url": "https://github.com/example/database-manager-mcp",
"source": "github",
"id": "ghi789jk-lmno-1234-pqrs-tuvwxyz56789"
},
"version": "3.1.0",
"packages": [
{
"registry_type": "oci",
"registry_base_url": "https://docker.io",
"identifier": "example/database-manager-mcp",
"version": "3.1.0",
"transport": {
"type": "stdio"
},
"runtime_arguments": [
{
"type": "named",
"name": "--network",
"value": "host",
"description": "使用主机网络模式"
},
{
"type": "named",
"name": "-e",
"value": "DB_TYPE={db_type}",
"description": "要连接的数据库类型",
"is_repeated": true,
"variables": {
"db_type": {
"description": "数据库类型",
"choices": [
"postgres",
"mysql",
"mongodb",
"redis"
],
"is_required": true
}
}
}
],
"package_arguments": [
{
"type": "named",
"name": "--host",
"description": "数据库主机",
"default": "localhost",
"is_required": true
},
{
"type": "named",
"name": "--port",
"description": "数据库端口",
"format": "number"
},
{
"type": "positional",
"value_hint": "database_name",
"description": "要连接的数据库名称",
"is_required": true
}
],
"environment_variables": [
{
"name": "DB_USERNAME",
"description": "数据库用户名",
"is_required": true
},
{
"name": "DB_PASSWORD",
"description": "数据库密码",
"is_required": true,
"is_secret": true
},
{
"name": "SSL_MODE",
"description": "SSL连接模式",
"default": "prefer",
"choices": [
"disable",
"prefer",
"require"
]
}
]
}
],
"_meta": {
"io.modelcontextprotocol.registry/publisher-provided": {
"tool": "docker-buildx",
"version": "0.12.1",
"build_info": {
"docker_version": "24.0.7",
"timestamp": "2023-12-08T14:30:00Z",
"platform": "linux/amd64,linux/arm64",
"registry": "docker.io",
"image_digest": "sha256:1a2b3c4d5e6f7890"
}
}
}
}

具有远程和软件包选项的服务器

{
"$schema": "https://static.modelcontextprotocol.io/schemas/2025-07-09/server.schema.json",
"name": "io.modelcontextprotocol.anonymous/hybrid-mcp",
"description": "MCP server available as both local package and remote service",
"repository": {
"url": "https://github.com/example/hybrid-mcp",
"source": "github",
"id": "klm012no-pqrs-3456-tuvw-xyz789abcdef"
},
"version": "1.5.0",
"packages": [
{
"registry_type": "npm",
"registry_base_url": "https://registry.npmjs.org",
"identifier": "@example/hybrid-mcp-server",
"version": "1.5.0",
"runtime_hint": "npx",
"transport": {
"type": "stdio"
},
"package_arguments": [
{
"type": "named",
"name": "--mode",
"description": "Operation mode",
"default": "local",
"choices": [
"local",
"cached",
"proxy"
]
}
]
}
],
"remotes": [
{
"type": "sse",
"url": "https://mcp.anonymous.modelcontextprotocol.io/sse",
"headers": [
{
"name": "X-API-Key",
"description": "API key for authentication",
"is_required": true,
"is_secret": true
},
{
"name": "X-Region",
"description": "Service region",
"default": "us-east-1",
"choices": [
"us-east-1",
"eu-west-1",
"ap-southeast-1"
]
}
]
},
{
"type": "streamable-http",
"url": "https://mcp.anonymous.modelcontextprotocol.io/http"
}
],
"_meta": {
"io.modelcontextprotocol.registry/publisher-provided": {
"tool": "hybrid-deployer",
"version": "1.7.2",
"build_info": {
"timestamp": "2023-12-03T11:00:00Z",
"deployment_strategy": "blue-green",
"npm_version": "10.2.4",
"node_version": "20.10.0",
"service_endpoints": {
"sse": "deployed",
"streamable": "deployed"
}
}
}
}
}

MCP捆绑包(MCPB)示例

{
"name": "io.modelcontextprotocol/text-editor",
"description": "MCP 捆绑服务器,提供高级文本编辑功能",
"repository": {
"url": "https://github.com/modelcontextprotocol/text-editor-mcpb",
"source": "github"
},
"version": "1.0.2",
"packages": [
{
"registry_type": "mcpb",
"registry_base_url": "https://github.com",
"identifier": "https://github.com/modelcontextprotocol/text-editor-mcpb/releases/download/v1.0.2/text-editor.mcpb",
"version": "1.0.2",
"file_sha256": "fe333e598595000ae021bd27117db32ec69af6987f507ba7a63c90638ff633ce",
"transport": {
"type": "stdio"
}
}
],
"_meta": {
"io.modelcontextprotocol.registry/publisher-provided": {
"tool": "mcpb-publisher",
"version": "1.0.0",
"build_info": {
"timestamp": "2023-12-02T09:15:00Z",
"bundle_format": "mcpb-v1"
}
}
}
}

此示例展示了一个MCPB(MCP Bundle)包,该包:

  • 托管在GitHub Releases(一个被列入许可名单的提供者)
  • 包含用于完整性验证的SHA-256哈希值
  • 可以被支持MCPB的MCP客户端直接下载和执行

在CLI工具中嵌入MCP

某些CLI工具捆绑了一个MCP服务器,但没有单独的MCP包或公共仓库。在这些情况下,可以通过指向主机CLI包并提供package_argumentsruntime_hint(如有需要)来启动MCP服务器,从而复用现有的packages结构。

{
"$schema": "https://static.modelcontextprotocol.io/schemas/2025-07-09/server.schema.json",
"name": "io.snyk/cli-mcp",
"description": "MCP server provided by the Snyk CLI",
"status": "active",
"version": "1.1298.0",
"packages": [
{
"registry_type": "npm",
"registry_base_url": "https://registry.npmjs.org",
"identifier": "snyk",
"version": "1.1298.0",
"transport": {
"type": "stdio"
},
"package_arguments": [
{ "type": "positional", "value": "mcp" },
{
"type": "named",
"name": "-t",
"description": "Transport type for MCP server",
"default": "stdio",
"choices": ["stdio", "sse"]
}
]
}
]
}

具有自定义安装路径的服务器

对于遵循自定义安装路径的MCP服务器或嵌入在没有独立软件包的应用程序中的服务器,请使用 website_url 字段引导用户查看设置文档:

{
"$schema": "https://static.modelcontextprotocol.io/schemas/2025-07-09/server.schema.json",
"name": "io.modelcontextprotocol.anonymous/embedded-mcp",
"description": "MCP server embedded in a Desktop app",
"status": "active",
"website_url": "https://anonymous.modelcontextprotocol.io/embedded-mcp-guide",
"version": "0.1.0"
}

已弃用的服务器示例

json
{
"name": "io.github.example/old-weather",
"description": "遗留的天气服务 - 已弃用:对于新项目请使用 weather-v2",
"status": "已弃用",
"repository": {
"url": "https://github.com/example/old-weather",
"source": "github",
"id": "legacy-abc123-def456-789012-345678-901234567890"
},
"version": "0.9.5",
"packages": [
{
"registry_type": "npm",
"registry_base_url": "https://registry.npmjs.org",
"identifier": "@legacy/old-weather-server",
"version": "0.9.5",
"transport": {
"type": "stdio"
},
"environment_variables": [
{
"name": "WEATHER_API_KEY",
"description": "天气 API 密钥",
"is_required": true,
"is_secret": true
}
]
}
],
"_meta": {
"io.modelcontextprotocol.registry/publisher-provided": {
"tool": "遗留发布工具",
"version": "0.8.1",
"build_info": {
"timestamp": "2023-06-15T09:30:00Z",
"deprecation_notice": "此发布工具已弃用。对于新项目请使用 npm-publisher v2.0+。",
"maintenance_mode": true,
"final_version": true
}
}
}
}

MCP注册表(2025-09-08)————介绍MCP注册表

· 阅读需 8 分钟

翻译自:https://blog.modelcontextprotocol.io/posts/2025-09-08-mcp-registry-preview/

今天,我们推出了模型上下文协议(MCP)注册表——一个公开的目录和API,用于收集公开可用的MCP服务器以提高其可发现性和实施效率。通过标准化服务器的分发和发现方式,我们正在扩展其覆盖范围,同时使客户端更容易连接。

MCP注册表现已提供预览版。要开始使用:

MCP服务器的单一事实来源

2025年3月,我们分享了想要为MCP生态系统构建一个中央注册表的计划。今天,我们宣布正式启动 https://registry.modelcontextprotocol.io,作为官方的MCP注册表。作为MCP项目的一部分,MCP注册表以及一个父OpenAPI规范都是开源的——这使每个人都能构建兼容的子注册表。

我们的目标是规范服务器的分配和发现方式,提供一个子注册表可以依赖的主要事实来源。进而,这将扩大服务器的覆盖范围,并帮助客户端更轻松地在MCP生态系统中找到服务器。

公共和私人子注册表

在建立一个中央注册表时,我们认为重要的是不要削弱社区和公司已经构建的现有注册表的功能。MCP 注册表作为公开可用的 MCP 服务器的主要可信来源,组织可以选择基于自定义标准创建子注册表。例如:

公共子注册中心(如与每个MCP客户端相关的带有明确见解的“MCP市场”)可以自由地补充和增强它们从上游MCP注册中心获取的数据。每个MCP终端用户角色都会有不同的需求,由MCP客户端市场以不同的见解方式适当服务其终端用户。

私有子注册表 将存在于具有严格隐私和安全要求的企业内部,但 MCP 注册表为这些企业提供了一个可以构建的单一上游数据源。至少,我们希望与这些私有实现共享 API 架构,以便相关的 SDK 和工具能够在整个生态系统中共享。

在两种情况下,MCP注册表都是起点——它是一个集中化的位置,MCP服务器维护者在这里发布和维护他们自我报告的信息,以供这些下游消费者处理并交付给他们的最终用户。

社区驱动的审核机制

MCP 注册表是一个由注册表工作组维护的官方 MCP 项目,并采用宽松的许可协议。社区成员可以提交问题,标记违反 MCP 管理指南 的服务器,例如包含垃圾信息、恶意代码或冒充合法服务的服务器。然后,注册表维护者可以将这些条目加入拒绝名单,并追溯性地将它们从公共访问中移除。

入门

要开始:

此MCP注册表的预览版旨在帮助我们在正式发布前改进用户体验,但不提供数据持久性保证或其他担保。我们建议MCP的采用者密切关注开发进展,因为在注册表正式发布之前可能会发生重大变更。

随着我们继续开发注册表,我们鼓励在modelcontextprotocol/registry GitHub 仓库上提供反馈和贡献:讨论、问题和拉取请求都非常欢迎。

感谢MCP社区

MCP 注册表从一开始就是一项协作努力,我们非常感谢更广泛开发者社区的热情和支持。

2025年2月,MCP的创作者David Soria ParraJustin Spahr-Summers提出建造一个集中化的社区注册表,并邀请PulseMCPGoose团队参与开发,这一项目作为一个基层倡议逐步展开。PulseMCP 的注册表维护者 Tadas Antanavicius领导了初期工作,并与来自 BlockAlex Hancock合作。他们的工作迅速得到注册表维护者 Toby Padilla 的支持,他是 GitHub 的MCP负责人。而近日,AnthropicAdam Jones也加入了团队成为注册表维护者,推动项目的顺利发布。MCP注册表开发的初步公告中提到,该项目共有16位贡献人员来自至少9家不同的公司。

许多其他人也为这个项目的实现做出了重要贡献:Radoslav Dimitrov 来自 StacklokAvinash Sridhar 来自 GitHubConnor Peet 来自 VS CodeJoel Verhagen 来自 NuGetPreeti Dewani 来自 Last9Avish Porwal 来自 MicrosoftJonathan Hefner,以及许多来自 Anthropic 和 GitHub 的员工,他们提供了代码审查和开发支持。我们还感谢 Registry 贡献者日志 上的每一位,以及参与 讨论和问题 的所有人。

我们深深感谢每一位为这一基础性开源基础设施投入的人。我们携手合作,正在帮助全球的开发者和组织构建更加可靠、具有上下文感知的人工智能应用程序。代表MCP社区,向您致以谢意。

MCP注册表(2025-09-08)————审核指南

· 阅读需 4 分钟

翻译自:https://github.com/modelcontextprotocol/registry/blob/main/docs/guides/administration/moderation-guidelines.md

官方MCP注册表中服务器发布者指南。

太长不看

我们非常宽容!我们只会移除非法内容、恶意软件、垃圾信息以及完全无法运行的服务器。

我们不对我们的审核作出任何保证,各子注册机构应将我们的数据“按原样”接受,假定几乎没有或完全没有审核。

范围

这些指南适用于官方MCP注册表 registry.modelcontextprotocol.io

子注册中心可能拥有自己的审核政策。如果您对某个特定子注册中心的内容有疑问,请直接联系他们。

免责声明

我们拥有有限的主动审核能力,这是一个由社区支持的项目。我们主要依赖于上游包注册表(例如 NPM、PyPi 和 Docker)或下游子注册表(例如 GitHub MCP Registry)进行更深入的审核。

这意味着注册表中可能存在一些内容需要根据这些指南移除,而我们尚未移除。您应该相应地处理注册表数据。

我们移除的内容

我们将移除包含以下内容的服务器:

  • 非法内容,包括淫秽内容、版权侵犯和黑客工具。
  • 恶意软件,无论意图如何
  • 垃圾信息,特别是扰乱注册表的大量创建的服务器。示例:
    • 同一台服务器被以不同名称多次提交。
    • 服务器只是提供一个固定的响应,其中包含一些营销文案。
    • 服务器描述充满了营销文案,其实现与其名称或描述无关。
  • 无法正常运行的服务器

我们不移除的内容

一般来说,我们认为应该保持注册表开放,并将管理工作交由子注册表处理。因此,我们不会移除以下类型的服务器:

  • 低质量或存在问题的服务器
  • 具有安全漏洞的服务器
  • 与其他服务器做同样的事情。
  • 提供或包含成人内容

移除如何起作用

当我们移除一台服务器时:

  • 它被设置为“已删除”状态,但仍可通过API访问。
  • 这允许子注册表将其从索引中移除。
  • 在极端情况下,我们可能会覆盖或删除服务器的详细信息,例如当元数据本身是非法时。

上诉;吸引;呼吁(根据具体语境翻译)。

觉得我们弄错了吗?请在我们的GitHub 仓库上提交一个问题,并附上以下内容:

  • 您服务器的ID和名称
  • 您认为它不符合上述移除标准的原因

对此政策的更改

我们仍在学习如何最好地运营MCP注册表!因此,我们未来可能会对这一政策进行修改。

MCP注册表(2025-09-08)————官方MCP注册表API

· 阅读需 4 分钟

翻译自:https://github.com/modelcontextprotocol/registry/blob/main/docs/reference/api/official-registry-api.md

此文档描述了托管在 registry.modelcontextprotocol.io 上的官方 MCP 注册表的 API。

此API基于通用注册表API,并附加了额外的端点和身份验证。有关使用API的实际示例,请参阅API使用指南。有关使用API发布服务器的信息,请参阅发布指南

基础网址

  • 生产环境: https://registry.modelcontextprotocol.io
  • Staging: https://staging.registry.modelcontextprotocol.io

交互式文档

扩展。

官方注册表实现了通用注册表 API,并具有以下特定配置和扩展:

认证

发布需要基于命名空间的身份验证:

  • GitHub OAuth - 用于 io.github.* 命名空间
  • GitHub OIDC - 用于从 GitHub Actions 发布
  • DNS 验证 - 适用于基于域名的命名空间(com.example.*
  • HTTP验证 - 针对基于域名的命名空间(com.example.*

请参阅发布者命令以进行身份验证设置。

包验证

官方注册表在发布时会强制执行额外的包验证要求

服务器列表过滤

官方注册表通过附加查询参数扩展了GET /v0/servers端点,以改进发现和同步功能:

  • 'updated_since' - 过滤在 RFC3339 时间戳之后更新的服务器(例如,'2025-08-07T13:15:04.280Z')
  • search - 在服务器名称中进行不区分大小写的子字符串搜索(例如,filesystem)
    • 这是有意设计得简单的。要进行更高级的搜索和筛选,请使用子注册表。
  • '''version - 按版本筛选(目前仅支持latest用于最新版本)'''

这些扩展使下游注册表能够实现高效的增量同步,并改进了服务器发现。参数可以组合使用,并与标准的基于游标的分页配合工作。

示例:`GET /v0/servers?search=filesystem&updated_since=2025-08-01T00:00:00Z&version=latest

附加终端点

认证端点

  • POST /v0/auth/dns - 用签名的DNS挑战交换认证令牌
  • POST /v0/auth/http - 用签名的HTTP挑战交换认证令牌
  • POST /v0/auth/github-at - 用GitHub访问令牌交换认证令牌
  • POST /v0/auth/github-oidc - 交换GitHub OIDC令牌以获取认证令牌
  • POST /v0/auth/oidc - 用于将谷歌OIDC令牌交换为认证令牌(针对管理员)。

管理员端点

  • GET /metrics - Prometheus 指标端点
  • GET /v0/health - 基本健康检查端点
  • PUT /v0/servers/{id} - 编辑现有服务器

MCP注册表(2025-09-08)————发布您的MCP服务器

· 阅读需 13 分钟

翻译自:https://github.com/modelcontextprotocol/registry/blob/main/docs/guides/publishing/publish-server.md

将MCP服务器发布到注册表的完整指南。

[!提示] 使用一个有主动性的 AI 编码助手?只需使用以下提示:

阅读 https://raw.githubusercontent.com/modelcontextprotocol/registry/refs/heads/main/docs/guides/publishing/publish-server.md 和 https://raw.githubusercontent.com/modelcontextprotocol/registry/refs/heads/main/docs/guides/publishing/github-actions.md。评估将此服务器发布到注册表的最佳方法(尽可能优先选择自动的CI流程,而非手动流程),并实施它。如果可能,在告诉用户完成之前,使用适当的 JSON 模式库或用户计算机上可用的工具,根据 $schema 验证 server.json。如果遇到困难,引导用户完成发布过程中他们需要执行的部分(例如,如果是手动发布,需要登录 publisher CLI 时)。

你将学习的内容

在本教程结束时,您将完成以下内容:

  • 为您的MCP服务器创建一个server.json文件
  • 使用注册表进行身份验证
  • 成功发布您的服务器
  • 验证您的服务器出现在注册表中

先决条件

部署选项

您可以通过多种方式使您的MCP服务器可用:

  • 📦 软件包部署:发布到注册表(如 npm、PyPI、Docker Hub 等)并由客户端本地运行
  • 🌐 远程部署:作为网络服务托管,客户端可直接连接
  • 🔄 混合部署:提供打包和远程选项以实现最大灵活性

在官方文档中了解更多关于MCP服务器架构的信息。

第1步:安装Publisher CLI

🍺 macOS/Linux/WSL: 使用 Homebrew(推荐)

需要Homebrew:

brew install mcp-publisher
⬇️ macOS/Linux/WSL:预构建二进制文件
curl -L "https://github.com/modelcontextprotocol/registry/releases/download/v1.0.0/mcp-publisher_1.0.0_$(uname -s | tr '[:upper:]' '[:lower:]')_$(uname -m | sed 's/x86_64/amd64/;s/aarch64/arm64/').tar.gz" | tar xz mcp-publisher && sudo mv mcp-publisher /usr/local/bin/
🏗️ macOS/Linux/WSL: 从源码构建

需要 Git、Make 和 Go 1.24+:

# 克隆注册表仓库
git clone https://github.com/modelcontextprotocol/registry
cd registry
make publisher

# 二进制文件将位于bin/mcp-publisher
export PATH=$PATH:$(pwd)/bin
🪟 Windows PowerShell:预先构建的二进制文件
$arch = if ([System.Runtime.InteropServices.RuntimeInformation]::ProcessArchitecture -eq "Arm64") { "arm64" } else { "amd64" }; Invoke-WebRequest -Uri "https://github.com/modelcontextprotocol/registry/releases/download/v1.0.0/mcp-publisher_1.0.0_windows_$arch.tar.gz" -OutFile "mcp-publisher.tar.gz"; tar xf mcp-publisher.tar.gz mcp-publisher.exe; rm mcp-publisher.tar.gz
# Move mcp-publisher.exe to a directory in your PATH

步骤 2:初始化您的 server.json

导航到您的服务器目录并创建一个模板:

cd /path/to/your/mcp-server
mcp-publisher init

这会创建一个带有自动检测值的 server.json。你会看到类似以下的内容:

{
"$schema": "https://static.modelcontextprotocol.io/schemas/2025-07-09/server.schema.json",
"name": "io.github.yourname/your-server",
"description": "A description of your MCP server",
"version": "1.0.0",
"packages": [
{
"registry_type": "npm",
"identifier": "your-package-name",
"version": "1.0.0"
}
]
}

步骤3:配置您的服务器详细信息

编辑生成的server.json

选择你的命名空间

name 字段决定了认证需求:

  • io.github.yourname/* - 需要 GitHub 认证
  • com.yourcompany/* - 需要进行DNS或HTTP域名验证

配置部署方法

将您的服务器配置为支持软件包、远程或两者兼有。

包部署

添加包验证元数据以证明您对包的所有权。

📦 NPM Packages

要求

在你的 package.json 文件中添加一个 mcpName 字段:

{
"name": "你的npm包",
"version": "1.0.0",
"mcpName": "io.github.username/服务器名字"
}

它是如何工作的

示例服务器.json

{
"name": "io.github.username/server-name",
"packages": [
{
"registry_type": "npm",
"identifier": "your-npm-package",
"version": "1.0.0"
}
]
}

官方的MCP注册表目前仅支持NPM公共注册表(https://registry.npmjs.org)。

🐍 PyPI 软件包

要求

将您的服务器名称以此格式包含在您的包README文件中:

MCP名称格式mcp-name: io.github.username/server-name

将其添加到您的README.md文件中(它会成为PyPI上的软件包描述)。如果您想在其他地方隐藏它,可以将其放在注释中。

它是如何工作的

  • 注册表获取 https://pypi.org/pypi/your-package/json
  • 如果 mcp-name: server-name 在 README 内容中,则通过。

示例服务器.json

{
"name": "io.github.username/server-name",
"packages": [
{
"registry_type": "pypi",
"identifier": "your-pypi-package",
"version": "1.0.0"
}
]
}

官方的MCP注册表目前仅支持官方的PyPI注册表(https://pypi.org)。

📋 NuGet 包

要求

在你的软件包的README文件中使用以下格式包含你的服务器名称:

MCP名称格式mcp-name: io.github.username/server-name

将一个包含服务器名称的README文件添加到你的NuGet包中。如果你想在其他地方隐藏它,可以将其放在注释中。

它是如何工作的

  • 注册表从 https://api.nuget.org/v3-flatcontainer/{id}/{version}/readme 获取自述文件。
  • 如果在README内容中找到mcp-name: server-name,则通过。

示例服务器.json

{
"name": "io.github.username/server-name",
"packages": [
{
"registry_type": "nuget",
"identifier": "Your.NuGet.Package",
"version": "1.0.0"
}
]
}

官方的MCP注册表目前仅支持官方的NuGet注册表(https://api.nuget.org)。

🐳 Docker/OCI 镜像

要求

为您的 Docker 镜像添加一个注释:

LABEL io.modelcontextprotocol.server.name="io.github.username/server-name"

它是如何工作的

  • 注册表使用公共令牌与Docker Hub进行身份验证。
  • 使用 Docker Registry v2 API 获取镜像清单
  • 检查 io.modelcontextprotocol.server.name 注解是否与您的服务器名称匹配。
  • 如果注释缺失或不匹配,则失败

示例服务器.json

{
"name": "io.github.username/server-name",
"packages": [
{
"registry_type": "oci",
"identifier": "yourusername/your-mcp-server",
"version": "1.0.0"
}
]
}

标识符是 namespace/repository,版本是标签,并可以选择性地包括摘要。

官方的MCP注册表目前仅支持官方的Docker注册表(https://docker.io)。

📁 MCPB Packages

要求

MCP参考 - MCPB软件包的URL必须在某处包含“mcp”,以确保上传了正确的工件。这可以通过.mcpb扩展名或在您的存储库名称中实现。

文件完整性 - MCPB 包必须包含用于文件完整性验证的 SHA-256 哈希值。此操作是在发布时必需的,MCP 客户端将在安装前验证该哈希值。

如何生成文件哈希

计算你的MCPB文件的SHA-256哈希值:

openssl dgst -sha256 server.mcpb

示例服务器.json

{
"name": "io.github.username/server-name",
"packages": [
{
"registry_type": "mcpb",
"identifier": "https://github.com/you/your-repo/releases/download/v1.0.0/server.mcpb",
"file_sha256": "fe333e598595000ae021bd27117db32ec69af6987f507ba7a63c90638ff633ce"
}
]
}

文件哈希验证

  • 作者 负责在创建 server.json 时生成正确的 SHA-256 哈希值。
  • MCP 客户端 在安装软件包之前验证哈希值以确保文件完整性。
  • 官方注册表存储哈希但不验证它们。
  • 子注册处可以选择实施自己的验证。这使他们能够对MCPB文件进行安全扫描,并确保客户端获得相同的经过安全扫描的内容。

官方的MCP注册表目前仅支持托管在GitHub或GitLab版本上的工件。

远程部署

remotes 字段添加到您的 server.json 中(可以与 packages 共存):

🌐 远程服务器配置

要求

  • 服务端点:您的MCP服务器必须可以通过指定的URL访问。
  • 传输协议:选择 sse(服务器发送事件)或 streamable-http
  • URL验证:仅适用于域命名空间(请参阅以下URL要求)

示例服务器.json

{
"$schema": "https://static.modelcontextprotocol.io/schemas/2025-07-09/server.schema.json",
"name": "com.yourcompany/api-server",
"description": "Cloud-hosted MCP server for API operations",
"version": "2.0.0",
"remotes": [
{
"type": "sse",
"url": "https://mcp.yourcompany.com/sse"
}
]
}

多种交通选项

你可以提供多种连接方式:

{
"remotes": [
{
"type": "sse",
"url": "https://mcp.yourcompany.com/sse"
},
{
"type": "streamable-http",
"url": "https://mcp.yourcompany.com/http"
}
]
}

URL验证要求

  • 对于 com.yourcompany/* 命名空间:URL 必须位于 yourcompany.com 或其子域名。
  • 对于io.github.username/*命名空间:没有URL限制(但您必须通过GitHub进行身份验证)。

身份验证标头(可选)

配置客户端连接时应发送的请求头。

{
"remotes": [
{
"type": "sse",
"url": "https://mcp.yourcompany.com/sse",
"headers": [
{
"name": "X-API-Key",
"description": "API key for authentication",
"is_required": true,
"is_secret": true
}
]
}
]
}

步骤 4:身份验证

根据您的命名空间选择身份验证方法。

GitHub认证(用于io.github.*命名空间)

mcp-publisher login github

这会打开你的浏览器进行OAuth认证。

DNS验证(用于自定义域名)

bash
# 生成密钥对
openssl genpkey -algorithm Ed25519 -out key.pem

# 获取用于DNS记录的公钥
echo "yourcompany.com. IN TXT \"v=MCPv1; k=ed25519; p=$(openssl pkey -in key.pem -pubout -outform DER | tail -c 32 | base64)\""

# 将TXT记录添加到你的DNS中,然后登录
mcp-publisher login dns --domain yourcompany.com --private-key $(openssl pkey -in key.pem -noout -text | grep -A3 "priv:" | tail -n +2 | tr -d ' :\n')

第5步:发布你的服务器

认证完成后,发布您的服务器:

mcp-publisher publish

你将看到类似这样的输出:

✓ Successfully published

步骤6:验证出版物

检查您的服务器是否出现在注册表中,可以通过搜索进行验证:

curl "https://registry.modelcontextprotocol.io/v0/servers?search=io.github.yourname/weather-server"

您应该会在 JSON 响应中看到您的服务器元数据。

故障排除

"包验证失败" - 请确保您的包中包含所需的验证元数据(mcpName字段、README提及或Docker标签)。

"身份验证失败" - 请验证您是否正确设置了DNS记录或已登录到正确的GitHub账户。'''

"命名空间未授权" - 您的身份验证方法与所选的命名空间格式不匹配。

例子

请看这些已发布服务器的实际例子:

下一步

你所完成的事情

您已成功将您的第一个MCP服务器发布到注册表!您的服务器现在可以被MCP客户端发现,并且可以被全球用户安装。

MCP注册表(2025-09-08)————通过REST API消费注册表数据

· 阅读需 5 分钟

翻译自:https://github.com/modelcontextprotocol/registry/blob/main/docs/guides/consuming/use-rest-api.md

集成模式和最佳实践:构建使用MCP注册表数据的应用程序。

关键细节

基本URL: https://registry.modelcontextprotocol.io

认证:只读访问不需要认证

  • GET /v0/servers - 列出所有带分页的服务器
  • GET /v0/servers/{id} - 根据UUID获取服务器详细信息

请参阅交互式 API 文档,以获取完整的请求/响应模式。

免责声明:官方注册表不提供正常运行时间或数据持久性的保证。您应该通过缓存设计您的应用程序来应对服务停机。

建立子注册表

创建增强的注册表 - 提取官方注册表数据并添加您自己的元数据,如评级、安全扫描或兼容性信息。

目前我们建议定期抓取 GET /v0/servers 端点。未来我们可能会提供一个 updated_at 的过滤器(#291),以便仅获取最近更改的服务器。

服务器通常是不可变的,除了status字段可以更新为deleted(以及其他状态)。对于这些包,我们建议您也将状态字段更新为deleted或者快速从您的注册表中移除该包。这是因为该状态通常表明它违反了我们的宽松审核指南,暗示它可能是非法的、恶意软件或者垃圾信息。

过滤与增强

官方注册表具有宽松的审核政策,因此您可能需要在注册表数据的基础上实施自己的过滤。

您还可以使用 _meta 字段向服务器添加自定义元数据。例如,用户评分、下载次数或安全扫描结果。如果您这样做,我们建议您将其放在一个以您的组织命名空间命名的键下,例如:

{
"$schema": "https://static.modelcontextprotocol.io/schemas/2025-07-09/server.schema.json",
"name": "io.github.yourname/weather-server",
"description": "天气数据访问的MCP服务器",
"status": "active",
"version": "1.0.0",
"packages": [
{
"registry_type": "npm",
"identifier": "weather-mcp-server",
"version": "1.0.0"
}
],
"_meta": {
"com.example.subregistry/custom": {
"user_rating": 4.5,
"download_count": 12345,
"security_scan": {
"last_scanned": "2024-06-01T12:00:00Z",
"vulnerabilities_found": 0
}
}
}
}

提供一个API

我们建议您的子注册表提供一个符合注册表 API 规范的 API,这样客户端可以轻松地在不同的注册表之间切换。有关详细信息,请参阅注册表 API 文档

MCP客户端集成

将注册表数据转换为客户端配置 - 获取服务器并将包信息转换为MCP客户端的配置格式。

我们强烈建议使用子注册表,而不是直接从官方注册表获取数据。您可能希望使其可配置,以便您的客户端用户可以选择他们首选的注册表,例如,我们预计某些企业用户可能会有自己的注册表。

您的客户端应优雅地处理符合最低规范的注册表,即避免对_meta字段的硬性依赖。

过滤

您可能需要筛选出在status字段中不是active的服务器。

运行服务器

你可以使用 packagesremotes 字段来决定如何运行服务器。这些字段的更多详细信息可以在 server.json 文档 中找到。

模型上下文协议规范(2025-06-18)—— 操作引导

· 阅读需 8 分钟

翻译自:https://modelcontextprotocol.io/specification/2025-06-18/client/elicitation

ℹ️ 协议修订:2025-06-18
ℹ️ 操作引导在此版本的MCP规范中是新引入的,其设计可能会在未来的协议版本中演变。

模型上下文协议(MCP)提供了一种标准化的方式,使服务器能够在与客户端的交互过程中通过客户端向用户请求额外的信息。此流程允许客户端在与用户的交互和数据共享中保持控制,同时使服务器能够动态地收集必要的信息。服务器通过 JSON 模式向用户请求结构化数据以验证响应。

用户交互模型

在MCP中,信息操作引导允许服务器通过启用用户输入请求嵌套在其他MCP服务器功能内部,从而实现交互式工作流程。

实现可以自由地通过任何符合其需求的接口模式来展现操作引导过程——协议本身并未规定任何特定的用户交互模型。

ℹ️ 为了信任与安全及保障:

  • 服务器绝不可使用操作引导性请求获取敏感信息。

应用程序应该:

  • 提供明确显示是哪个服务器正在请求信息的用户界面。

  • 允许用户在发送前审阅和修改他们的回复

  • 尊重用户隐私,并提供明确的拒绝和取消选项

能力

支持操作引导的客户端必须初始化期间声明elicitation功能:

{
"capabilities": {
"elicitation": {}
}
}

协议消息

创建需求操作引导请求

要向用户请求信息,服务器会发送一个 elicitation/create 请求:

简单文本请求

请求:

{
"jsonrpc": "2.0",
"id": 1,
"method": "elicitation/create",
"params": {
"message": "Please provide your GitHub username",
"requestedSchema": {
"type": "object",
"properties": {
"name": {
"type": "string"
}
},
"required": ["name"]
}
}
}

响应:

{
"jsonrpc": "2.0",
"id": 1,
"result": {
"action": "accept",
"content": {
"name": "octocat"
}
}
}

结构化数据请求

请求:

{
"jsonrpc": "2.0",
"id": 2,
"method": "elicitation/create",
"params": {
"message": "请提供您的联系方式",
"requestedSchema": {
"type": "object",
"properties": {
"name": {
"type": "string",
"description": "您的全名"
},
"email": {
"type": "string",
"format": "email",
"description": "您的电子邮件地址"
},
"age": {
"type": "number",
"minimum": 18,
"description": "您的年龄"
}
},
"required": ["name", "email"]
}
}
}

响应:

{
"jsonrpc": "2.0",
"id": 2,
"result": {
"action": "accept",
"content": {
"name": "Monalisa Octocat",
"email": "octocat@github.com",
"age": 30
}
}
}

拒绝响应示例:

{
"jsonrpc": "2.0",
"id": 2,
"result": {
"action": "reject"
}
}

取消响应示例:

{
"jsonrpc": "2.0",
"id": 2,
"result": {
"action": "cancel"
}
}

消息流

消息流

请求模式

requestedSchema 字段允许服务器使用受限的 JSON Schema 子集来定义预期响应的结构。为了简化客户端的实现,操作引导模式仅限于具有原始属性的简单对象。

"requestedSchema": {
"type": "object",
"properties": {
"propertyName": {
"type": "string",
"title": "Display Name",
"description": "Description of the property"
},
"anotherProperty": {
"type": "number",
"minimum": 0,
"maximum": 100
}
},
"required": ["propertyName"]
}

支持的模式类型

该模式仅限于以下基本类型:

  1. 字符串模式
{
"type": "string",
"title": "显示名称",
"description": "描述文本",
"minLength": 3,
"maxLength": 50,
"pattern": "^[A-Za-z]+$",
"format": "email"
}

支持的格式:emailuridatedate-time

  1. 数字模式
{
"type": "number", // 或 "integer"
"title": "显示名称",
"description": "描述文本",
"minimum": 0,
"maximum": 100
}
  1. 布尔模式

{
"type": "boolean",
"title": "显示名称",
"description": "描述文本",
"default": false
}
  1. 枚举模式

原样返回:

{
"type": "string",
"title": "显示名称",
"description": "描述文本",
"enum": ["option1", "option2", "option3"],
"enumNames": ["Option 1", "Option 2", "Option 3"]
}

客户端可以使用此模式来:

  1. 生成适当的输入表单
  2. 在发送之前验证用户输入。
  3. 为用户提供更好的指导

请注意,为了简化客户端实现,复杂的嵌套结构、对象数组以及其他高级 JSON Schema 功能故意不予支持。

响应行动

启发式响应使用三步动作模型来清楚地区分不同的用户操作:

{
"jsonrpc": "2.0",
"id": 1,
"result": {
"action": "accept", // or "reject" or "cancel"
"content": {
"propertyName": "value",
"anotherProperty": 42
}
}
}

三个响应动作是:

  1. 接受action: "accept"):用户明确批准并提交了数据

    • content 字段包含与请求的模式匹配的提交数据。
    • 示例:用户点击了“提交”、“确定”、“确认”等。
  2. 拒绝action: "reject"):用户明确拒绝了请求

    • 通常省略content字段。
    • 示例:用户点击了“拒绝”、“不接受”、“否”等。
  3. 取消action: "cancel"):用户在未做出明确选择的情况下取消。

    • 通常省略content字段。
    • 示例:用户关闭了对话框,点击了外部区域,按下了 Escape 键等。

服务器应适当处理每种状态。

  • 接受:处理提交的数据
  • 拒绝:处理明确的拒绝(例如,提供替代方案)
  • 取消:处理解散(例如,稍后再次提示)。

安全性考虑

  1. 服务器绝不能通过套取方式请求敏感信息。
  2. 客户端应当实现用户批准控制。
  3. 双方应该根据提供的模式验证提取内容。
  4. 客户端应当清楚表明是哪个服务器正在请求信息。
  5. 客户端允许用户随时拒绝操作引导请求。
  6. 客户端应该实现速率限制。
  7. 客户端应该以一种清晰的方式提出操作引导请求,明确表明所需的信息是什么以及为什么需要这些信息。

模型上下文协议规范(2025-06-18)—— 关键变化

· 阅读需 3 分钟

翻译自:https://modelcontextprotocol.io/specification/2025-06-18/changelog

ℹ️ 此文档列出了自上一篇修订版(2025-03-26)以来对模型上下文协议(MCP)规范所做的更改。

重大变化

  1. 移除对JSON-RPC 批处理 的支持(PR #416)。
  2. 添加对结构化工具输出的支持(PR #371)。
  3. 将MCP服务器分类为OAuth资源服务器,添加受保护的资源元数据以发现相应的授权服务器。(PR #338
  4. 要求MCP客户端实施RFC 8707中描述的资源指示器,以防止恶意服务器获取访问令牌。(PR #734
  5. 请明确授权规范中的安全注意事项以及最佳实践,并在新的安全最佳实践页面中说明。
  6. 添加对 操作引导 的支持,使服务器能够在交互过程中请求用户提供额外信息。(PR #382
  7. 在工具调用结果中添加对 资源链接 的支持。(PR #603
  8. 要求在使用HTTP时,通过MCP-Protocol-Version请求头,在后续请求中指定协商的协议版本(参考PR #548)。
  9. 生命周期操作中的“SHOULD”更改为“MUST”。

其他架构更改

  1. 将“_meta”字段添加到其他接口类型(PR #710),并指定正确用法
  2. context 字段添加到 CompletionRequest 中,为完成请求提供包括先前解析的变量的功能(PR #598)。
  3. 添加title字段以便显示更易于理解的名称,这样name可以作为程序化标识符使用(PR #663)。

完整的变更日志

要查看自上次协议修订以来所做的所有更改的完整列表,请查看 GitHub