Skip to content

Rename Enabled transform to Visibility#2950

Merged
jlowin merged 3 commits intomainfrom
jlowin/rename-enabled-to-visibility
Jan 20, 2026
Merged

Rename Enabled transform to Visibility#2950
jlowin merged 3 commits intomainfrom
jlowin/rename-enabled-to-visibility

Conversation

@jlowin
Copy link
Copy Markdown
Member

@jlowin jlowin commented Jan 20, 2026

The Enabled class name was awkward—it describes a state rather than the concept being controlled. Renaming to Visibility makes the API clearer since the transform controls which components are visible to clients.

from fastmcp.server.transforms import Visibility

# Hide components tagged "internal"
mcp.add_transform(Visibility(False, tags={"internal"}))

# Session-level visibility control
await ctx.reset_visibility()  # was reset_components()

The enable() and disable() methods on servers/contexts remain unchanged—those are action verbs that still make sense.

The class name `Enabled` was confusing because it described a state rather
than the concept being controlled. `Visibility` better expresses what the
transform does: control which components are visible to clients.

- Class: Enabled → Visibility
- File: enabled.py → visibility.py
- Context method: reset_components() → reset_visibility()
- Internal metadata key: "enabled" → "visibility"
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jan 20, 2026

Warning

Rate limit exceeded

@jlowin has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 7 minutes and 24 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 3ea9289 and 081223f.

📒 Files selected for processing (1)
  • docs/development/v3-notes/v3-features.mdx

Walkthrough

This pull request performs a comprehensive terminology refactor across the codebase, renaming the "Enabled" system to "Visibility" throughout. The changes rename the Enabled class to Visibility, update method signatures such as reset_components() to reset_visibility() and create_enabled_transforms() to create_visibility_transforms(), and update import paths from fastmcp.server.transforms.enabled to fastmcp.server.transforms.visibility. The refactor spans source code in src/fastmcp/server/, documentation files in docs/, and examples, with corresponding updates to docstrings, references, and exports across all affected modules.

Possibly related PRs

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately and concisely summarizes the main change: renaming the Enabled transform to Visibility, which is the primary objective throughout the pull request.
Description check ✅ Passed The PR description clearly explains the rationale for the change and provides concrete usage examples, though the author-provided description does not follow the repository's template format with contributor and review checklists.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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


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.

@marvin-context-protocol marvin-context-protocol Bot added enhancement Improvement to existing functionality. For issues and smaller PR improvements. breaking change Breaks backward compatibility. Requires minor version bump. Critical for maintainer attention. server Related to FastMCP server implementation or server-side functionality. labels Jan 20, 2026
@jlowin
Copy link
Copy Markdown
Member Author

jlowin commented Jan 20, 2026

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jan 20, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
docs/development/v3-notes/v3-features.mdx (1)

296-303: Inconsistent method reference: reset_components() should be reset_visibility().

Line 299 still references reset_components() in the method list, but the example on line 289 correctly uses reset_visibility(). This inconsistency should be fixed for documentation accuracy.

📝 Proposed fix
 Session visibility methods:
 - `await ctx.enable_components(...)`: Enable components for this session
 - `await ctx.disable_components(...)`: Disable components for this session
-- `await ctx.reset_components()`: Clear session rules, return to global defaults
+- `await ctx.reset_visibility()`: Clear session rules, return to global defaults
🧹 Nitpick comments (3)
docs/python-sdk/fastmcp-server-server.mdx (1)

1-4: Add description field to frontmatter.

As per coding guidelines, MDX documentation pages must include both title and description in the YAML frontmatter.

Suggested fix
 ---
 title: server
 sidebarTitle: server
+description: API reference for the FastMCP server module, including server configuration, tools, resources, prompts, and transforms.
 ---
src/fastmcp/server/transforms/__init__.py (1)

223-223: Consider removing the unused noqa directive.

Static analysis indicates the # noqa: E402 comment may be unnecessary. The E402 rule (module-level import not at top of file) might not be triggering here. Consider removing it if it's no longer needed.

♻️ Suggested fix
-from fastmcp.server.transforms.visibility import Visibility, is_enabled  # noqa: E402
+from fastmcp.server.transforms.visibility import Visibility, is_enabled
src/fastmcp/server/transforms/visibility.py (1)

92-109: Align __repr__ output with boolean constructor values.

__repr__ currently emits Visibility(enable, ...) for most cases but Visibility(True, match_all=True) for match_all. Using booleans everywhere better mirrors the constructor and examples.

♻️ Proposed update for consistent repr output
-        action = "enable" if self._enabled else "disable"
+        enabled = self._enabled
         if self.match_all:
-            return f"Visibility({self._enabled}, match_all=True)"
+            return f"Visibility({enabled}, match_all=True)"
         parts = []
         if self.names:
             parts.append(f"names={set(self.names)}")
@@
         if self.tags:
             parts.append(f"tags={set(self.tags)}")
         if parts:
-            return f"Visibility({action}, {', '.join(parts)})"
-        return f"Visibility({action})"
+            return f"Visibility({enabled}, {', '.join(parts)})"
+        return f"Visibility({enabled})"

Comment on lines +292 to 294
Adds a visibility transform that marks matching components as disabled.
Components can be re-enabled by calling enable() with matching criteria
(the later transform wins).
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

find . -name "base.py" -type f | grep -E "(fastmcp|server.*provider)" | head -20

Repository: jlowin/fastmcp

Length of output: 263


🏁 Script executed:

git ls-files | grep -E "fastmcp.*base\.py|server.*providers.*base\.py"

Repository: jlowin/fastmcp

Length of output: 346


🏁 Script executed:

fd "base.py" --type f

Repository: jlowin/fastmcp

Length of output: 346


🏁 Script executed:

cat -n src/fastmcp/server/providers/base.py | head -350

Repository: jlowin/fastmcp

Length of output: 15488


🏁 Script executed:

wc -l src/fastmcp/server/providers/base.py

Repository: jlowin/fastmcp

Length of output: 98


🏁 Script executed:

rg -n -B2 -A5 'def enable\(' src/fastmcp/server/providers/base.py

Repository: jlowin/fastmcp

Length of output: 332


🏁 Script executed:

rg -n -B2 -A5 'def disable\(' src/fastmcp/server/providers/base.py

Repository: jlowin/fastmcp

Length of output: 273


🏁 Script executed:

sed -n '492,538p' src/fastmcp/server/providers/base.py

Repository: jlowin/fastmcp

Length of output: 1897


🏁 Script executed:

sed -n '541,578p' src/fastmcp/server/providers/base.py

Repository: jlowin/fastmcp

Length of output: 1471


🏁 Script executed:

cat -n docs/python-sdk/fastmcp-server-providers-base.mdx | sed -n '260,300p'

Repository: jlowin/fastmcp

Length of output: 1891


Update enable() documentation to match disable() and source code

The disable() change is correct, but the documentation for enable() at line 264 needs updating. The source code docstring for enable() says "Adds a visibility transform" (matching disable()), but the documentation still shows "Adds an enabled transform". Change line 264 from "Adds an enabled transform" to "Adds a visibility transform" for consistency with both the source and the disable() method.

@jlowin jlowin merged commit 0e4d519 into main Jan 20, 2026
11 checks passed
@jlowin jlowin deleted the jlowin/rename-enabled-to-visibility branch January 20, 2026 01:46
@jlowin jlowin removed the breaking change Breaks backward compatibility. Requires minor version bump. Critical for maintainer attention. label Jan 20, 2026
gfortaine pushed a commit to gfortaine/fastmcp that referenced this pull request Jan 30, 2026
gfortaine pushed a commit to gfortaine/fastmcp that referenced this pull request Feb 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement Improvement to existing functionality. For issues and smaller PR improvements. server Related to FastMCP server implementation or server-side functionality.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant