import logging from pathlib import Path from fastapi import FastAPI from fastapi.staticfiles import StaticFiles from .core.config import load_config from .routes.mcp import get_router from .websocket.manager import ConnectionManager logging.basicConfig(level=logging.INFO) logger = logging.getLogger("agentbell.mcp") def create_app() -> FastAPI: config = load_config() app = FastAPI( title="AgentBell MCP Server", description="A Model Context Protocol (MCP) server for real-time voice notifications.", version="1.0.0", ) static_dir = Path(__file__).resolve().parent / "static" static_dir.mkdir(parents=True, exist_ok=True) app.mount("/static", StaticFiles(directory=static_dir), name="static") manager = ConnectionManager() app.include_router(get_router(config, manager)) if not config.tts_configured: logger.warning( "ELEVENLABS_API_KEY is not configured. /invoke calls will return an error." ) @app.websocket("/ws") async def websocket_endpoint(websocket): await manager.handle_connection(websocket) @app.get("/") async def root(): return {"message": "AgentBell MCP Server is running."} return app app = create_app()