Commit
·
e0abc68
1
Parent(s):
7501b6e
Improve MCP server presets and connection testing
Browse files- Update preset MCP servers with verified working endpoints
- Add schema_url for each preset server
- Improve test_mcp_connection to fetch schema and count tools
- MCP Tools by abidlabs: 4 tools verified working
- HuggingFace MCP by dylanebert: 6 tools verified working
- Better error handling for sleeping/unavailable servers
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
app.py
CHANGED
|
@@ -42,29 +42,33 @@ EXPORT_FORMATS = ["OpenLineage", "Collibra", "Purview", "Alation"]
|
|
| 42 |
|
| 43 |
# Preset MCP Servers on HuggingFace that can provide metadata
|
| 44 |
MCP_PRESETS = {
|
| 45 |
-
"
|
| 46 |
-
"name": "
|
| 47 |
-
"url": "https://
|
| 48 |
-
"
|
| 49 |
-
"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 50 |
},
|
| 51 |
"ragmint": {
|
| 52 |
"name": "Ragmint RAG Pipeline",
|
| 53 |
"url": "https://mcp-1st-birthday-ragmint-mcp-server.hf.space/gradio_api/mcp/sse",
|
| 54 |
-
"
|
|
|
|
| 55 |
"tools": ["optimize_rag", "retrieve_documents"]
|
| 56 |
},
|
| 57 |
"web_search": {
|
| 58 |
"name": "Web Search MCP",
|
| 59 |
"url": "https://agents-mcp-hackathon-search-web-mcp-server.hf.space/gradio_api/mcp/sse",
|
| 60 |
-
"
|
|
|
|
| 61 |
"tools": ["search_web", "fetch_page"]
|
| 62 |
-
},
|
| 63 |
-
"mcp_tools": {
|
| 64 |
-
"name": "MCP Tools (Demo)",
|
| 65 |
-
"url": "https://abidlabs-mcp-tools.hf.space/gradio_api/mcp/sse",
|
| 66 |
-
"description": "Demo MCP server with various utility tools",
|
| 67 |
-
"tools": ["prime_factors", "generate_image", "image_orientation"]
|
| 68 |
}
|
| 69 |
}
|
| 70 |
|
|
@@ -361,23 +365,38 @@ def send_to_mcp(server_url: str, api_key: str, metadata_text: str, source_type:
|
|
| 361 |
|
| 362 |
|
| 363 |
def test_mcp_connection(server_url: str, api_key: str) -> str:
|
| 364 |
-
"""Health-check to MCP server."""
|
| 365 |
if not server_url:
|
| 366 |
return "No MCP server URL configured."
|
| 367 |
try:
|
| 368 |
headers = {}
|
| 369 |
if api_key:
|
| 370 |
headers["Authorization"] = f"Bearer {api_key}"
|
| 371 |
-
|
| 372 |
-
|
| 373 |
-
|
| 374 |
-
|
| 375 |
-
|
| 376 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 377 |
return f"Connected to MCP server: {resp.status_code} OK"
|
| 378 |
-
|
| 379 |
-
|
| 380 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 381 |
except Exception as e:
|
| 382 |
return f"Error contacting MCP server: {e}"
|
| 383 |
|
|
@@ -628,10 +647,10 @@ with gr.Blocks(
|
|
| 628 |
mcp_preset = gr.Dropdown(
|
| 629 |
choices=[
|
| 630 |
("-- Select Preset --", ""),
|
| 631 |
-
("
|
|
|
|
| 632 |
("Ragmint RAG Pipeline", "ragmint"),
|
| 633 |
("Web Search MCP", "web_search"),
|
| 634 |
-
("MCP Tools (Demo)", "mcp_tools"),
|
| 635 |
],
|
| 636 |
label="Preset MCP Servers",
|
| 637 |
value="",
|
|
|
|
| 42 |
|
| 43 |
# Preset MCP Servers on HuggingFace that can provide metadata
|
| 44 |
MCP_PRESETS = {
|
| 45 |
+
"mcp_tools": {
|
| 46 |
+
"name": "MCP Tools by abidlabs",
|
| 47 |
+
"url": "https://abidlabs-mcp-tools.hf.space/gradio_api/mcp/sse",
|
| 48 |
+
"schema_url": "https://abidlabs-mcp-tools.hf.space/gradio_api/mcp/schema",
|
| 49 |
+
"description": "Demo MCP server with utility tools for testing integration",
|
| 50 |
+
"tools": ["prime_factors", "generate_cheetah_image", "image_orientation"]
|
| 51 |
+
},
|
| 52 |
+
"huggingface_mcp": {
|
| 53 |
+
"name": "HuggingFace MCP by dylanebert",
|
| 54 |
+
"url": "https://dylanebert-huggingface-mcp.hf.space/gradio_api/mcp/sse",
|
| 55 |
+
"schema_url": "https://dylanebert-huggingface-mcp.hf.space/gradio_api/mcp/schema",
|
| 56 |
+
"description": "Search and explore HuggingFace models, datasets, and spaces",
|
| 57 |
+
"tools": ["search_models", "search_datasets", "get_model_card"]
|
| 58 |
},
|
| 59 |
"ragmint": {
|
| 60 |
"name": "Ragmint RAG Pipeline",
|
| 61 |
"url": "https://mcp-1st-birthday-ragmint-mcp-server.hf.space/gradio_api/mcp/sse",
|
| 62 |
+
"schema_url": "https://mcp-1st-birthday-ragmint-mcp-server.hf.space/gradio_api/mcp/schema",
|
| 63 |
+
"description": "RAG pipeline optimization and document retrieval",
|
| 64 |
"tools": ["optimize_rag", "retrieve_documents"]
|
| 65 |
},
|
| 66 |
"web_search": {
|
| 67 |
"name": "Web Search MCP",
|
| 68 |
"url": "https://agents-mcp-hackathon-search-web-mcp-server.hf.space/gradio_api/mcp/sse",
|
| 69 |
+
"schema_url": "https://agents-mcp-hackathon-search-web-mcp-server.hf.space/gradio_api/mcp/schema",
|
| 70 |
+
"description": "Search the web for data and documentation",
|
| 71 |
"tools": ["search_web", "fetch_page"]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 72 |
}
|
| 73 |
}
|
| 74 |
|
|
|
|
| 365 |
|
| 366 |
|
| 367 |
def test_mcp_connection(server_url: str, api_key: str) -> str:
|
| 368 |
+
"""Health-check to MCP server by fetching schema."""
|
| 369 |
if not server_url:
|
| 370 |
return "No MCP server URL configured."
|
| 371 |
try:
|
| 372 |
headers = {}
|
| 373 |
if api_key:
|
| 374 |
headers["Authorization"] = f"Bearer {api_key}"
|
| 375 |
+
|
| 376 |
+
# For Gradio MCP servers, the schema endpoint is the best test
|
| 377 |
+
schema_url = server_url.replace("/sse", "/schema").replace("/mcp/mcp", "/mcp")
|
| 378 |
+
try:
|
| 379 |
+
resp = requests.get(schema_url, headers=headers, timeout=15)
|
| 380 |
+
if resp.status_code == 200:
|
| 381 |
+
try:
|
| 382 |
+
schema = resp.json()
|
| 383 |
+
tool_count = len(schema) if isinstance(schema, dict) else 0
|
| 384 |
+
return f"Connected! Found {tool_count} tools available."
|
| 385 |
+
except:
|
| 386 |
return f"Connected to MCP server: {resp.status_code} OK"
|
| 387 |
+
except requests.exceptions.RequestException:
|
| 388 |
+
pass
|
| 389 |
+
|
| 390 |
+
# Fallback: try base URL
|
| 391 |
+
base_url = server_url.replace("/gradio_api/mcp/sse", "")
|
| 392 |
+
try:
|
| 393 |
+
resp = requests.get(base_url, headers=headers, timeout=10)
|
| 394 |
+
if resp.status_code == 200:
|
| 395 |
+
return f"Server reachable (status {resp.status_code})"
|
| 396 |
+
except:
|
| 397 |
+
pass
|
| 398 |
+
|
| 399 |
+
return "MCP server may be sleeping. Try again in a moment."
|
| 400 |
except Exception as e:
|
| 401 |
return f"Error contacting MCP server: {e}"
|
| 402 |
|
|
|
|
| 647 |
mcp_preset = gr.Dropdown(
|
| 648 |
choices=[
|
| 649 |
("-- Select Preset --", ""),
|
| 650 |
+
("MCP Tools by abidlabs", "mcp_tools"),
|
| 651 |
+
("HuggingFace MCP by dylanebert", "huggingface_mcp"),
|
| 652 |
("Ragmint RAG Pipeline", "ragmint"),
|
| 653 |
("Web Search MCP", "web_search"),
|
|
|
|
| 654 |
],
|
| 655 |
label="Preset MCP Servers",
|
| 656 |
value="",
|