feat(mcp): model-facing resource tools with paginated list/read/templates (RFC-0058) - #385
Open
ykf173 wants to merge 6 commits into
Open
feat(mcp): model-facing resource tools with paginated list/read/templates (RFC-0058)#385ykf173 wants to merge 6 commits into
ykf173 wants to merge 6 commits into
Conversation
Collaborator
PR 质量问题
与已合入 PR #372 的功能重叠PR #372(RFC-0058: Unified MCP Server Registration)已合入 main,实现了统一的 MCP 资源注册和访问。本 PR 与 #372 在 7 个文件上重叠:
与 PR #383 的高度重叠本 PR 与 #383(同来自 kaifeng.yan 的分支)在 18 个文件上完全重叠,疑似同一工作的不同迭代。建议合并为一个 PR。 建议
|
ykf173
force-pushed
the
feature/kaifeng.yan/unify_mcp_read_resource
branch
from
August 21, 2026 02:10
86aaeb7 to
62b848b
Compare
added 6 commits
August 21, 2026 10:44
Introduce the McpResourceProvider protocol with paginated list/read/list-templates operations, opaque host cursors, and structured resource errors, plus runtime JSON value types for MCP metadata. Extend resolve_resource_content() with an optional client_name parameter so host-injected resources resolve against the exact MCP server that advertised them, and skip servers whose initialize handshake omitted the resources capability.
Expose three model-facing tools through ResourceCapability: list_mcp_resources, list_mcp_resource_templates, and read_mcp_resource. Listings paginate with host cursors, reads truncate long text and bound binary payloads, and failures are reported as structured errors the model can act on. Wire the resource capability into AgentPool and gate it behind the per-agent resources.enabled config.
Implement the McpResourceProvider contract on McpServerCap so each connected MCP server serves paginated resource listings, template listings, and reads. ResourceEntry now carries the configured server name plus MCP metadata (title, size, annotations, meta), preserving the title-preferred display name behavior introduced in RFC-0058. Extend MCPClient and McpServerManager with the underlying paginated protocol calls.
Register every connected McpServerCap as an MCP resource provider in the ExtensionRegistry, independent of the per-agent resources.enabled gate. The gate controls only the model-facing tool surface; host catalog enumeration and ResourceSource injection stay available for protocol servers. Host catalog enumeration and ResourceSource injection use the configured server display name, keeping identical URIs from different providers isolated.
Key the experimental resource catalog by escaped server:uri instead of synthesized names, preserving the configured server name per entry, and negotiate resource support per provider so one failing server no longer discards the rest. Surface the model-facing resource tools in the OpenCode tool discovery endpoints behind the resources.enabled gate, and pass the owning server name through resource resolution so host-injected reads route to the correct provider.
ykf173
force-pushed
the
feature/kaifeng.yan/unify_mcp_read_resource
branch
from
August 21, 2026 02:44
62b848b to
9270f5c
Compare
Collaborator
Author
|
@Million-mo 已按建议修改,逐条回复如下: 1. 标题 → conventional commit已改为 2. 描述补充已在 PR description 中补充了背景、设计方案、与 #372 的增量价值说明、RFC 关联。 3. 拆分 commit原单 commit 已拆分为 6 个逻辑 conventional commit:
4. RFC / OpenSpec 关联已关联 RFC-0058,commit message 和 PR description 中均有引用。 5. 增量价值 vs #372
关于 #383:该 PR 已关闭未合入,其工作已通过 #384/#386 合入 main。本 PR 与 #383 的代码重叠属于历史遗留(同一分支的不同迭代),实际功能差异已在 rebase 后消除。目前仅 3 个文件与 #383 有代码交集(mcp_server_cap.py、agent_routes.py、test_mcp_server_cap.py),且已与 #372 的合入内容对齐。 其他修复
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Background
PR #372 (RFC-0058) unified MCP server registration for tool and resource access, establishing the
McpServerCapregistration layer at POOL scope,tool_prefix,ResourceAccessdelegation, and title-preferredlist_resources(). This PR builds on that foundation to expose the full model-facing resource tool surface to agents.What This PR Adds
Three model-facing tools in
ResourceCapability:list_mcp_resources(server=None, cursor=None, limit=50)— paginated resource listing with host cursorslist_mcp_resource_templates(server=None, cursor=None, limit=50)— paginated template listingread_mcp_resource(server, uri)— bounded resource reads with text truncation and binary size limitsKey Design Decisions
server:urikeys (resource_catalog_key()), isolating identical URIs from different MCP providersResourceEntry.nameprefers the server-providedtitleover rawname; the raw title is also preserved in its own fieldsupports_resources()filters servers that omittedresourcesin their initialize handshakelist_resources()does not discard results from other serversresources.enabledin the agent config; the host catalog endpoint is always availableIncremental Value vs #372
PR #372 established the registration infrastructure:
McpServerCapas aResourceAccessprovidertool_prefixandResourceAccessdelegationlist_resources()in the experimental catalog endpointThis PR adds the model-visible tool surface:
ResourceCapabilityimplementingMcpResourceProvider(paginated, cursor-based)ResourceSourceinjection withclient_name-scoped resolutionRelated RFCs
Commit Structure
feat(resources): paginated MCP resource provider contract— protocols, runtime types, server-qualified resolverfeat(resources): model-facing MCP resource tools in ResourceCapability— three tools, gated by resources.enabledfeat(mcp): paginated resource list/read/templates on McpServerCap— paginated implementation, ResourceEntry with server/title/metadatafeat(mcp): register MCP resource providers in ExtensionRegistry— SESSION-scope registration, independent of resources.enabledfeat(opencode): server-qualified MCP resource catalog and tool discovery— rekeyed catalog, capability negotiation, tool discoverydocs(changelog): add MCP resource integration entry