Files
ole eb95b98111 Refactor and enhance various components of the FINN real estate analysis tool
- Updated docker-compose files to use local data volumes for development.
- Refactored analysis.py to improve code readability and performance, including changes to cache age calculations and hash computations.
- Enhanced cache.py to ensure the database directory is created if it doesn't exist and improved SQL query formatting.
- Modified cli.py to improve logging and statistics reporting for finn_ads.
- Updated config.py to streamline environment variable handling.
- Initialized the database eagerly in http_server.py to prevent runtime errors.
- Refactored mcp_server.py to slim down data structures and improve response formatting for API calls.
- Enhanced service.py to improve feedback handling and shortlist retrieval, ensuring enriched data is returned.
- Updated recompute_analysis_cache.py for better SQL query formatting.
2026-05-29 15:17:11 +00:00

39 lines
1.1 KiB
Python

import json
import uvicorn
from starlette.responses import JSONResponse
from starlette.requests import Request
from starlette.middleware.cors import CORSMiddleware
from mcp.server.transport_security import TransportSecuritySettings
from finn_eiendom.cache import init_db
from finn_eiendom.mcp_server import mcp
# Initialise the database (and create the data/ directory) eagerly at
# startup so the first tool call never fails on a missing directory.
init_db()
mcp.transport_security = TransportSecuritySettings(enable_dns_rebinding_protection=False)
app = mcp.sse_app()
# Add CORS middleware to allow browser-based clients (e.g., MCP Inspector)
app.add_middleware(
CORSMiddleware,
allow_origins=["*"],
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
# Health check endpoint for container orchestration
async def health(request: Request) -> JSONResponse:
"""Return a simple health status for container probes."""
return JSONResponse({"status": "ok"})
app.add_route("/health", health, methods=["GET"])
if __name__ == "__main__":
uvicorn.run(app, host="0.0.0.0", port=8010, forwarded_allow_ips="*")