Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -55,9 +55,7 @@ def reload_tools_from_url(mcp_url_input):
|
|
| 55 |
return gr.DataFrame(value=df)
|
| 56 |
|
| 57 |
with gr.Blocks() as demo:
|
| 58 |
-
|
| 59 |
-
with gr.Row():
|
| 60 |
-
gr.HTML("""
|
| 61 |
<div style="text-align:center; max-width: 100%; margin-bottom: 20px;">
|
| 62 |
<h1 style="font-size: 2em; margin-bottom: 0.5em;">
|
| 63 |
🚀 MCP Explorer – Agents-MCP-Hackathon (June 2025)
|
|
@@ -73,74 +71,71 @@ with gr.Blocks() as demo:
|
|
| 73 |
</div>
|
| 74 |
"""
|
| 75 |
)
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
visible=True
|
| 95 |
-
)
|
| 96 |
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
|
| 112 |
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
| 133 |
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
|
| 142 |
-
|
| 143 |
-
)
|
| 144 |
|
| 145 |
demo.launch()
|
| 146 |
|
|
|
|
| 55 |
return gr.DataFrame(value=df)
|
| 56 |
|
| 57 |
with gr.Blocks() as demo:
|
| 58 |
+
gr.HTML("""
|
|
|
|
|
|
|
| 59 |
<div style="text-align:center; max-width: 100%; margin-bottom: 20px;">
|
| 60 |
<h1 style="font-size: 2em; margin-bottom: 0.5em;">
|
| 61 |
🚀 MCP Explorer – Agents-MCP-Hackathon (June 2025)
|
|
|
|
| 71 |
</div>
|
| 72 |
"""
|
| 73 |
)
|
| 74 |
+
gr.Markdown("""
|
| 75 |
+
<div align="center">
|
| 76 |
+
<h2>🛠️ Set an MCP server and discover its tools</h2>
|
| 77 |
+
</div>
|
| 78 |
+
""")
|
| 79 |
+
source_selector = gr.Radio(
|
| 80 |
+
choices=["Hackathon candidates", "Custom MCP URL"],
|
| 81 |
+
label="🔀 Source",
|
| 82 |
+
value="Hackathon candidates"
|
| 83 |
+
)
|
| 84 |
+
|
| 85 |
+
hackathon_dropdown = gr.Dropdown(
|
| 86 |
+
label="Select a MCP server from the hackathon organisation",
|
| 87 |
+
choices=get_mcp_space_endpoints(),
|
| 88 |
+
value=DEFAULT_MCP_URL,
|
| 89 |
+
interactive=True,
|
| 90 |
+
visible=True
|
| 91 |
+
)
|
|
|
|
|
|
|
| 92 |
|
| 93 |
+
custom_url_input = gr.Textbox(
|
| 94 |
+
label="Enter custom MCP server URL",
|
| 95 |
+
value="https://agents-mcp-hackathon-mcp-server-demo.hf.space/gradio_api/mcp/sse",
|
| 96 |
+
visible=False
|
| 97 |
+
)
|
| 98 |
+
|
| 99 |
+
def toggle_url_input(source):
|
| 100 |
+
return (
|
| 101 |
+
gr.update(visible=(source == "Hackathon candidates")),
|
| 102 |
+
gr.update(visible=(source == "Custom MCP URL"))
|
| 103 |
+
)
|
| 104 |
+
|
| 105 |
+
def reload_tools_router(source, dropdown_val, custom_val):
|
| 106 |
+
selected_url = dropdown_val if source == "Hackathon candidates" else custom_val
|
| 107 |
+
return reload_tools_from_url(selected_url)
|
| 108 |
|
| 109 |
+
source_selector.change(fn=toggle_url_input, inputs=source_selector, outputs=[hackathon_dropdown, custom_url_input])
|
| 110 |
+
|
| 111 |
+
#print("[MCP] Endpoints loaded:", get_mcp_space_endpoints())
|
| 112 |
+
tool_table = gr.DataFrame(headers=["Tool name", "Description", "Params"], interactive=False, label="🔧 MCP Tools availables", wrap=True)
|
| 113 |
+
reload_btn = gr.Button("🔄 Refresh and set MCP tools list")
|
| 114 |
+
reload_btn.click(
|
| 115 |
+
fn=reload_tools_router,
|
| 116 |
+
inputs=[source_selector, hackathon_dropdown, custom_url_input],
|
| 117 |
+
outputs=tool_table
|
| 118 |
+
)
|
| 119 |
+
hackathon_dropdown.change(
|
| 120 |
+
fn=reload_tools_router,
|
| 121 |
+
inputs=[source_selector, hackathon_dropdown, custom_url_input],
|
| 122 |
+
outputs=tool_table
|
| 123 |
+
)
|
| 124 |
+
custom_url_input.submit(
|
| 125 |
+
fn=reload_tools_router,
|
| 126 |
+
inputs=[source_selector, hackathon_dropdown, custom_url_input],
|
| 127 |
+
outputs=tool_table
|
| 128 |
+
)
|
| 129 |
|
| 130 |
+
gr.Markdown("""
|
| 131 |
+
<div align="center">
|
| 132 |
+
<h2>🔎 Test them with smolagents</h2>
|
| 133 |
+
</div>
|
| 134 |
+
""")
|
| 135 |
+
chatbot = gr.ChatInterface(
|
| 136 |
+
fn=lambda message, history: str(agent.run(message)),
|
| 137 |
+
type="messages",
|
| 138 |
+
)
|
|
|
|
| 139 |
|
| 140 |
demo.launch()
|
| 141 |
|