File size: 1,764 Bytes
e2bb7fc
 
bd12dd4
 
e2bb7fc
 
 
 
 
 
 
 
bd12dd4
e2bb7fc
bd12dd4
 
 
e2bb7fc
bd12dd4
e2bb7fc
 
 
 
 
bd12dd4
 
e2bb7fc
bd12dd4
e2bb7fc
 
 
bd12dd4
 
e2bb7fc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
from __future__ import annotations

import os
import sys
from pathlib import Path

from fastapi import FastAPI  # type: ignore[import-not-found]

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

app = FastAPI(title="dateutil MCP info app", version="1.0.0")


@app.get("/")
def service_info() -> dict:
    return {
        "service": "dateutil-mcp",
        "description": "Supplementary info API for dateutil MCP deployment",
        "mcp_entrypoint": "dateutil/mcp_output/start_mcp.py",
        "transport_default": "stdio",
        "http_endpoint": "/mcp when MCP_TRANSPORT=http",
    }


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


@app.get("/tools")
def tools() -> dict:
    import importlib

    service_module = importlib.import_module("mcp_service")
    create_app = getattr(service_module, "create_app")
    mcp = create_app()
    raw_tools = getattr(mcp, "tools", None)

    items: list[dict] = []
    if isinstance(raw_tools, dict):
        for key, tool_obj in raw_tools.items():
            items.append(
                {
                    "name": getattr(tool_obj, "name", str(key)),
                    "description": getattr(tool_obj, "description", ""),
                }
            )
    elif isinstance(raw_tools, list):
        for tool_obj in raw_tools:
            items.append(
                {
                    "name": getattr(tool_obj, "name", "unknown"),
                    "description": getattr(tool_obj, "description", ""),
                }
            )

    return {"count": len(items), "tools": items}


PORT = int(os.getenv("PORT", "7860"))