Q 开发者的 MCP 管理 - Amazon Q 开发者版

本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。

Q 开发者的 MCP 管理

使用 IAM Identity Center 作为登录方法的专业级客户可以控制其组织内用户的 MCP 访问权限。默认情况下,您的用户可以在其 Q 客户端中使用任何 MCP 服务器。作为管理员,您可以完全禁止用户使用 MCP 服务器,也可以指定允许您的用户使用的 MCP 服务器的经过审查的列表。

这些限制分别通过 MCP on/off 开关和 MCP 注册表进行控制。MCP 切换和注册表属性是 Q Developer 配置文件的一部分,可以在组织级别或账户级别定义,账户级别的配置文件取代组织级别的配置文件。这使您可以为整个组织指定默认 MCP 策略,然后为特定帐户覆盖该默认策略;例如,为整个组织禁用 MCP,但为某些团队(帐户)启用允许名单。

注意

切换设置和注册表设置都是在客户端强制执行的。请注意,最终用户可能会规避它。

为您的组织禁用 MCP

要为您的账户或组织禁用 MCP,请执行以下操作:

  1. 打开 Amazon Q 开发者版控制台。

  2. 选择设置

  3. 首选项下,选择编辑

  4. “编辑首选项” 弹出窗口中,将 “模型上下文协议 (MCP)” 切换为 “关闭”。

  5. 选择保存

为您的组织指定 MCP 允许名单

要控制允许组织中的用户使用哪些 MCP 服务器,您可以在 JSON 文件中指定允许的 MCP 服务器列表,通过 HTTPS 提供此 JSON 文件,然后在所需的 Q 开发者配置文件中输入该 URL。然后,任何使用此配置文件的 Q Developer 客户端都将强制用户只能使用你在 JSON 文件中列入许可名单的 MCP 服务器。

指定 MCP 注册表 URL

  1. 打开 Amazon Q 开发者版控制台。

  2. 选择设置

  3. 首选项下,选择编辑

  4. “编辑首选项” 弹出窗口中,确保模型上下文协议 (MCP) 处于开启状态。

  5. MCP 注册表 URL 字段中,输入包含列入许可名单的 MCP 服务器的 MCP 注册表 JSON 文件的 URL。

  6. 选择保存

请注意,根据我们的数据加密政策,MCP 注册表 URL 在传输过程中和静态时都经过加密

MCP 注册表文件格式

注册表 JSON 文件的格式是 MCP 注册表标准 v0.1 中服务器架构 JSON 的子集。Q Developer 支持的子集的 JSON 架构定义可在本文档末尾的注册表架构部分中找到。

下面是一个简单的、人为的 MCP 注册表文件示例,其中包含远程 (HTTP) 和本地 (stdio) MCP 服务器定义。

{ "servers": [ { "server": { "name": "my-remote-server", "title": "My server", "description": "My server description", "version": "1.0.0", "remotes": [ { "type": "streamable-http", "url": "https://acme.com/my-server", "headers": [ { "name": "X-My-Header", "value": "SomeValue" } ] } ] } }, { "server": { "name": "my-local-server", "title": "My server", "description": "My server description", "version": "1.0.0", "packages": [ { "registryType": "npm", "registryBaseUrl": "https://npm.acme.com", "identifier": "@acme/my-server", "transport": { "type": "stdio" }, "runtimeArguments": [ { "type": "positional", "value": "-q" } ], "packageArguments": [ { "type": "positional", "value": "start" } ], "environmentVariables": [ { "name": "ENV_VAR", "value": "ENV_VAR_VALUE" } ] } ] } } ] }

下表描述了注册表 JSON 文件的每个属性。除非另有说明,否则所有属性均为必填项。有关完整的 JSON 架构,请参阅注册表架构部分。

嵌套属性以与其父项的水平偏移量显示。例如,“标题” 是 “远程” 的子属性,“名称” 和 “值” 是 “标题” 的子属性。

属性 描述 可选? 示例值
常用属性
名称 服务器名称。在给定的注册表文件中必须是唯一的。 "aws-ccapi-mcp"
删除实例快照 人类可读的服务器名称。 “AWS CC API”
description 服务器的描述。 “通过自然语言管理 AWS 基础设施。”
version 服务器的版本。强烈建议使用语义版本控制 (x.y.z)。 “1.0.2”
远程 (HTTP) 服务器属性
遥控器 只有一个用于指定远程端点的条目的数组。 -
  type 必须是 “streamable-http” 或 “sse” 之一。 “streamable-http”
  url MCP 服务器端点网址。 “https://mcp.figma.com/mcp”
  headers 要包含在每个请求中的 HTTP 标头数组。 -
    名称 HTTP 标头名称。 “授权”
    值 HTTP 标头值。 “Bearer mf_9.b5f-4.1jqm”
本地 (stdio) 服务器属性
软件包 只有一个条目包含 MCP 服务器定义的数组。 -
  注册表类型

必须是 “npm”、“pypi” 或 “oci” 之一。

以下软件包运行器用于下载和运行 MCP 服务器软件包:

  • 对于注册表类型 “npm”,使用 “npx” 运行器

  • 对于 “pypi”,使用 “uvx”

  • 对于 “oci”,使用 “docker”

客户端计算机必须预先安装相应的软件包运行器。

“npm”
  registryBaseUrl Package 注册表 URL。 "https://npm.acme.com"
  identifier 服务器包标识符。 “@acme /my-server”
  传输 只有一个属性的对象,即 “类型”。 -
    type 必须是 “stdio”。 “工作室”
  运行时参数 提供给运行时的参数数组,即 npx、uvx 或 docker。 -
    type 必须是 “定位”。 “位置”
    值 运行时参数值。 “-q”
  Packagaraments 提供给 MCP 服务器的参数数组。 -
    type 必须是 “定位”。 “位置”
    值 Package 参数值。 “开始”
  环境变量 启动服务器之前要设置的环境变量数组。 -
    名称 环境变量名称。 “日志级别”
    值 环境变量值。 “信息”

提供 MCP 注册表文件

MCP 注册表 JSON 文件必须通过 HTTPS 提供。你可以随心所欲地提供这个,例如,使用 S3、Apache/nginx 等。在您的用户上运行的 Q Developer 客户端必须可以访问此 URL PCs。但是,它不必可以从 AWS 控制台进行访问,这意味着它可以专用于您的公司网络。

出于安全考虑,HTTPS 端点必须具有由可信证书颁发机构签署的有效 SSL 证书。特别是,您不能将自签名证书用于注册表端点。

Q 将在启动时定期获取 MCP 注册表(每 24 小时一次)。在定期同步期间,如果 Q 注意到注册表中不再存在本地安装的 MCP 服务器,它将终止该服务器并禁止用户将其添加回来。如果它注意到本地安装的服务器的版本与注册表中的服务器版本不同,它将使用注册表中定义的版本重新启动服务器。

Q 开发者插件

当用户启动 Q Developer 时,它将检查配置文件中是否定义了注册表 URL。如果是,它将检索该网址上的注册表 JSON,并强制用户只能使用注册表中定义的 MCP 服务器。当用户尝试添加 MCP 服务器时,他们将看到注册表中定义的服务器列表,他们可以从中进行选择。

屏幕截图显示了注册表中定义的 MCP 服务器的添加情况。

用户无法修改注册表 MCP 服务器的任何参数(URL、包标识符、runtimeArguments 等)。但是,他们仍然可以执行以下操作:

  1. 调整 MCP 工具权限(“要求运行”、“始终运行” 或 “拒绝”)。

  2. 选择 MCP 服务器作用域(全局或工作区)。

  3. 更改请求超时。

  4. 为本地 MCP 服务器指定其他环境变量。

  5. 为远程 MCP 服务器指定其他 HTTP 标头。

注意

如果用户指定了已在注册表中定义的 env var 或 HTTP 标头,则用户的定义将优先。这允许用户指定特定于其设置的属性,例如身份验证密钥或本地文件夹路径。

MCP 注册表 JSON 架构

以下是 Q Developer 支持的 MCP 注册表 JSON 文件的 JSON 架构定义。您可以使用此架构来验证您创建的任何注册表文件。

{ "$schema": "https://json-schema.org/draft-07/schema", "properties": { "servers": { "type": "array", "items": { "type": "object", "properties": { "server": { "$ref": "#/definitions/ServerDetail" } }, "required": [ "server" ] } } }, "definitions": { "ServerDetail": { "properties": { "name": { "description": "Server name. Must be unique within a given registry file.", "example": "weather-mcp", "maxLength": 200, "minLength": 3, "pattern": "^[a-zA-Z0-9._-]+$", "type": "string" }, "title": { "description": "Optional human-readable title or display name for the MCP server. MCP subregistries or clients MAY choose to use this for display purposes.", "example": "Weather API", "maxLength": 100, "minLength": 1, "type": "string" }, "description": { "description": "Clear human-readable explanation of server functionality. Should focus on capabilities, not implementation details.", "example": "MCP server providing weather data and forecasts via OpenWeatherMap API", "maxLength": 100, "minLength": 1, "type": "string" }, "version": { "description": "Version string for this server. SHOULD follow semantic versioning (e.g., '1.0.2', '2.1.0-alpha'). Equivalent of Implementation.version in MCP specification. Non-semantic versions are allowed but may not sort predictably. Version ranges are rejected (e.g., '^1.2.3', '~1.2.3', '\u003e=1.2.3', '1.x', '1.*').", "example": "1.0.2", "maxLength": 255, "type": "string" }, "packages": { "items": { "$ref": "#/definitions/Package" }, "type": "array" }, "remotes": { "items": { "anyOf": [ { "$ref": "#/definitions/StreamableHttpTransport" }, { "$ref": "#/definitions/SseTransport" } ] }, "type": "array" } }, "required": [ "name", "description", "version" ], "type": "object" }, "Package": { "properties": { "registryType": { "description": "Registry type indicating how to download packages (e.g., 'npm', 'pypi', 'oci')", "enum": [ "npm", "pypi", "oci" ], "type": "string" }, "registryBaseUrl": { "description": "Base URL of the package registry", "examples": [ "https://registry.npmjs.org", "https://pypi.org", "https://docker.io" ], "format": "uri", "type": "string" }, "identifier": { "description": "Package identifier - either a package name (for registries) or URL (for direct downloads)", "examples": [ "@modelcontextprotocol/server-brave-search", "https://github.com/example/releases/download/v1.0.0/package.mcpb" ], "type": "string" }, "transport": { "anyOf": [ { "$ref": "#/definitions/StdioTransport" }, { "$ref": "#/definitions/StreamableHttpTransport" }, { "$ref": "#/definitions/SseTransport" } ], "description": "Transport protocol configuration for the package" }, "runtimeArguments": { "description": "A list of arguments to be passed to the package's runtime command (such as docker or npx).", "items": { "$ref": "#/definitions/PositionalArgument" }, "type": "array" }, "packageArguments": { "description": "A list of arguments to be passed to the package's binary.", "items": { "$ref": "#/definitions/PositionalArgument" }, "type": "array" }, "environmentVariables": { "description": "A mapping of environment variables to be set when running the package.", "items": { "$ref": "#/definitions/KeyValueInput" }, "type": "array" } }, "required": [ "registryType", "identifier", "transport" ], "type": "object" }, "StdioTransport": { "properties": { "type": { "description": "Transport type", "enum": [ "stdio" ], "example": "stdio", "type": "string" } }, "required": [ "type" ], "type": "object" }, "StreamableHttpTransport": { "properties": { "type": { "description": "Transport type", "enum": [ "streamable-http" ], "example": "streamable-http", "type": "string" }, "url": { "description": "URL template for the streamable-http transport. Variables in {curly_braces} reference argument valueHints, argument names, or environment variable names. After variable substitution, this should produce a valid URI.", "example": "https://api.example.com/mcp", "type": "string" }, "headers": { "description": "HTTP headers to include", "items": { "$ref": "#/definitions/KeyValueInput" }, "type": "array" } }, "required": [ "type", "url" ], "type": "object" }, "SseTransport": { "properties": { "type": { "description": "Transport type", "enum": [ "sse" ], "example": "sse", "type": "string" }, "url": { "description": "Server-Sent Events endpoint URL", "example": "https://mcp-fs.example.com/sse", "format": "uri", "type": "string" }, "headers": { "description": "HTTP headers to include", "items": { "$ref": "#/definitions/KeyValueInput" }, "type": "array" } }, "required": [ "type", "url" ], "type": "object" }, "PositionalArgument": { "properties": { "value": { "description": "The value for the input.", "type": "string" } }, "required": [ "value" ], "type": "object" }, "KeyValueInput": { "properties": { "name": { "description": "Name of the header or environment variable.", "example": "SOME_VARIABLE", "type": "string" }, "value": { "description": "The value for the input.", "type": "string" } }, "required": [ "name" ], "type": "object" } }, "required": [ "servers" ], "type": "object" }