| 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 / "scanpy" / "mcp_output" / "mcp_plugin" |
| plugin_path = str(PLUGIN_DIR) |
| if plugin_path not in sys.path: |
| sys.path.insert(0, plugin_path) |
|
|
| app = FastAPI(title="scanpy-mcp-info", version="1.0.0") |
|
|
|
|
| @app.get("/") |
| def root() -> dict[str, Any]: |
| return { |
| "name": "scanpy MCP service", |
| "description": "Supplementary info API for local development", |
| "mcp_entrypoint": "scanpy/mcp_output/start_mcp.py", |
| "default_port": int(os.getenv("PORT", "7860")), |
| } |
|
|
|
|
| @app.get("/health") |
| def health() -> dict[str, str]: |
| return {"status": "healthy"} |
|
|
|
|
| @app.get("/tools") |
| def tools() -> dict[str, Any]: |
| from mcp_service import create_app |
|
|
| mcp = create_app() |
| tool_items = [] |
| for tool in getattr(mcp, "tools", []): |
| tool_items.append( |
| { |
| "name": getattr(tool, "name", "unknown"), |
| "description": getattr(tool, "description", ""), |
| } |
| ) |
| return {"tools": tool_items, "count": len(tool_items)} |
|
|