from pathlib import Path import sys import os from dotenv import load_dotenv root = Path(__file__).resolve().parents[1] sys.path.insert(0, str(root)) config = Path.home() / '.config/agents-mcp/server.env' if not config.exists(): raise SystemExit('Missing agents MCP configuration; refusing to start HTTP without authentication') load_dotenv(config, override=True) os.environ['SESSIONS_PUBLIC_SNAPSHOT'] = '1' from mcp_server import build_server from http_boundary import HTTPBoundary from starlette.middleware import Middleware server = build_server() if server.auth is None: raise SystemExit('Missing authentication; refusing to start HTTP') server.run(transport='http', host='127.0.0.1', port=int(os.getenv('SESSIONS_PORT', '8766')), middleware=[Middleware(HTTPBoundary, base=os.environ['SESSIONS_MCP_BASE_URL'])], stateless_http=True, json_response=True, uvicorn_config={'access_log': False, 'limit_concurrency': 16, 'timeout_keep_alive': 5})