Skip to content

Fix include_tags/exclude_tags ignored without tools in MCPConfig#3186

Merged
jlowin merged 2 commits intomainfrom
fix/config-include-tags-single-server
Feb 14, 2026
Merged

Fix include_tags/exclude_tags ignored without tools in MCPConfig#3186
jlowin merged 2 commits intomainfrom
fix/config-include-tags-single-server

Conversation

@jlowin
Copy link
Copy Markdown
Member

@jlowin jlowin commented Feb 13, 2026

Closes #3177.

When a server config in mcpServers used include_tags or exclude_tags without also specifying tools, the tags were silently ignored. The config parsed as a plain RemoteMCPServer/StdioMCPServer (which absorb unknown fields via extra="allow") instead of the Transforming* variant that actually applies tag filtering.

The fix makes tools optional in _TransformingMCPServerMixin (defaulting to {}) and adds a model validator that requires at least one of tools, include_tags, or exclude_tags to be present — so plain configs still parse as base types, but any config with transform-related fields gets the right type:

config = {
    "mcpServers": {
        "my_server": {
            "url": "http://localhost:8003/mcp",
            "include_tags": ["production"],  # now works without "tools"
        }
    }
}

async with Client(config) as client:
    tools = await client.list_tools()  # only tools tagged "production"

@jlowin jlowin added bug Something isn't working. Reports of errors, unexpected behavior, or broken functionality. client Related to the FastMCP client SDK or client-side functionality. fastmcp.json Functionality related to fastmcp.json or FastMCPConfig files. labels Feb 13, 2026
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Feb 13, 2026

Walkthrough

The pull request includes documentation link updates and introduces validation logic for MCP server transformation configurations. In src/fastmcp/mcp_config.py, the _TransformingMCPServerMixin class is updated with a new pre-validation method that enforces at least one of the transform fields (tools, include_tags, or exclude_tags) to be provided when using this mixin. The tools field signature is also updated to use Field(default_factory=dict) for initialization. These changes ensure that transformation configurations cannot be created with empty or unspecified transform parameters.

🚥 Pre-merge checks | ✅ 6
✅ Passed checks (6 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main change: fixing the bug where include_tags/exclude_tags were ignored when tools were not specified in MCPConfig.
Description check ✅ Passed The description adequately covers the issue (references #3177), explains the root cause, describes the fix, and provides a concrete example demonstrating the corrected behavior.
Linked Issues check ✅ Passed The code changes directly address the requirements in #3177 by making tools optional with a default empty dict and adding a validator to ensure transform fields are properly recognized, enabling tag filtering without requiring explicit tools.
Out of Scope Changes check ✅ Passed All changes are within scope: the mcp_config.py modifications implement the fix for the linked issue, and the documentation link updates are standard maintenance for consistency.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Merge Conflict Detection ✅ Passed ✅ No merge conflicts detected when merging into main

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/config-include-tags-single-server

No actionable comments were generated in the recent review. 🎉


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@jlowin jlowin merged commit ccfe504 into main Feb 14, 2026
14 checks passed
@jlowin jlowin deleted the fix/config-include-tags-single-server branch February 14, 2026 01:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working. Reports of errors, unexpected behavior, or broken functionality. client Related to the FastMCP client SDK or client-side functionality. fastmcp.json Functionality related to fastmcp.json or FastMCPConfig files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

include_tags not work in the mcp.json format where you can transform an MCP server in the json

1 participant