Skip to content

Enchancements for #11971#11972

Open
dmjdarshan wants to merge 2 commits intoRooCodeInc:mainfrom
dmjdarshan:onlyallow-feature
Open

Enchancements for #11971#11972
dmjdarshan wants to merge 2 commits intoRooCodeInc:mainfrom
dmjdarshan:onlyallow-feature

Conversation

@dmjdarshan
Copy link

@dmjdarshan dmjdarshan commented Mar 21, 2026

Related GitHub Issue

Closes: #11971


Description

This PR implements the onlyAllow feature for MCP server tool configuration, allowing users to specify an allowlist of tools instead of a denylist for servers with many tools.

Key changes:

  1. Schema update (src/services/mcp/McpHub.ts): Added onlyAllow: z.array(z.string()).optional() to BaseConfigSchema with documentation explaining its precedence over disabledTools.
  2. Logic updates (src/services/mcp/McpHub.ts):
    • Modified fetchToolsList() to read onlyAllow from config and apply precedence rules: when onlyAllow is non-empty, it takes precedence over disabledTools
    • Enhanced toggleToolEnabledForPrompt() with smart config-aware logic: when onlyAllow is active, tool toggles modify the allowlist; otherwise uses existing disabledTools behavior
    • Updated updateServerToolList() signature to support "onlyAllow" as a list type
  3. Tests (src/services/mcp/__tests__/McpHub.spec.ts): Added 7 comprehensive test cases covering all scenarios:
    • 4 tests for fetchToolsList: basic allowlist filtering, precedence over disabledTools, fallback behavior, empty array handling
    • 3 tests for toggleToolEnabledForPrompt: adding/removing tools from allowlist, fallback to disabledTools when allowlist is empty

No breaking changes: Existing configurations without onlyAllow work exactly as before. Full backward compatibility maintained.


Test Procedure

Manual verification (optional):

  • Create/edit ~/.config/Roo Code/mcp.json with a test server using onlyAllow:
{
  "mcpServers": {
    "test-server": {
      "command": "npx",
      "args": ["-y", "some-mcp-server"],
      "onlyAllow": ["tool_a", "tool_b", "tool_c"]
    }
  }
}

Verify in Roo Code's MCP settings that only the listed tools are enabled for prompt use.


Pre-Submission Checklist

  • Issue Linked: This PR is linked to GitHub Issue [ENHANCEMENT] Add onlyAllow support for MCP server tools (takes precedence over disabledTools) #11971.
  • Scope: Changes are focused on adding onlyAllow support (one feature per PR).
  • Self-Review: Code reviewed; follows existing patterns in McpHub.
  • Testing: 7 new test cases added; all existing tests remain passing (5396+ total).
  • Build Verification: Code compiles successfully and bundles without errors.
  • Documentation Impact: Feature is self-documenting via schema and code comments. User-facing documentation (e.g., MCP config guide) should be updated separately if it exists.
  • Contribution Guidelines: Reviewed and agree to Contributor Guidelines.

Screenshots / Videos

N/A — backend feature with no UI changes.


Documentation Updates

No documentation updates required in this PR. However, if Roo Code maintains user-facing MCP configuration documentation, it should mention the new onlyAllow option and its precedence rules.


Additional Notes

  • Complete Implementation: Includes schema, fetch logic, and smart toggle behavior for seamless integration
  • Zero UI Changes: Feature is purely configuration-driven; existing tool enable/disable toggles continue to work via the same enabledForPrompt mechanism
  • Full Integration: All downstream tool filtering (native tools, tool validation, UI filtering) works unchanged since they rely on enabledForPrompt
  • Backward Compatibility: Old configs without onlyAllow are completely unaffected
  • Test Coverage: Comprehensive edge case coverage including empty arrays, precedence rules, and toggle behavior

Get in Touch

Discord: dmjdarshan

Interactively review PR in Roo Code Cloud

@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. Enhancement New feature or request labels Mar 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Enhancement New feature or request size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[ENHANCEMENT] Add onlyAllow support for MCP server tools (takes precedence over disabledTools)

1 participant