Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/hal0/api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@
from hal0.api.routes import (
lemonade_proxy as lemonade_proxy_routes,
)
from hal0.api.routes import (
mcp as mcp_routes,
)
from hal0.api.routes import (
memory as memory_routes,
)
Expand Down Expand Up @@ -795,6 +798,17 @@ def create_app() -> FastAPI:
tags=["approvals"],
)

# MCP introspection (issue #206). Read-only view of hosted MCP
# servers, connected clients (audit-derived), the installable
# catalog, and an SSE tail of ``mcp.tool.*`` events. The lifecycle
# mutations (install / uninstall / restart / config-write) stub at
# 501 — ADR-0013's ``mcp_client.py`` work owns those.
app.include_router(
mcp_routes.router,
prefix="/api/mcp",
tags=["mcp"],
)

# ── MCP servers (ADR-0004 §4 + ADR-0005 §2) ─────────────────────
# Mounted BEFORE _mount_dashboard so the dashboard's SPA fallback
# doesn't shadow /mcp/* paths. ApprovalQueue + CogneeWrapper are
Expand Down
7 changes: 7 additions & 0 deletions src/hal0/api/mcp_mount.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,11 @@ def mount_mcp_servers(
app.mount("/mcp/admin", admin_app, name="mcp-admin")

session_managers = [admin_server.session_manager]
# Issue #206 — stash the live FastMCP instances on app.state so the
# /api/mcp/* introspection routes can read tool / resource / prompt
# counts via ``await server.list_tools()`` without re-importing the
# builders. Keyed by mount id (matches ``connect_url`` last segment).
mcp_servers: dict[str, object] = {"hal0-admin": admin_server}

if memory_wrapper is not None:
from hal0.mcp.memory import build_server as build_memory_server
Expand All @@ -155,8 +160,10 @@ def mount_mcp_servers(
memory_app.add_middleware(MCPAuthMiddleware)
app.mount("/mcp/memory", memory_app, name="mcp-memory")
session_managers.append(memory_server.session_manager)
mcp_servers["hal0-memory"] = memory_server

app.state.mcp_session_managers = session_managers
app.state.mcp_servers = mcp_servers

log.info(
"hal0.mcp.mounted",
Expand Down
Loading
Loading