from __future__ import annotations import os from pathlib import Path import sys from fastapi import FastAPI BASE_DIR = Path(__file__).resolve().parent PLUGIN_DIR = BASE_DIR / "biotite" / "mcp_output" / "mcp_plugin" if str(PLUGIN_DIR) not in sys.path: sys.path.insert(0, str(PLUGIN_DIR)) app = FastAPI(title="Biotite MCP Supplementary App", version="1.0.0") @app.get("/") def info() -> dict: return { "service": "biotite-mcp", "description": "Supplementary info API for the Biotite MCP deployment", "mcp_entrypoint": "biotite/mcp_output/start_mcp.py", "mcp_transport_env": "MCP_TRANSPORT", "port_env": "PORT", } @app.get("/health") def health() -> dict: return {"status": "healthy"} @app.get("/tools") def tools() -> dict: try: from mcp_service import create_app mcp = create_app() tool_items = [] tools_obj = getattr(mcp, "tools", None) if isinstance(tools_obj, dict): iterable = tools_obj.items() for name, tool in iterable: description = getattr(tool, "description", "") tool_items.append({"name": name, "description": description}) elif isinstance(tools_obj, list): for tool in tools_obj: name = getattr(tool, "name", "unknown") description = getattr(tool, "description", "") tool_items.append({"name": name, "description": description}) return {"count": len(tool_items), "tools": tool_items} except Exception as exc: return {"count": 0, "tools": [], "error": str(exc)} PORT = int(os.getenv("PORT", "7860")) if __name__ == "__main__": import uvicorn uvicorn.run(app, host="0.0.0.0", port=PORT)