SEP-973:为实现、资源、工具和提示暴露附加元数据

SEP-973:为实现、资源、工具和提示暴露附加元数据

社区译文;来源: MCP 29affa6b

本 SEP 已达到 Final 状态,并作为已接受设计的历史记录保留。 定稿后对协议所做的更改不会反映在此处。权威要求请参阅当前规范 及其变更日志。
字段值
SEP973
标题为实现、资源、工具和提示暴露附加元数据
状态Final
类型标准跟踪
创建日期2025-07-15
作者@jesselumarie
发起人无
PR#973

摘要

本 SEP 提议新增两个可选字段:icons 和 websiteUrl。这两个字段将添加到 Implementation schema,使客户端能够直观识别第三方实现,并直接链接到其文档。icons 参数还将添加到 Tool、Resource 和 Prompt schema。虽然服务器和客户端都可以对所有实现使用这些字段,但我们预计它们最初主要用于服务器提供的实现。

动机

当前状态

当前实现只暴露带命名空间的元数据,迫使客户端显示缺少视觉提示的通用标签。

图片

提议状态

提议的实现允许添加视觉提示和文档链接,从而更容易直观识别由哪个服务器或客户端提供某项实现,例如斜杠命令界面中的工具:

图片

  • 视觉提示: 图标让用户能够立即看出当前使用的是哪个工具或资源来源。
  • 可发现性: 文档链接(websiteUrl)让客户端可以通过一次点击将用户引导到更多信息。

理由

此设计建立在 Web manifest(MDN)的既有工作之上,并整合了社区反馈:

  • 合并 PR: 将 PR #417 与 PR #862 的变更合并为一项内聚的增强。
  • 灵活的图标尺寸: 支持多种图标尺寸(例如 48x48、96x96,或用于矢量格式的 any),以适应不同客户端 UI 的需求。
  • 可选字段: 由于两个字段均为可选,现有实现仍保持完全兼容。

规范

按如下方式扩展 Implementation 对象:

/**
 * A url pointing to an icon URL or a base64-encoded data URI
 *
 * Clients that support rendering icons MUST support at least the following MIME types:
 * - image/png - PNG images (safe, universal compatibility)
 * - image/jpeg (and image/jpg) - JPEG images (safe, universal compatibility)
 *
 * Clients that support rendering icons SHOULD also support:
 * - image/svg+xml - SVG images (scalable but requires security precautions)
 * - image/webp - WebP images (modern, efficient format)
 */
export interface Icon {
  /**
   * A standard URI pointing to an icon resource.
   *
   * Consumers MUST takes steps to ensure URLs serving icons are from the
   * same domain as the client/server or a trusted domain.
   *
   * Consumers MUST take appropriate precautions when consuming SVGs as they can contain
   * executable JavaScript
   *
   * @format uri
   */
  src: string;
  /** Optional override if the server’s MIME type is missing or generic. */
  mimeType?: string;
  /** e.g. "48x48", "any" (for SVG), or "48x48 96x96" */
  sizes?: string;
}

/**
 * Describes the MCP implementation
 */
export interface Implementation extends BaseMetadata {
  version: string;
  /**
   * An optional list of icons for this implementation.
   * This can be used by clients to display the implementation in a user interface.
   * Each icon should have a `kind` property that specifies whether it is a data representation or a URL source, a `src` property that points to the icon file or data representation, and may also include a `mimeType` and `sizes` property.
   * The `mimeType` property should be a valid MIME type for the icon file, such as "image/png" or "image/svg+xml".
   * The `sizes` property should be a string that specifies one or more sizes at which the icon file can be used, such as "48x48" or "any" for scalable formats like SVG.
   * The `sizes` property is optional, and if not provided, the client should assume that the icon can be used at any size.
   */
  icons?: Icon[];
  /**
   * An optional URL of the website for this implementation.
   *
   * Consumers MUST takes steps to ensure URLs serving icons are from the
   * same domain as the client/server or a trusted domain.
   *
   * Consumers MUST take appropriate precautions when consuming SVGs as they can contain
   * executable JavaScript
   *
   * @format: uri
   */
  websiteUrl?: string;
}

使用以下类型扩展 Tool、Resource 和 Prompt 接口:

  /**
   * An optional list of icons for a resource.
   * This can be used by clients to display the resource's icon in a user interface.
   * Each icon should have a `kind` property that specifies whether it is a data representation or a URL source, a `src` property that points to the icon file or data representation, and may also include a `mimeType` and `sizes` property.
   * The `mimeType` property should be a valid MIME type for the icon file, such as "image/png" or "image/svg+xml".
   * The `sizes` property should be a string that specifies one or more sizes at which the icon file can be used, such as "48x48" or "any" for scalable formats like SVG.
   * The `sizes` property is optional, and if not provided, the client should assume that the icon can be used at any size.
   */
  icons?: Icon[];

向后兼容性

icons 和 websiteUrl 均为可选字段;忽略它们的客户端将回退到现有行为。

安全影响

这不应引入任何新的安全影响。