"""HTTP/SSE entrypoint for the atlas2-mcp server."""

from __future__ import annotations

from datetime import datetime, timezone
from typing import Dict
import logging
import os

from fastapi import FastAPI
from dotenv import load_dotenv

load_dotenv()

from .mcp_server import mcp

START_TIME = datetime.now(timezone.utc)

logging.basicConfig(level=logging.INFO, force=True)

app = FastAPI(
    title="Atlas2-MCP",
    description="Atlas2 semantic resolution scaffold (single resolve tool).",
    version="0.0.1",
)

app.mount("/mcp", mcp.sse_app())


@app.get("/health", tags=["liveness"])
async def health() -> Dict[str, object]:
    now = datetime.now(timezone.utc)
    uptime_seconds = (now - START_TIME).total_seconds()
    return {
        "status": "ok",
        "uptime_seconds": round(uptime_seconds, 2),
        "tools": ["resolve"],
    }
