| """ |
| MCP 状态 API 端点 |
| 提供 GET /api/mcp/status。 |
| """ |
|
|
| from fastapi import APIRouter, HTTPException |
|
|
| from app.mcp.plugin_registry import get_plugin_registry |
|
|
| router = APIRouter() |
|
|
|
|
| @router.get("/status") |
| async def get_mcp_status(): |
| """获取 MCP 服务状态 |
| |
| Returns: |
| 包含服务状态、工具总数、按插件分组、最近错误的字典 |
| """ |
| try: |
| registry = get_plugin_registry() |
| return registry.get_mcp_status() |
| except RuntimeError: |
| |
| return { |
| "service_available": False, |
| "total_tools": 0, |
| "available_tools": 0, |
| "unavailable_tools": 0, |
| "incomplete_tools": 0, |
| "groups": [], |
| "recent_errors": [], |
| } |
|
|