You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
MCP: cache resource catalogs per connection like tools and prompts #52852
OpenCode V2 sends another resources/list and resources/templates/list request for every resource catalog read, even when callers share the same live connection and the catalog has not changed. Concurrent reads multiply that traffic.
With a generic local MCP server, eight concurrent reads through Mcp.Service.resourceCatalog() and Mcp.Service.resources() produced eight requests for each list operation. One shared request per operation would be enough for that burst.
A short-lived cache of successful discovery results, with invalidation on resource-list notifications and connection teardown, would avoid these duplicate requests without keeping non-notifying servers stale indefinitely. Resource contents should still be read directly.
Plugins
No external plugins are needed for the core regression.
OpenCode version
V2 source checkout.
Steps to reproduce
The executed regression is coalesces concurrent MCP resource discovery and reuses successful catalogs in packages/core/test/mcp.test.ts in the proposed fix.
Connect to the generic local MCP server in that test.
Start eight concurrent reads, alternating resourceCatalog() and resources() on the same service.
Count the server's resource-list and template-list requests.
The unpatched implementation sent eight of each. The fix sends one of each and reuses the successful results for subsequent reads within five seconds.
Screenshot and/or share link
Not applicable. The regression checks protocol request counts.
changed the title [-]MCP resource discovery repeats identical requests on one live connection[/-][+]MCP: cache resource catalogs per connection like tools and prompts[/+]on Oct 18, 2026
Retitling to the underlying gap. Tools and prompts are already fetched once per connection and refreshed on list_changed, but resource catalogs are re-fetched from the server on every list_mcp_resources call. Resources should be cached per connection the same way, and invalidated on notifications/resources/list_changed, reconnect and session recovery.
Opened #59375 for this. It caches resource catalogs per connection and clears the cache on list_changed, reconnect and session recovery. Failed loads aren't cached.
Thanks for the detailed write-up and the test, @davdroman!
You're asking for OpenCode V2 to cache MCP resource discovery (resources/list and resources/templates/list) per connection for a short time. Concurrent and repeated reads through resourceCatalog() / resources() would then share one request, and the cache would be cleared on resource-list notifications and connection teardown. Resource contents would still be read directly.
Right now, resource catalogs are fetched live on every read by design, while tools and prompts are kept on the connection. So I'm tracking this as an improvement rather than a bug. Maintainers will consider it together with your PR.
Activity
[-]MCP resource discovery repeats identical requests on one live connection[/-][+]MCP: cache resource catalogs per connection like tools and prompts[/+]opencode-agent commentedon Oct 18, 2026
Retitling to the underlying gap. Tools and prompts are already fetched once per connection and refreshed on
list_changed, but resource catalogs are re-fetched from the server on everylist_mcp_resourcescall. Resources should be cached per connection the same way, and invalidated onnotifications/resources/list_changed, reconnect and session recovery.Messier81 commentedon Oct 26, 2026
Opened #59375 for this. It caches resource catalogs per connection and clears the cache on
list_changed, reconnect and session recovery. Failed loads aren't cached.opencodejr commentedon Oct 27, 2026
Thanks for the detailed write-up and the test, @davdroman!
You're asking for OpenCode V2 to cache MCP resource discovery (
resources/listandresources/templates/list) per connection for a short time. Concurrent and repeated reads throughresourceCatalog()/resources()would then share one request, and the cache would be cleared on resource-list notifications and connection teardown. Resource contents would still be read directly.Right now, resource catalogs are fetched live on every read by design, while tools and prompts are kept on the connection. So I'm tracking this as an improvement rather than a bug. Maintainers will consider it together with your PR.
Related:
resources/listis reported as an empty catalog. It's in the same discovery path, so it's relevant to making sure only successful results are cached