diff --git a/mcpgateway/plugins/framework/manager.py b/mcpgateway/plugins/framework/manager.py index 2a27e669..d93cca21 100644 --- a/mcpgateway/plugins/framework/manager.py +++ b/mcpgateway/plugins/framework/manager.py @@ -428,7 +428,7 @@ async def initialize(self) -> None: loaded_count = 0 for plugin_config in plugins: - if plugin_config.mode != PluginMode.DISABLED: + if plugin_config.enabled and plugin_config.mode != PluginMode.DISABLED: try: plugin = await self._loader.load_and_instantiate_plugin(plugin_config) if plugin: @@ -441,7 +441,10 @@ async def initialize(self) -> None: logger.error(f"Failed to load plugin {plugin_config.name}: {str(e)}") raise ValueError(f"Unable to register and initialize plugin: {plugin_config.name}") from e else: - logger.debug(f"Skipping disabled plugin: {plugin_config.name}") + if not plugin_config.enabled: + logger.debug(f"Skipping disabled plugin: {plugin_config.name} (enabled=false)") + else: + logger.debug(f"Skipping disabled plugin: {plugin_config.name} (mode=disabled)") self._initialized = True logger.info(f"Plugin manager initialized with {loaded_count} plugins") diff --git a/mcpgateway/plugins/framework/models.py b/mcpgateway/plugins/framework/models.py index cec4235e..4976e2c2 100644 --- a/mcpgateway/plugins/framework/models.py +++ b/mcpgateway/plugins/framework/models.py @@ -115,6 +115,7 @@ class PluginConfig(BaseModel): version (str): version of the plugin. hooks (list[str]): a list of the hook points where the plugin will be called. tags (list[str]): a list of tags for making the plugin searchable. + enabled (bool): whether the plugin is enabled and should be loaded. mode (bool): whether the plugin is active. priority (int): indicates the order in which the plugin is run. Lower = higher priority. conditions (Optional[list[PluginCondition]]): the conditions on which the plugin is run. @@ -130,6 +131,7 @@ class PluginConfig(BaseModel): version: str hooks: list[HookType] tags: list[str] + enabled: bool = True # Default to enabled for backward compatibility mode: PluginMode = PluginMode.ENFORCE priority: int = 100 # Lower = higher priority conditions: Optional[list[PluginCondition]] = None # When to apply diff --git a/plugins/config.yaml b/plugins/config.yaml index 48a83dc0..40b72c40 100644 --- a/plugins/config.yaml +++ b/plugins/config.yaml @@ -9,6 +9,7 @@ plugins: author: "Mihai Criveti" hooks: ["prompt_pre_fetch", "prompt_post_fetch"] tags: ["security", "pii", "compliance", "filter", "gdpr", "hipaa"] + enabled: true # true | false - whether plugin should be loaded mode: "permissive" # enforce | permissive | disabled priority: 50 # Lower number = higher priority (runs first) conditions: @@ -43,6 +44,7 @@ plugins: author: "MCP Context Forge Team" hooks: ["prompt_pre_fetch", "prompt_post_fetch"] tags: ["plugin", "transformer", "regex", "search-and-replace", "pre-post"] + enabled: true # true | false - whether plugin should be loaded mode: "enforce" # enforce | permissive | disabled priority: 150 conditions: @@ -63,6 +65,7 @@ plugins: author: "MCP Context Forge Team" hooks: ["prompt_pre_fetch"] tags: ["plugin", "filter", "denylist", "pre-post"] + enabled: false # true | false - whether plugin should be loaded mode: "enforce" # enforce | permissive | disabled priority: 100 conditions: diff --git a/plugins/regex_filter/README.md b/plugins/regex_filter/README.md index b7b54c76..596db072 100644 --- a/plugins/regex_filter/README.md +++ b/plugins/regex_filter/README.md @@ -1,6 +1,6 @@ # Search Replace Plugin for MCP Gateway -> Author: Teryl Taylor +> Author: Teryl Taylor > Version: 0.1.0 A native plugin for MCP Gateway that performs regex-based search and replace operations on prompt arguments and responses. @@ -88,11 +88,11 @@ config: # Replace email addresses with placeholder - search: "[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}" replace: "[email]" - + # Replace phone numbers - search: "\\b\\d{3}-\\d{3}-\\d{4}\\b" replace: "[phone]" - + # Case-insensitive replacement - search: "(?i)microsoft" replace: "MS" @@ -173,13 +173,13 @@ async def test_search_replace(): ] } ) - + plugin = SearchReplacePlugin(config) payload = PromptPrehookPayload( name="test", args={"message": "foo is foo"} ) - + result = await plugin.prompt_pre_fetch(payload, context) assert result.modified_payload.args["message"] == "bar is bar" ``` @@ -241,4 +241,4 @@ Apache-2.0 ## Support -For issues or questions, please open an issue in the MCP Gateway repository. \ No newline at end of file +For issues or questions, please open an issue in the MCP Gateway repository.