File size: 1,650 Bytes
8ad43db
 
fae22c5
 
8ad43db
 
 
 
 
 
 
 
fae22c5
8ad43db
 
fae22c5
 
 
8ad43db
fae22c5
8ad43db
 
 
 
fae22c5
 
8ad43db
fae22c5
8ad43db
 
 
fae22c5
 
8ad43db
fae22c5
 
8ad43db
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
from __future__ import annotations

import os
import sys
from pathlib import Path
from typing import Any

from fastapi import FastAPI

PLUGIN_DIR = Path(__file__).resolve().parent / "statsmodels" / "mcp_output" / "mcp_plugin"
if str(PLUGIN_DIR) not in sys.path:
    sys.path.insert(0, str(PLUGIN_DIR))

app = FastAPI(title="statsmodels-mcp-info", version="1.0.0")
PORT = int(os.getenv("PORT", "7860"))


@app.get("/")
def root() -> dict[str, Any]:
    return {
        "name": "statsmodels-mcp-service",
        "description": "Supplementary info app for local development. MCP endpoint is served by FastMCP runtime.",
        "mcp_http_path": "/mcp",
        "default_port": PORT,
    }


@app.get("/health")
def health() -> dict[str, str]:
    return {"status": "healthy"}


@app.get("/tools")
def tools() -> dict[str, Any]:
    try:
        from mcp_service import create_app

        mcp = create_app()
        raw_tools = getattr(mcp, "tools", None)
        entries: list[dict[str, Any]] = []

        if isinstance(raw_tools, dict):
            for name, obj in raw_tools.items():
                entries.append({
                    "name": str(name),
                    "description": getattr(obj, "description", ""),
                })
        elif isinstance(raw_tools, list):
            for obj in raw_tools:
                entries.append({
                    "name": getattr(obj, "name", "unknown"),
                    "description": getattr(obj, "description", ""),
                })

        return {"count": len(entries), "tools": entries}
    except Exception as exc:
        return {"count": 0, "tools": [], "error": str(exc)}