Spaces:
Running
feat: replace Gradio MCP with standalone FastMCP server + landing page
Replaces the Gradio-based MCP integration (app_mcp.py + mcp_service.py) with a self-contained FastMCP server using the MCP 2025-03-26 streamable HTTP transport.
What changed: New mcp_server/ package
- FastMCP instance with a lifespan that builds embeddings, vectorstores and reranker once at startup
- Two tools with typed Pydantic I/O models:
- retrieve_data_mcp โ IPCC / IPBES / IPOS document chunks and figures
- retrieve_graphs โ Our World In Data (OWID) graphs with similarity scores and source URLs - pydantic-settings driven config (all knobs overridable via env vars)
- In-memory test suite (pytest + pytest-asyncio) โ no Azure or model dependencies required to run tests; includes a backward-compatibility check for legacy text-content wire format
New mcp_app.py โ production entrypoint: Starlette app serving a landing page at / (with connection snippets for Claude, ChatGPT, Cursor, Mistral) and the MCP endpoint at /mcp on a single port
Dockerfile โ drops gradio[mcp] extra, switches CMD to python mcp_app.py when APP_TO_DEPLOY=MCP
scripts/mcp_client.py โ updated test client: streamable HTTP transport, Azure SP / MSAL token auth, AZURE_OPENAI_DEPLOYMENT_NAME required (no hardcoded internal defaults)
How to test locally
source .venv/bin/activate
python mcp_app.py
# โ http://localhost:7860 landing page
# โ http://localhost:7860/mcp MCP endpoint
python -m pytest mcp_server/tests/ -v
Must fix:
- Remove from mcp_service import make_retrieve_data_mcp, make_retrieve_graphs_mcp in app.py. mcp_service.py is gone; that import breaks the default Docker path (python app.py).
- put the html in a separate file
Worth a quick pass: Short README note that retrieve_graphs_mcp is now retrieve_graphs, and confirm public MCP with no auth is intentional for your deployment.