Skip to content
This repository was archived by the owner on May 15, 2026. It is now read-only.
This repository was archived by the owner on May 15, 2026. It is now read-only.

[ENHANCEMENT] Per-Mode MCP Server Restrictions (Whitelist/Blacklist) to Prevent Context Bloat #12004

Open

Description

@simurg79

Problem (one or two sentences)

Currently, Roo Code lacks the ability to restrict which MCP servers are loaded on a per-mode basis. If a custom mode includes the "mcp" permission in its tool groups, Roo Code injects the descriptions and schemas for all globally and project-enabled MCP servers directly into the system prompt.

This brute-force approach causes severe issues:

Context Bloat: Dumping massive tool schemas into the prompt wastes thousands of tokens per request and degrades the model's reasoning capabilities.

Hard Tool Limits: Strict tool limits on modern models (e.g., the 128-tool limit) are easily exhausted when running multiple robust MCP servers simultaneously, causing API calls to outright fail.

Lack of Isolation: Specialized modes (e.g., a pure "Database Mode" or "Documentation Mode") get polluted with unrelated development tools, breaking the single-responsibility principle of Custom Modes.

Context (who is affected and when)

Happens for me when I want to use GPT5.4 which has a tool limit of 128.

Desired behavior (conceptual, not technical)

I would like the ability to explicitly whitelist or blacklist specific MCP servers within a custom mode's configuration (via .roomodes or the Custom Mode UI).

For example, adding an allowed_mcps or blocked_mcps array to the mode definition:

JSON
{
"customModes": [
{
"slug": "database-architect",
"name": "Database Architect",
"roleDefinition": "You manage the database schema...",
"groups": ["read", "edit", "mcp"],
"allowed_mcps": ["postgres-mcp", "redis-mcp"]
}
]
}
If allowed_mcps is defined, Roo Code should only inject the schemas for those specific servers into the system prompt for that mode, ignoring all other enabled MCPs.

Constraints / preferences (optional)

No response

Request checklist

  • I've searched existing Issues and Discussions for duplicates
  • This describes a specific problem with clear context and impact

Roo Code Task Links (optional)

No response

Acceptance criteria (optional)

No response

Proposed approach (optional)

No response

Trade-offs / risks (optional)

No response

Activity

  1. simurg79 commented on Mar 27, 2026

    @simurg79
    Author

    @roomote , I approve this plan. This is exactly what I need and it will be great help. Allowlisting (aka whitelisting) is enoug which mean by default value of allowedMcpServers is * or all. * or all can be interpreted as the default behavior.

  2. ghost added a commit that references this issue on Mar 27, 2026
    27b4b30
  3. aak204 commented on Apr 13, 2026

    @aak204

    Totally agree with this request. Once a mode pulls in every server schema, you lose both the mode boundary and hit the 128-tool limit fast.
    As a temporary workaround until Roo gets native per-mode allowlists, I built an OSS compiler/gateway (toolc). You can feed it your existing MCP configs, and it compiles them into a smaller, filtered surface. This way, your mode points to one reduced endpoint instead of inheriting the whole noisy tool zoo.
    Repo: https://github.com/aak204/Tool-Catalog-Compiler

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    EnhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions