Abubakar Abid's picture

Abubakar Abid

abidlabs

AI & ML interests

self-supervised learning, applications to medicine & biology, interpretation, reproducibility

Recent Activity

replied to their post 1 day ago
Hi folks! Excited to share a new feature from the Gradio team along with a tutorial. If you don't already know, Gradio is an open-source Python library used to build interfaces for machine learning models. Beyond just creating UIs, Gradio also exposes API capabilities and now, Gradio apps can be launched Model Context Protocol (MCP) servers for LLMs. If you already know how to use Gradio, there are only two additional things you need to do: * Add standard docstrings to your function (these will be used to generate the descriptions for your tools for the LLM) * Set `mcp_server=True` in `launch()` Here's a complete example (make sure you already have the latest version of Gradio installed): ```py import gradio as gr def letter_counter(word, letter): """Count the occurrences of a specific letter in a word. Args: word: The word or phrase to analyze letter: The letter to count occurrences of Returns: The number of times the letter appears in the word """ return word.lower().count(letter.lower()) demo = gr.Interface( fn=letter_counter, inputs=["text", "text"], outputs="number", title="Letter Counter", description="Count how many times a letter appears in a word" ) demo.launch(mcp_server=True) ``` This is a very simple example, but you can add the ability to generate Ghibli images or speak emotions to any LLM that supports MCP. Once you have an MCP running locally, you can copy-paste the same app to host it on [Hugging Face Spaces](https://huggingface.co/spaces/) as well. All free and open-source of course! Full tutorial: https://www.gradio.app/guides/building-mcp-server-with-gradio
View all activity

Organizations

Hugging Face's profile picture Org for Gradio Tests's profile picture 🧨Diffusers's profile picture MIT-15.561-2022's profile picture Spaces-explorers's profile picture Gradio Client Demos's profile picture Gradio's profile picture Templates's profile picture CVPR Demo Track's profile picture AUBMC AIM's profile picture Test Demo's profile picture Stanford CS236g 2022's profile picture pytorch's profile picture HF Course Demos's profile picture Sorbonne Université's profile picture Gradio-Themes-Party's profile picture Univ-Pitts-ECE-1395's profile picture Yale CPSC 577's profile picture Gradio-Blocks-Party's profile picture HuggingFaceM4's profile picture Evaluate Metric's profile picture Workshop June 13 Classroom's profile picture Fatima Fellowship's profile picture Hugging Face University 2022's profile picture Hugging Face H4's profile picture Hugging Face OSS Metrics's profile picture Gradio Test Deploy's profile picture Gradio PR Deploys's profile picture IBM-NASA Prithvi Models Family's profile picture UniverseTBD's profile picture Hacktoberfest 2023's profile picture ICML2023's profile picture Gradio Discord Bots's profile picture Gradio Templates's profile picture Gradio Community's profile picture Social Post Explorers's profile picture Meta Llama's profile picture smolagents's profile picture Inference Endpoints Images's profile picture

Posts 17

view post
Post
2930
HOW TO ADD MCP SUPPORT TO ANY 🤗 SPACE

Gradio now supports MCP! If you want to convert an existing Space, like this one hexgrad/Kokoro-TTS, so that you can use it with Claude Desktop / Cursor / Cline / TinyAgents / or any LLM that supports MCP, here's all you need to do:

1. Duplicate the Space (in the Settings Tab)
2. Upgrade the Gradio sdk_version to 5.28 (in the README.md)
3. Set mcp_server=True in launch()
4. (Optionally) add docstrings to the function so that the LLM knows how to use it, like this:

def generate(text, speed=1):
    """
    Convert text to speech audio.

    Parameters:
        text (str): The input text to be converted to speech.
        speed (float, optional): Playback speed of the generated speech.


That's it! Now your LLM will be able to talk to you 🤯

Articles 12

Article
65

How to Build an MCP Server with Gradio