Skip to content

Commit b4305a0

Browse files
authored
Limit admin plugin to enable/disable (#324)
1 parent 528952f commit b4305a0

File tree

4 files changed

+67
-0
lines changed

4 files changed

+67
-0
lines changed

plugins/.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@
3131
!circleci/
3232
!circleci/**
3333

34+
# Track the mcp_admin plugin
35+
!mcp_admin/
36+
!mcp_admin/**
37+
3438
# Ignore Python bytecode files
3539
*.pyc
3640
__pycache__/

plugins/mcp_admin/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# MCP Admin Plugin
2+
3+
This plugin exposes operations that allow you to enable or disable MCP plugins
4+
at runtime.

plugins/mcp_admin/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
"""MCP administration plugin."""
2+
3+
__all__ = ["McpAdminTool"]

plugins/mcp_admin/tool.py

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
from typing import Dict, Any
2+
3+
from mcp_tools.interfaces import ToolInterface
4+
from mcp_tools.plugin import register_tool, discover_and_register_tools, registry
5+
from mcp_tools.plugin_config import config
6+
7+
8+
@register_tool(os_type="all")
9+
class McpAdminTool(ToolInterface):
10+
"""Tool for administering the running MCP instance."""
11+
12+
@property
13+
def name(self) -> str:
14+
return "mcp_admin"
15+
16+
@property
17+
def description(self) -> str:
18+
return "Inspect and manage MCP plugins at runtime."
19+
20+
@property
21+
def input_schema(self) -> Dict[str, Any]:
22+
return {
23+
"type": "object",
24+
"properties": {
25+
"operation": {
26+
"type": "string",
27+
"enum": [
28+
"enable_plugin",
29+
"disable_plugin",
30+
],
31+
"description": "Action to perform",
32+
},
33+
"plugin": {
34+
"type": "string",
35+
"description": "Target plugin name",
36+
},
37+
},
38+
"required": ["operation", "plugin"],
39+
}
40+
41+
async def execute_tool(self, arguments: Dict[str, Any]) -> Dict[str, Any]:
42+
operation = arguments.get("operation")
43+
plugin = arguments.get("plugin")
44+
45+
if operation == "enable_plugin":
46+
config.enable_plugin(plugin)
47+
if plugin not in registry.tools:
48+
discover_and_register_tools()
49+
return {"success": True, "plugin": plugin, "enabled": True}
50+
elif operation == "disable_plugin":
51+
config.disable_plugin(plugin)
52+
registry.tools.pop(plugin, None)
53+
registry.instances.pop(plugin, None)
54+
return {"success": True, "plugin": plugin, "enabled": False}
55+
56+
return {"success": False, "error": f"Unknown operation: {operation}"}

0 commit comments

Comments
 (0)