65 lines
1.5 KiB
Python
65 lines
1.5 KiB
Python
"""FastAPI application entry point"""
|
|
import os
|
|
from fastapi import FastAPI
|
|
from fastapi.middleware.cors import CORSMiddleware
|
|
|
|
from app.core.config import settings
|
|
from app.routes import cards, auth, sync
|
|
from app.mcp_server import AICardMcpServer
|
|
|
|
# Initialize MCP server
|
|
enable_mcp = os.getenv("ENABLE_MCP", "true").lower() == "true"
|
|
mcp_server = AICardMcpServer(enable_mcp=enable_mcp)
|
|
|
|
# Get FastAPI app from MCP server
|
|
app = mcp_server.get_app()
|
|
|
|
# Update app configuration
|
|
app.title = settings.app_name
|
|
app.version = settings.app_version
|
|
app.docs_url = "/docs"
|
|
app.redoc_url = "/redoc"
|
|
|
|
# CORS middleware
|
|
app.add_middleware(
|
|
CORSMiddleware,
|
|
allow_origins=settings.cors_origins,
|
|
allow_credentials=True,
|
|
allow_methods=["*"],
|
|
allow_headers=["*"],
|
|
)
|
|
|
|
# Include routers
|
|
app.include_router(auth.router, prefix=settings.api_v1_prefix)
|
|
app.include_router(cards.router, prefix=settings.api_v1_prefix)
|
|
app.include_router(sync.router, prefix=settings.api_v1_prefix)
|
|
|
|
|
|
@app.get("/")
|
|
async def root():
|
|
"""Root endpoint"""
|
|
return {
|
|
"app": settings.app_name,
|
|
"version": settings.app_version,
|
|
"status": "running"
|
|
}
|
|
|
|
|
|
@app.get("/health")
|
|
async def health_check():
|
|
"""Health check endpoint"""
|
|
return {
|
|
"status": "healthy",
|
|
"mcp_enabled": enable_mcp,
|
|
"mcp_endpoint": "/mcp" if enable_mcp else None
|
|
}
|
|
|
|
|
|
if __name__ == "__main__":
|
|
import uvicorn
|
|
uvicorn.run(
|
|
"app.main:app",
|
|
host="0.0.0.0",
|
|
port=8000,
|
|
reload=True
|
|
) |