Hi folks! Excited to share a new feature from the Gradio team along with a tutorial.
text
Hi folks! Excited to share a new feature from the Gradio team along with a tutorial.
new_line
new_line
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.
text
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.
new_line
new_line
If you already know how to use Gradio, there are only two additional things you need to do:
text
If you already know how to use Gradio, there are only two additional things you need to do:
new_line
* Add standard docstrings to your function (these will be used to generate the descriptions for your tools for the LLM)
text
* Add standard docstrings to your function (these will be used to generate the descriptions for your tools for the LLM)
new_line
* Set 
text
* Set 
mcp_server=True
`mcp_server=True`
inline_code
 in 
text
 in 
launch()
`launch()`
inline_code
new_line
new_line
text
new_line
Here's a complete example (make sure you already have the latest version of Gradio installed):
text
Here's a complete example (make sure you already have the latest version of Gradio installed):
new_line
text
new_line
new_line
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)
py
```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)
```
code_fence
new_line
new_line
new_line
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](
text
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/
https://huggingface.co/spaces/
link
) as well. 
text
) as well. 
new_line
new_line
All free and open-source of course! Full tutorial: 
text
All free and open-source of course! Full tutorial: 
https://www.gradio.app/guides/building-mcp-server-with-gradio
https://www.gradio.app/guides/building-mcp-server-with-gradio
link
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
🔥
sergo71ua RiverZ John6666 victor 9voltfan2009 drwlf ronedgecomb mrf345 LeroyDyer leeloolee joseEjmendez
🚀
John6666 victor 9voltfan2009 drwlf ZennyKenny LeroyDyer
🤗
John6666 victor 9voltfan2009 LeroyDyer
👍
BuiDoan
65d883893a52cd9bcd8ab7cf
https://cdn-avatars.huggingface.co/v1/production/uploads/65d883893a52cd9bcd8ab7cf/tRsCJlHNZo1D02kBTmfy9.jpeg
leroy Samuel Dyer
LeroyDyer
user
608b8bb39d7c9519b4adae19
https://cdn-avatars.huggingface.co/v1/production/uploads/1621947938344-noauth.png
Abubakar Abid
abidlabs
user