"""Run the Horizon MCP server: python -m horizon.mcp

Security: HTTP transport requires HORIZON_MCP_TOKEN to be set.
When running over stdio (default), no token is required because
the transport is inherently local.
"""

import os
import sys

from horizon.mcp_server import mcp

transport = "stdio"
if "--http" in sys.argv:
    token = os.environ.get("HORIZON_MCP_TOKEN")
    if not token:
        print(
            "ERROR: HORIZON_MCP_TOKEN environment variable must be set "
            "when using HTTP transport. Refusing to start without "
            "authentication.\n\n"
            "Set it with:\n"
            "  export HORIZON_MCP_TOKEN='your-secret-token'\n\n"
            "For local development, use stdio transport (the default).",
            file=sys.stderr,
        )
        sys.exit(1)
    transport = "streamable-http"

mcp.run(transport=transport)
