import gradio as gr import os from mcp import StdioServerParameters from smolagents import InferenceClientModel, CodeAgent, MCPClient import pandas as pd import requests DEFAULT_MCP_URL = "https://alihmaou-mcp-tools.hf.space/gradio_api/mcp/sse" HF_TOKEN = os.getenv("HUGGINGFACE_API_TOKEN") def get_mcp_space_endpoints(): """Fetch MCP-compatible Spaces from the HF Hackathon org.""" try: resp = requests.get("https://huggingface.co/api/spaces?author=Agents-MCP-Hackathon") resp.raise_for_status() spaces = resp.json() except Exception as e: print(f"[Warning] Failed to fetch MCP spaces: {e}") return [DEFAULT_MCP_URL] endpoints = [DEFAULT_MCP_URL] for space in spaces: if "mcp-server" in space.get("tags", []): full_id = space["id"] slug = full_id.replace("/", "-").replace("_", "-").lower() endpoint = f"https://{slug}.hf.space/gradio_api/mcp/sse" if endpoint != DEFAULT_MCP_URL: endpoints.append(endpoint) return endpoints def reload_tools_from_url(mcp_url_input): global tools, agent, mcp_client, mcp_url mcp_url=mcp_url_input try: mcp_client = MCPClient({"url": mcp_url,"transport": "sse"}) # Might be deprecated soon but didnt find out the clean way tools = mcp_client.get_tools() model = InferenceClientModel(token=os.getenv("HUGGINGFACE_API_TOKEN")) agent = CodeAgent(tools=tools, model=model,) except Exception as e: print(f"[Warning] Failed to reach MCP server: {e}") # Tableau structuré : nom, description, inputs attendus rows = [] for tool in tools: input_fields = ", ".join(param for param in tool.inputs) rows.append({ "Tool name": tool.name, "Description": tool.description, "Params": input_fields }) df = pd.DataFrame(rows) return gr.DataFrame(value=df) with gr.Blocks() as demo: gr.Markdown("""
🔍 Query any MCP-compatible endpoint, 🛠️ browse available tools in a clean table view, and 🤖 test real-time interactions using a `smolagent` powered by `HuggingFace`.
Perfect for 🧪 exploring fellow participants’ tools or 🧰 debugging your own MCP server during the event!
🍒 As a cherry on the cake, the list of the tools developed for the hackathon will be updated here from time to time (see src/bonus.py) : Ready to use hackathon MCP tools list