Visibility transform for marking component visibility state.Each Visibility instance marks components via internal metadata. Multiple
visibility transforms can be stacked - later transforms override earlier ones.
Final filtering happens at the Provider level.
Save visibility rule dicts to session state and send notifications.Args:
context: The context to save rules for.
rules: The visibility rules to save.
components: Optional hint about which component types are affected.
If None, sends notifications for all types (safe default).
If provided, only sends notifications for specified types.
Enable components matching criteria for this session only.Session rules override global transforms. Rules accumulate - each call
adds a new rule to the session. Later marks override earlier ones
(Visibility transform semantics).Sends notifications to this session only: ToolListChangedNotification,
ResourceListChangedNotification, and PromptListChangedNotification.Args:
context: The context for this session.
names: Component names or URIs to match.
keys: Component keys to match (e.g., ).
version: Component version spec to match.
tags: Tags to match (component must have at least one).
components: Component types to match (e.g., ).
match_all: If True, matches all components regardless of other criteria.
Disable components matching criteria for this session only.Session rules override global transforms. Rules accumulate - each call
adds a new rule to the session. Later marks override earlier ones
(Visibility transform semantics).Sends notifications to this session only: ToolListChangedNotification,
ResourceListChangedNotification, and PromptListChangedNotification.Args:
context: The context for this session.
names: Component names or URIs to match.
keys: Component keys to match (e.g., ).
version: Component version spec to match.
tags: Tags to match (component must have at least one).
components: Component types to match (e.g., ).
match_all: If True, matches all components regardless of other criteria.
Clear all session visibility rules.Use this to reset session visibility back to global defaults.Sends notifications to this session only: ToolListChangedNotification,
ResourceListChangedNotification, and PromptListChangedNotification.Args:
Apply session-specific visibility transforms to components.This helper applies session-level enable/disable rules by marking
components with their visibility state. Session transforms override
global transforms due to mark-based semantics (later marks win).Args:
components: The components to apply session transforms to.
Sets visibility state on matching components.Does NOT filter inline - just marks components with visibility state.
Later transforms in the chain can override earlier marks.
Final filtering happens at the Provider level after all transforms run.Methods: