Spaces:
Running
Running
Download app.py from judicialmind/OpenGovtData-MCP: direct link, hf CLI and curl.
- Browser
- Download file 1.11 kB
-
https://huggingface.co/spaces/judicialmind/OpenGovtData-MCP/resolve/main/app.py
- Command line
-
hf download hf://spaces/judicialmind/OpenGovtData-MCP/app.py
-
curl -L -o app.py https://huggingface.co/spaces/judicialmind/OpenGovtData-MCP/resolve/main/app.py
1.11 kB
| """OpenGovtData-MCP Space: FastAPI HTTP API + MCP streamable HTTP (/mcp) over the bundled demo store.""" | |
| import contextlib | |
| import os | |
| from ogd.mcp.core import OgdBackend | |
| from ogd.mcp.server import make_api, make_mcp | |
| STORE = os.environ.get("OGD_STORE", os.path.join(os.path.dirname(os.path.abspath(__file__)), "demo_store")) | |
| backend = OgdBackend(STORE, None, threads=2) | |
| mcp_server = make_mcp(backend) | |
| mcp_app = mcp_server.streamable_http_app(streamable_http_path="/mcp", stateless_http=True, host="0.0.0.0") | |
| app = make_api(backend) | |
| async def _lifespan(_app): | |
| async with mcp_server.session_manager.run(): | |
| yield | |
| app.router.lifespan_context = _lifespan | |
| def root() -> dict: | |
| return {"name": "OpenGovtData-MCP", "demo_tables": sum(1 for r in backend.catalog.values() if r.get("table_path")), | |
| "http_api": ["/search?q=", "/describe/{uuid}", "/cite/{uuid}", "POST /query", "/health"], | |
| "mcp": "/mcp (streamable HTTP)", "docs": "/docs"} | |
| app.mount("/", mcp_app) # last: FastAPI routes above win, /mcp falls through to the MCP app | |