Files
2026-08-16 22:47:26 -07:00

49 lines
1.2 KiB
Python

"""Entrypoint: python -m bookstack_mcp"""
from __future__ import annotations
import logging
import sys
from .config import Settings
from .server import create_server
def build_app():
logging.basicConfig(
level=logging.INFO,
format="%(asctime)s %(levelname)s %(name)s %(message)s",
)
settings = Settings.from_env()
mcp = create_server(settings)
kwargs = {}
if settings.allowed_hosts:
kwargs["allowed_hosts"] = settings.allowed_hosts
kwargs["host_origin_protection"] = "auto"
return mcp.http_app(path=settings.mcp_path, **kwargs), settings
def main() -> None:
import uvicorn
try:
app, settings = build_app()
except RuntimeError as exc:
print(f"Configuration error: {exc}", file=sys.stderr)
raise SystemExit(2) from exc
logging.getLogger("bookstack-mcp").info(
"Serving BookStack MCP on http://%s:%s%s (auth=%s, read_only=%s)",
settings.host,
settings.port,
settings.mcp_path,
settings.auth_mode,
settings.read_only,
)
uvicorn.run(app, host=settings.host, port=settings.port, proxy_headers=True,
forwarded_allow_ips="*", access_log=False)
if __name__ == "__main__":
main()