-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathhooks.py
More file actions
31 lines (24 loc) · 1.05 KB
/
Copy pathhooks.py
File metadata and controls
31 lines (24 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
"""Plugin lifecycle hooks for mcp2cli.
The `install` hook is called by Agent Zero when the plugin is first enabled,
automatically installing the mcp2cli CLI tool into the active environment.
The `uninstall` hook is called when the plugin is disabled or removed.
"""
import importlib.util
from pathlib import Path
def _load_execute():
"""Load execute.py from plugin root using importlib (avoids sys.path pollution)."""
execute_path = Path(__file__).parent / "execute.py"
spec = importlib.util.spec_from_file_location("execute", str(execute_path))
if spec is None or spec.loader is None:
raise ImportError(f"Could not load execute.py from {execute_path}")
module = importlib.util.module_from_spec(spec)
spec.loader.exec_module(module)
return module
def install():
"""Install mcp2cli binary when the plugin is enabled."""
execute = _load_execute()
return execute.main()
def uninstall():
"""Uninstall mcp2cli binary when the plugin is disabled or removed."""
execute = _load_execute()
return execute.uninstall_main()