Skip to content

fix: include resource templates in access_mcp_resource tool filtering and description#12270

Draft
roomote-v0[bot] wants to merge 1 commit intomainfrom
fix/access-mcp-resource-templates
Draft

fix: include resource templates in access_mcp_resource tool filtering and description#12270
roomote-v0[bot] wants to merge 1 commit intomainfrom
fix/access-mcp-resource-templates

Conversation

@roomote-v0
Copy link
Copy Markdown
Contributor

@roomote-v0 roomote-v0 Bot commented May 4, 2026

Related GitHub Issue

Closes: #12269

Description

This PR attempts to address Issue #12269 where MCP resources show up in the UI but the model fails to use them. Two root causes were identified and fixed:

1. hasAnyMcpResources() ignores resource templates

The tool filtering logic in filter-tools-for-mode.ts only checked for static resources on MCP servers, not resourceTemplates. Many MCP servers expose resource templates (URI templates with parameters like orbitcity://event/details/{identifier}) rather than static resources. When a server only had resource templates, the access_mcp_resource tool was excluded from the tool list entirely, making it invisible to the model.

Fix: Updated hasAnyMcpResources() to check both server.resources and server.resourceTemplates.

2. The model has no information about available resources

Unlike MCP server tools (which each get their own native function definition via getMcpServerTools()), the access_mcp_resource tool had a static, generic description. The model had no way to know which resources or resource templates were available from connected servers, making it unable to construct valid URIs.

Fix: Made the access_mcp_resource tool description dynamic by:

  • Adding a createAccessMcpResourceTool(mcpHub?) factory function that builds the tool definition with available resource information
  • Passing mcpHub through getNativeTools() options and build-tools.ts so the description is generated at tool assembly time
  • The description now lists available resources and resource templates per server, including URIs, names, and descriptions

Test Procedure

  • Added 9 new tests in access_mcp_resource.spec.ts covering dynamic description generation (no hub, empty servers, static resources, resource templates, multiple servers, etc.)
  • Added 4 new tests in filter-tools-for-mode.spec.ts covering the hasAnyMcpResources fix (resource templates only, static resources only, no mcpHub, empty server)
  • All 28 tests pass (existing + new)
  • Lint and type checks pass

Pre-Submission Checklist

  • Issue Linked: This PR is linked to an approved GitHub Issue.
  • Scope: Changes are focused on the linked issue.
  • Self-Review: Performed a thorough self-review.
  • Testing: New tests added covering both fixes.
  • Documentation Impact: No documentation updates required.
  • Contribution Guidelines: Read and agree to the Contributor Guidelines.

Documentation Updates

  • No documentation updates are required.

Additional Notes

Feedback and guidance are welcome.

Interactively review PR in Roo Code Cloud

… and description

- Fix hasAnyMcpResources() to also check resourceTemplates, not just
  static resources. MCP servers that only expose resource templates
  (URI templates with parameters) were incorrectly excluded.
- Make access_mcp_resource tool description dynamic to include available
  resources and resource templates from connected MCP servers, giving
  the model the information it needs to construct valid resource URIs.
- Pass mcpHub through getNativeTools() and build-tools.ts so the
  dynamic description is generated at tool assembly time.
- Add comprehensive tests for both fixes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add access_mcp_resource Tool to Bob

1 participant