-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenerate_config_template.py
51 lines (39 loc) · 1.28 KB
/
generate_config_template.py
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import json
import shutil
import sys
from pathlib import Path
from mcp_toolbox.config import Config
def get_endpoint_path() -> str:
"""
Find the path to the mcp-toolbox script.
Similar to the 'which' command in Unix-like systems.
Returns:
str: The full path to the mcp-toolbox script
"""
# First try using shutil.which to find the script in PATH
script_path = shutil.which("mcp-toolbox")
if script_path:
return script_path
# If not found in PATH, try to find it in the current Python environment
# This handles cases where the script is installed but not in PATH
bin_dir = Path(sys.executable).parent
possible_paths = [
bin_dir / "mcp-toolbox",
bin_dir / "mcp-toolbox.exe", # For Windows
]
for path in possible_paths:
if path.exists():
return str(path)
# If we can't find it, return the script name and hope it's in PATH when executed
return "mcp-toolbox"
if __name__ == "__main__":
endpoint_path = get_endpoint_path()
mcp_config = {
"command": endpoint_path,
"args": ["stdio"],
"env": {field.upper(): "" for field in Config.model_fields},
}
mcp_item = {
"zerolab-toolbox-dev": mcp_config,
}
print(json.dumps(mcp_item, indent=4))