-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadd_nested_servers.py
More file actions
103 lines (85 loc) · 3.28 KB
/
add_nested_servers.py
File metadata and controls
103 lines (85 loc) · 3.28 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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#!/usr/bin/env python3
"""
Script to add nested MCP servers to Bob's main MCP server
This allows dynamic addition of capabilities
"""
import asyncio
import json
from pathlib import Path
from src.mcp.real_mcp_server import RealMCPServer
async def setup_nested_servers():
"""Configure nested MCP servers"""
server = RealMCPServer()
await server.initialize()
print("🔌 Adding nested MCP servers to Bob...")
# Check for available MCP servers
available_servers = []
# 1. Sequential thinking server (if npm/npx available)
try:
import subprocess
result = subprocess.run(['which', 'npx'], capture_output=True)
if result.returncode == 0:
available_servers.append({
"name": "sequential-thinking",
"command": ["npx", "-y", "@modelcontextprotocol/server-sequential-thinking"],
"description": "Structured thinking and planning"
})
except:
pass
# 2. File scope server (if available)
filescope_path = Path("/home/zonk1024/projects/bob-mcp/mcp_servers/servers/filescope/FileScopeMCP/dist/index.js")
if filescope_path.exists():
available_servers.append({
"name": "filescope",
"command": ["node", str(filescope_path)],
"description": "File analysis and visualization"
})
# 3. TODO list server (if available)
todo_path = Path("/home/zonk1024/projects/bob-mcp/mcp_servers/servers/todo_list/todo-list-mcp/dist/index.js")
if todo_path.exists():
available_servers.append({
"name": "todo",
"command": ["node", str(todo_path)],
"description": "Task management"
})
# 4. GitHub server (if gh CLI available)
try:
result = subprocess.run(['which', 'gh'], capture_output=True)
if result.returncode == 0:
available_servers.append({
"name": "github",
"command": ["npx", "-y", "@modelcontextprotocol/server-github"],
"description": "GitHub integration"
})
except:
pass
# Add available servers
for server_config in available_servers:
print(f"\n✅ Adding {server_config['name']}: {server_config['description']}")
try:
await server.add_nested_server(
server_config['name'],
server_config['command']
)
print(f" Successfully added {server_config['name']}")
except Exception as e:
print(f" ❌ Failed to add {server_config['name']}: {e}")
print(f"\n🎉 Added {len(available_servers)} nested MCP servers!")
# Save configuration
config = {
"nested_servers": [
{
"name": s["name"],
"command": s["command"],
"description": s["description"],
"active": True
}
for s in available_servers
],
"last_updated": asyncio.get_event_loop().time()
}
with open("nested_servers_config.json", "w") as f:
json.dump(config, f, indent=2)
print("\n💾 Configuration saved to nested_servers_config.json")
if __name__ == "__main__":
asyncio.run(setup_nested_servers())