feat(mcp): model-facing resource tools with paginated list/read/templates (RFC-0058) - #69
Open
Million-mo wants to merge 6 commits into
Open
feat(mcp): model-facing resource tools with paginated list/read/templates (RFC-0058)#69Million-mo wants to merge 6 commits into
Million-mo wants to merge 6 commits into
Conversation
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.
51 tasks
Owner
Author
|
Owner
Author
|
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