File size: 1,222 Bytes
db62a8c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
from fastapi import FastAPI
import os
import sys

mcp_plugin_path = os.path.join(os.path.dirname(__file__), "MetPy", "mcp_output", "mcp_plugin")
sys.path.insert(0, mcp_plugin_path)

app = FastAPI(
    title="Metpy MCP Service",
    description="Auto-generated MCP service for MetPy",
    version="1.0.0"
)

@app.get("/")
def root():
    return {
        "service": "Metpy MCP Service",
        "version": "1.0.0",
        "status": "running",
        "transport": os.environ.get("MCP_TRANSPORT", "http")
    }

@app.get("/health")
def health_check():
    return {"status": "healthy", "service": "MetPy MCP"}

@app.get("/tools")
def list_tools():
    try:
        from mcp_service import create_app
        mcp_app = create_app()
        tools = []
        for tool_name, tool_func in mcp_app.tools.items():
            tools.append({
                "name": tool_name,
                "description": tool_func.__doc__ or "No description available"
            })
        return {"tools": tools}
    except Exception as e:
        return {"error": f"Failed to load tools: {str(e)}"}

if __name__ == "__main__":
    import uvicorn
    port = int(os.environ.get("PORT", 7860))
    uvicorn.run(app, host="0.0.0.0", port=port)