Procházet zdrojové kódy

docs(mcp): explain resource providers and server instructions

Tianyi Cui před 5 dny
rodič
revize
aec2d5e5f0

+ 2 - 2
docs/subsystems/README.i18n.yaml

@@ -2,5 +2,5 @@
 # side as of the last confirmed-consistent state. Both languages carry equal authority;
 # after editing either side, bring the other along and re-record with:
 #   pnpm run verify-translation-pairing --write docs/subsystems/README.md
-README.md: 747adf38db3584dda29c0a63309efa6f2fcebff1
-README.zh.md: 405c4bd0213f7cee03ed16b41e4a79090456d86b
+README.md: 88b2c85c2a02c98c57c3dd9075cec7d7dcd5ea9f
+README.zh.md: 5527ff47c951594a99d01498548f17e726c2c095

+ 1 - 1
docs/subsystems/README.md

@@ -25,7 +25,7 @@ One page per subsystem of the DeepSeek Harness: what it is, the data structures
 | [session-reference.md](session-reference.md) | structured cross-session references: `SessionReferenceInput`/`Candidate`, prepared message contexts, the stable error taxonomy |
 | [system-prompt.md](system-prompt.md) | per-assembly context, tool-provider results, prompt sections, and cooperative assembly |
 | [tools.md](tools.md) | `ToolDefinition` full fields, the schema DSL, `ToolExecution`/`ToolResult`, tool-presentation UI types, and the guarded execution pipeline |
-| [mcp.md](mcp.md) | external MCP connections, scoped tool registration, protocol negotiation, result adaptation, and configuration ownership |
+| [mcp.md](mcp.md) | external MCP connections, scoped tools and resources, server instructions, protocol results, and configuration ownership |
 | [user-questions.md](user-questions.md) | the UI-backed human question/answer seam: `AskUserQuestionRequest`, answer/options vocabulary, provider API, error taxonomy |
 | [approval.md](approval.md) | the one-shot user-approval seam: `ApprovalRequest`, `ApprovalOutcome`, per-session policy, audit events, and answerer contracts |
 | [attachment.md](attachment.md) | durable image identity and metadata, validation inputs, verified reads, and the `AttachmentStore` seam |

+ 1 - 1
docs/subsystems/README.zh.md

@@ -25,7 +25,7 @@
 | [session-reference.md](session-reference.zh.md) | 结构化跨会话引用:`SessionReferenceInput`/`Candidate`、prepared 消息上下文、稳定错误分类 |
 | [system-prompt.md](system-prompt.zh.md) | 逐次组装的上下文、工具提供方结果、提示词段落与协作式组装 |
 | [tools.md](tools.zh.md) | `ToolDefinition` 完整字段、schema DSL、`ToolExecution`/`ToolResult`、工具展示 UI 类型,以及受保护的执行流水线 |
-| [mcp.md](mcp.zh.md) | 外部 MCP 连接、作用域工具注册、协议协商、结果适配与配置归属 |
+| [mcp.md](mcp.zh.md) | 外部 MCP 连接、作用域工具与资源、服务器指令、协议结果与配置归属 |
 | [user-questions.md](user-questions.zh.md) | UI 支持的人工问答 seam:`AskUserQuestionRequest`、answer/options 词汇、提供方 API、错误分类体系 |
 | [approval.md](approval.zh.md) | 一次性用户审批 seam:`ApprovalRequest`、`ApprovalOutcome`、逐会话策略、审计事件和 answerer 约定 |
 | [attachment.md](attachment.zh.md) | 持久图片标识与元数据、校验输入、经校验读取,以及 `AttachmentStore` seam |

+ 2 - 2
docs/subsystems/mcp.i18n.yaml

@@ -2,5 +2,5 @@
 # side as of the last confirmed-consistent state. Both languages carry equal authority;
 # after editing either side, bring the other along and re-record with:
 #   pnpm run verify-translation-pairing --write docs/subsystems/mcp.md
-mcp.md: d2b659a5d39ea11269d7b471f11a25423d315014
-mcp.zh.md: 3d092a952c88b47ec539018ea60d754b8a3b9078
+mcp.md: e9c41f32d320cdd4d1efb7c6bf0f2038d858b665
+mcp.zh.md: 0c72ab43f678c118a487a3eb093f60450244114e

+ 19 - 2
docs/subsystems/mcp.md

@@ -4,13 +4,14 @@ English | [中文](mcp.zh.md)
 
 ## Summary
 
-Model Context Protocol (MCP) connects the model to tools supplied by external servers. Each configured server contributes ordinary harness tools with cancellation, permission checks, recorded results, and supported image output. The official SDK negotiates modern or supported legacy protocol revisions. This reference covers the MCP package group's responsibilities, scope, and composition choices; the [client README](../../packages/mcp/mcp-client/README.md) owns server configuration.
+Model Context Protocol (MCP) connects the model to tools supplied by external servers. Each configured server contributes ordinary harness tools with cancellation, permission checks, recorded results, and supported image output. Optional shared tools discover and read resources, while server instructions join the logged system prompt. The official SDK negotiates modern or supported legacy protocol revisions. This reference covers the MCP package group's responsibilities, scope, and composition choices; the [client README](../../packages/mcp/mcp-client/README.md) owns server configuration.
 
 ## Table of Contents
 
 - [Configuration](#configuration)
 - [Responsibilities and scope](#responsibilities-and-scope)
 - [Protocol and results](#protocol-and-results)
+- [Resources and instructions](#resources-and-instructions)
 - [Limits](#limits)
 - [Further reading](#further-reading)
 
@@ -25,6 +26,8 @@ MCP is opt-in. Mount one `@deepseek-ai/dsh-mcp-client` entry for each server in
 |---|---|
 | Server identity, local process or HTTP endpoint, credentials, and process environment | [Client configuration](../../packages/mcp/mcp-client/README.md#use-this-package) |
 | Tool-call timeout, startup failure policy, and reconnection | [Client configuration](../../packages/mcp/mcp-client/README.md#use-this-package) |
+| Resource discovery and reading | Mount the [MCP resource service](../../packages/mcp/mcp-resources/README.md#use-this-package); it has no configuration fields |
+| Server instruction size limit | Client `maxInstructionBytes`; the composition supplies [system-prompt assembly](system-prompt.md) |
 | Permission decisions and supported image output | [Tool execution](tools.md) and [attachments](attachment.md) |
 
 Protocol negotiation follows the SDK's supported revisions; there is no product setting that forces a protocol revision. The [configuration catalog](../config-catalog.md#deepseek-aidsh-mcp-client) lists accepted client fields and defaults.
@@ -36,6 +39,8 @@ Protocol negotiation follows the SDK's supported revisions; there is no product
 
 The client is a per-server connection plugin and a consumer of the harness tool registry. It does not publish a shared `ctx.mcp` service. The external server implements MCP operations; the SDK owns protocol exchange; the client adapts discovered tools to harness execution.
 
+`mcp-resources` is an optional shared service and tool consumer. It defines the resource-provider interface, selects providers in the caller's scope, and registers one shared set of resource tools. Each MCP client provides resource operations through its own connection. Mounting the resource service does not create connections or change which servers are configured.
+
 Configured `serverName` identifies a server in its registration scope. Two entries in that scope cannot reserve the same name; separate Agent scopes can reuse it. Public tool names include the configured server name, so equally named tools from different servers remain distinct. Registration effects own names and discovered tools; plugin disposal closes the connection and removes its contributions.
 
 The [native Cua Driver provider](../../packages/experimental/computer-use-cua-driver-native/README.md) shares the client's exported result adapter without opening an MCP connection. Desktop provider selection belongs to the [computer-use subsystem](computer-use.md).
@@ -51,10 +56,21 @@ The result adapter retains canonical MCP JSON for programmatic callers and prepa
 
 -----
 
+<a id="resources-and-instructions"></a>
+## Resources and instructions
+
+Resource calls require an explicit configured server name. The shared registry resolves that name in the calling Agent's scope before dispatch; unavailable servers fail without a network request. Discovery and reads are on demand, including for servers that expose resources without tools. The [resource package](../../packages/mcp/mcp-resources/README.md) owns pagination and content rendering; its generated tool schemas live in the [tool catalog](../tool-catalog.md#deepseek-aidsh-mcp-resources).
+
+Resource providers remain connection-owned. Scope disposal removes registrations; the MCP client controls cancellation and recovery. Canonical results retain complete JSON for programmatic callers, while the text projection replaces binary blobs with descriptions. Returned text enters ordinary tool history; content is not fetched merely because a server connects.
+
+When system-prompt assembly is composed, the client publishes nonblank server instructions as a scoped, server-attributed section. Instructions remain literal text and pass the configured size limit before publication. A replacement connection publishes instructions only after discovery succeeds; absent instructions add no section. The [system-prompt subsystem](system-prompt.md) owns assembly and recording.
+
+-----
+
 <a id="limits"></a>
 ## Limits
 
-This composition exposes server tools. It does not expose MCP resources, server instructions, prompt templates, human-input elicitation, or task-based execution. Servers without a tools capability connect with an empty tool set. Connection and discovery timeouts follow the SDK; the client has no separate settings for them.
+MCP prompt templates, human-input elicitation, task-based execution, and resource subscriptions are unsupported. Resource access requires the optional resource service; binary resources remain programmatic data with text descriptions for the model. Servers without a tools capability connect with an empty tool set. Connection and discovery timeouts follow the SDK; the client has no separate settings for them.
 
 -----
 
@@ -62,6 +78,7 @@ This composition exposes server tools. It does not expose MCP resources, server
 ## Further reading
 
 - [MCP package group](../../packages/mcp/README.md) — package entry points.
+- [MCP resources](../../packages/mcp/mcp-resources/README.md) — shared tools and resource-provider semantics.
 - [Third-party memory servers](../user/guide/mcp-memory.md) — product configuration guide.
 - [Protocol negotiation decision](../../.agents/notes/implemented/feature/2026-09-12-mcp-sdk-protocol-negotiation.md) — SDK ownership and compatibility decisions.
 

+ 19 - 2
docs/subsystems/mcp.zh.md

@@ -4,13 +4,14 @@
 
 ## 摘要
 
-模型上下文协议(Model Context Protocol,MCP)让模型使用外部服务器提供的工具。每个已配置服务器都会提供普通 Harness 工具,支持取消、权限检查、结果记录和受支持的图像输出。官方 SDK 协商现代或受支持的旧版协议。本参考页介绍 MCP 包组的职责、作用域和组合选择;服务器配置由[客户端 README](../../packages/mcp/mcp-client/README.zh.md) 维护。
+模型上下文协议(Model Context Protocol,MCP)让模型使用外部服务器提供的工具。每个已配置服务器都会提供普通 Harness 工具,支持取消、权限检查、结果记录和受支持的图像输出。可选的共享工具负责发现和读取资源,服务器指令则加入已记录的系统提示词。官方 SDK 协商现代或受支持的旧版协议。本参考页介绍 MCP 包组的职责、作用域和组合选择;服务器配置由[客户端 README](../../packages/mcp/mcp-client/README.zh.md) 维护。
 
 ## 目录
 
 - [配置](#configuration)
 - [职责与作用域](#responsibilities-and-scope)
 - [协议与结果](#protocol-and-results)
+- [资源与指令](#resources-and-instructions)
 - [限制](#limits)
 - [延伸阅读](#further-reading)
 
@@ -25,6 +26,8 @@ MCP 需要显式启用。在目标 Cordis 作用域中,为每个服务器挂
 |---|---|
 | 服务器身份、本地进程或 HTTP 端点、凭据和进程环境 | [客户端配置](../../packages/mcp/mcp-client/README.zh.md#use-this-package) |
 | 工具调用超时、启动失败策略和重连 | [客户端配置](../../packages/mcp/mcp-client/README.zh.md#use-this-package) |
+| 资源发现与读取 | 挂载 [MCP 资源服务](../../packages/mcp/mcp-resources/README.zh.md#use-this-package);该服务没有配置字段 |
+| 服务器指令大小限制 | 客户端 `maxInstructionBytes`;组合提供[系统提示词装配](system-prompt.zh.md) |
 | 权限决策和受支持的图像输出 | [工具执行](tools.zh.md)和[附件](attachment.zh.md) |
 
 协议协商遵循 SDK 支持的修订版;产品没有强制指定协议修订版的设置。[配置目录](../config-catalog.zh.md#deepseek-aidsh-mcp-client) 列出客户端接受的字段和默认值。
@@ -36,6 +39,8 @@ MCP 需要显式启用。在目标 Cordis 作用域中,为每个服务器挂
 
 客户端是每服务器一个的连接插件,也是 Harness 工具注册表的消费者。它不发布共享的 `ctx.mcp` 服务。外部服务器实现 MCP 操作;SDK 拥有协议交换;客户端将发现的工具适配到 Harness 执行过程。
 
+`mcp-resources` 是可选的共享服务和工具消费者。它定义资源提供方接口,在调用方作用域中选择提供方,并注册一组共享资源工具。每个 MCP 客户端通过自己的连接提供资源操作。挂载资源服务不会创建连接,也不会改变配置的服务器。
+
 配置的 `serverName` 在注册作用域内标识服务器。同一作用域中的两个条目不能占用相同名称;不同 Agent 作用域可以复用该名称。公开工具名包含配置的服务器名称,因此不同服务器的同名工具仍可区分。注册副作用拥有名称和已发现工具;插件释放时关闭连接并移除其贡献。
 
 [原生 Cua Driver 提供方](../../packages/experimental/computer-use-cua-driver-native/README.zh.md) 复用客户端导出的结果适配器,无需打开 MCP 连接。桌面提供方选择属于[计算机使用子系统](computer-use.zh.md)。
@@ -51,10 +56,21 @@ stdio 和 Streamable HTTP 都使用官方 SDK 的协商、发现、协议校验
 
 -----
 
+<a id="resources-and-instructions"></a>
+## 资源与指令
+
+资源调用必须显式指定配置的服务器名称。共享注册表在分发前,于调用 Agent 的作用域中解析该名称;不可用的服务器会在发出网络请求前失败。发现和读取均按需执行,也支持只提供资源而不提供工具的服务器。[资源包](../../packages/mcp/mcp-resources/README.zh.md) 维护分页和内容渲染规则;其生成的工具 schema 位于[工具目录](../tool-catalog.zh.md#deepseek-aidsh-mcp-resources)。
+
+资源提供方仍由连接拥有。作用域释放时移除注册;MCP 客户端控制取消和恢复。规范结果为程序化调用方保留完整 JSON,文本投影则以描述替换二进制 blob。返回的文本进入普通工具历史;服务器连接本身不会触发内容读取。
+
+组合包含系统提示词装配时,客户端将非空白的服务器指令发布为带服务器归属的作用域章节。指令保持字面文本,并在发布前通过配置的大小限制。替换连接仅在发现成功后发布指令;缺少指令时不添加章节。[系统提示词子系统](system-prompt.zh.md) 维护装配与记录规则。
+
+-----
+
 <a id="limits"></a>
 ## 限制
 
-该组合提供服务器工具,不提供 MCP 资源、服务器指令、提示词模板、人工输入征询或基于任务的执行。没有工具能力的服务器以空工具集连接。连接和发现超时遵循 SDK;客户端没有对应的独立设置。
+不支持 MCP 提示词模板、人工输入征询、基于任务的执行和资源订阅。资源访问需要可选的资源服务;二进制资源保留为程序化数据,模型接收其文本描述。没有工具能力的服务器以空工具集连接。连接和发现超时遵循 SDK;客户端没有对应的独立设置。
 
 -----
 
@@ -62,6 +78,7 @@ stdio 和 Streamable HTTP 都使用官方 SDK 的协商、发现、协议校验
 ## 延伸阅读
 
 - [MCP 包组](../../packages/mcp/README.zh.md) — 包入口。
+- [MCP 资源](../../packages/mcp/mcp-resources/README.zh.md) — 共享工具与资源提供方语义。
 - [第三方记忆服务器](../user/guide/mcp-memory.zh.md) — 产品配置指南。
 - [协议协商决策](../../.agents/notes/implemented/feature/2026-09-12-mcp-sdk-protocol-negotiation.zh.md) — SDK 职责与兼容性决策。