-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmain.py
More file actions
78 lines (67 loc) · 2.28 KB
/
Copy pathmain.py
File metadata and controls
78 lines (67 loc) · 2.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
import subprocess
import sys
import os
from mcp.server.fastmcp import FastMCP, Context
from extensions import Register
from server_extensions import register_mcp_extensions
import prompts # Import the new prompts module
mcp = FastMCP("PolyAgent")
def main():
print("🚀 Starting PolyAgent MCP Coordinator...")
# Initialize the MCP server registration system
register = Register()
# Register all extensions (prompts, tools, resources)
register_mcp_extensions(register)
# Register the new decorator-based prompts
prompts.register_prompts_with_system(register)
print(f"✅ Registered {len(register.get_prompts())} prompts")
print(f"✅ Registered {len(register.get_tools())} tools")
print(f"✅ Registered {len(register.get_resources())} resources")
# Start the MCP servers if not already running
mcp_servers = {
"Generation_mcp": {
"command": "/home/vani/.local/bin/uv",
"args": [
"--directory",
"/home/vani/mcp_servers/polyAgent/OMG_mcp",
"run",
"mcp",
"run",
"main.py"
]
},
"Property_mcp": {
"command": "/home/vani/.local/bin/uv",
"args": [
"--directory",
"/home/vani/mcp_servers/polyAgent/TransPolymer_mcp",
"run",
"mcp",
"run",
"main.py"
]
}
}
# Check if MCP servers are already running
running_servers = []
for server in mcp_servers:
try:
# Try to check if the server process is running
# For now, we'll assume they need to be started
print(f"🔄 Starting {server}...")
subprocess.Popen(mcp_servers[server]["command"], cwd=os.path.dirname(os.path.abspath(__file__)))
running_servers.append(server)
except Exception as e:
print(f"⚠️ Could not start {server}: {e}")
print(f"🎯 PolyAgent ready with {len(running_servers)} MCP servers connected")
print("📡 Waiting for property optimization requests...")
# Keep the main process running
try:
while True:
pass
except KeyboardInterrupt:
print("\n🛑 Shutting down PolyAgent...")
sys.exit(0)
if __name__ == "__main__":
# Run the FastMCP server with stdio transport
mcp.run(transport="stdio")