Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,24 +1,3 @@
|
|
| 1 |
-
#!/usr/bin/env python3
|
| 2 |
-
"""
|
| 3 |
-
Standalone Gradio demo of the IdRef resolver MCP server, deployable as
|
| 4 |
-
a Hugging Face Space.
|
| 5 |
-
|
| 6 |
-
Like the server, this app is a transport adapter: every score, threshold and
|
| 7 |
-
status comes from the API, and no host but the API is called. Unlike the server,
|
| 8 |
-
a missing or unreachable API does not stop the process — the call comes back with
|
| 9 |
-
`error` set and `status` null.
|
| 10 |
-
|
| 11 |
-
Local run:
|
| 12 |
-
uv run --with 'gradio[mcp]>=6,<7' --with httpx app.py
|
| 13 |
-
|
| 14 |
-
Environment:
|
| 15 |
-
IDREF_API_URL API base URL (default http://localhost:8000)
|
| 16 |
-
IDREF_API_KEY sent as X-API-Key; never a tool argument, never echoed back
|
| 17 |
-
GRADIO_SERVER_NAME bind address (default 0.0.0.0)
|
| 18 |
-
GRADIO_SERVER_PORT port (default 7860)
|
| 19 |
-
GRADIO_MCP_SERVER "false" disables the demo MCP endpoint (default true)
|
| 20 |
-
"""
|
| 21 |
-
|
| 22 |
from __future__ import annotations
|
| 23 |
|
| 24 |
import os
|
|
@@ -29,7 +8,7 @@ import httpx
|
|
| 29 |
|
| 30 |
# ── Configuration ─────────────────────────────────────────────────────────────
|
| 31 |
|
| 32 |
-
API_BASE_URL = os.environ.get("IDREF_API_URL", "
|
| 33 |
|
| 34 |
# The credential is read from the environment only: never a tool argument, never
|
| 35 |
# echoed into a payload.
|
|
@@ -300,10 +279,4 @@ with gr.Blocks(title="IdRef resolver MCP demo") as demo:
|
|
| 300 |
gr.api(align_person, api_name="align_person")
|
| 301 |
|
| 302 |
|
| 303 |
-
|
| 304 |
-
demo.launch(
|
| 305 |
-
theme=gr.themes.Soft(), # Gradio 6 moved theme from Blocks() to launch()
|
| 306 |
-
server_name=os.getenv("GRADIO_SERVER_NAME", "0.0.0.0"),
|
| 307 |
-
server_port=int(os.getenv("GRADIO_SERVER_PORT", "7860")),
|
| 308 |
-
mcp_server=os.getenv("GRADIO_MCP_SERVER", "true").lower() == "true",
|
| 309 |
-
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
from __future__ import annotations
|
| 2 |
|
| 3 |
import os
|
|
|
|
| 8 |
|
| 9 |
# ── Configuration ─────────────────────────────────────────────────────────────
|
| 10 |
|
| 11 |
+
API_BASE_URL = os.environ.get("IDREF_API_URL", "https://idref-resolver.smartbiblia.fr/").rstrip("/")
|
| 12 |
|
| 13 |
# The credential is read from the environment only: never a tool argument, never
|
| 14 |
# echoed into a payload.
|
|
|
|
| 279 |
gr.api(align_person, api_name="align_person")
|
| 280 |
|
| 281 |
|
| 282 |
+
demo.launch(theme=gr.themes.Soft(), mcp_server=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|