Skip to content

Server

server

AXM MCP Server — Streamable HTTP transport.

Reuses the FastMCP instance from mcp_app and runs it over HTTP instead of stdio, enabling a single persistent process for all conversations.

health_check(request) async

Return server health with registered tool count.

Reads the count from FastMCP's public list_tools() enumeration, which reflects exactly what is registered on the instance in BOTH facade and legacy modes — no private _tool_manager access and no parallel counter that could drift from the registration seam.

Source code in packages/axm-mcp/src/axm_mcp/server.py
Python
@mcp.custom_route("/health", methods=["GET"])  # type: ignore[untyped-decorator]
async def health_check(request: Request) -> JSONResponse:
    """Return server health with registered tool count.

    Reads the count from FastMCP's public ``list_tools()`` enumeration,
    which reflects exactly what is registered on the instance in BOTH
    facade and legacy modes — no private ``_tool_manager`` access and no
    parallel counter that could drift from the registration seam.
    """
    tools = await mcp.list_tools()
    return JSONResponse({"status": "ok", "tools_count": len(tools)})

serve(host='127.0.0.1', port=None)

Start the MCP server with Streamable HTTP transport.

Parameters:

Name Type Description Default
host str

Bind address (default 127.0.0.1).

'127.0.0.1'
port int | None

Bind port. Falls back to AXM_MCP_PORT env var, then 9427.

None
Source code in packages/axm-mcp/src/axm_mcp/server.py
Python
def serve(
    host: str = "127.0.0.1",
    port: int | None = None,
) -> None:
    """Start the MCP server with Streamable HTTP transport.

    Args:
        host: Bind address (default 127.0.0.1).
        port: Bind port. Falls back to AXM_MCP_PORT env var, then 9427.
    """
    if port is None:
        env_port = os.environ.get("AXM_MCP_PORT")
        port = int(env_port) if env_port else DEFAULT_PORT

    if not (_MIN_PORT <= port <= _MAX_PORT):
        msg = f"Invalid port {port}: must be between {_MIN_PORT} and {_MAX_PORT}"
        raise ValueError(msg)

    mcp.settings.host = host
    mcp.settings.port = port
    mcp.run(transport="streamable-http")