guohanghui/graph-theory
0
1from fastapi import FastAPI2import os3import sys4 5mcp_plugin_path = os.path.join(os.path.dirname(__file__), "graph-theory", "mcp_output", "mcp_plugin")6sys.path.insert(0, mcp_plugin_path)7 8app = FastAPI(9 title="Graph-Theory MCP Service",10 description="Auto-generated MCP service for graph-theory",11 version="1.0.0"12)13 14@app.get("/")15def root():16 return {17 "service": "Graph-Theory MCP Service",18 "version": "1.0.0",19 "status": "running",20 "transport": os.environ.get("MCP_TRANSPORT", "http")21 }22 23@app.get("/health")24def health_check():25 return {"status": "healthy", "service": "graph-theory MCP"}26 27@app.get("/tools")28def list_tools():29 try:30 from mcp_service import create_app31 mcp_app = create_app()32 tools = []33 for tool_name, tool_func in mcp_app.tools.items():34 tools.append({35 "name": tool_name,36 "description": tool_func.__doc__ or "No description available"37 })38 return {"tools": tools}39 except Exception as e:40 return {"error": f"Failed to load tools: {str(e)}"}41 42if __name__ == "__main__":43 import uvicorn44 port = int(os.environ.get("PORT", 7860))45 uvicorn.run(app, host="0.0.0.0", port=port)46 