"""
Local-only dev launcher for the OMS MCP server with CORS enabled.

FastMCP's built-in `mcp.run(transport="streamable-http")` serves the /mcp
endpoint but adds no CORS middleware, so the browser-based MCP Inspector's
preflight (OPTIONS /mcp) gets 405 and the UI cannot connect. In production
Apache handles CORS/OPTIONS; locally there is no proxy, so we add CORS here.

Run from the oms_mcp/ directory (sibling imports must resolve):
    python ./oms_mcp/dev_serve.py

Then point MCP Inspector at:  http://127.0.0.1:8000/mcp  (transport: Streamable HTTP)

This file is for LOCAL TESTING ONLY. Do not use it in production — prod runs
server.py via systemd behind Apache (see .documentation/MCP_STREAMABLE_HTTP_MIGRATION.md).
"""

import uvicorn
from starlette.middleware.cors import CORSMiddleware

# Importing server.py defines the FastMCP instance without starting it
# (its mcp.run() is guarded by `if __name__ == "__main__"`).
from server import mcp

app = mcp.streamable_http_app()

app.add_middleware(
    CORSMiddleware,
    allow_origins=["*"],
    allow_methods=["GET", "POST", "DELETE", "OPTIONS"],
    allow_headers=["*"],
    expose_headers=["Mcp-Session-Id"],
)

if __name__ == "__main__":
    uvicorn.run(app, host="127.0.0.1", port=8000)
