Skip to content

Commit 425b6d1

Browse files
Update
1 parent 79cd4a2 commit 425b6d1

File tree

1 file changed

+33
-3
lines changed

1 file changed

+33
-3
lines changed

gradio-mcp-updates.md

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ authors:
99

1010
[Gradio](https://gradio.app) is an open-source Python package for creating AI-powered web applications. Gradio is compliant with the [MCP server protocol](https://modelcontextprotocol.io/introduction) and powers thousands of MCP servers hosted on [Hugging Face Spaces](https://hf.co/spaces). The Gradio team is **betting big** on Gradio and Spaces being the best way to build and host AI-powered MCP servers.
1111

12-
To that end, here are some of the big improvements we've added to Gradio MCP servers as of version **5.38.0**.
12+
To that end, here are some of the big improvements we've added to Gradio MCP servers as of version [5.38.0](https://github.com/gradio-app/gradio/releases/tag/gradio%405.38.0).
1313

1414
## Seamless Local File Support
1515

@@ -37,6 +37,8 @@ As an MCP developer, it's highly recommended to implement your MCP tools to emit
3737

3838
## Transform OpenAPI Specs to MCP in One Line
3939

40+
If you want to integrate an existing backend API into an LLM, you have to manually map API endpoints to MCP tools. This can be a time consuming and error prone chore. With this release, Gradio can automate the entire process for you! With a single line of code, you can integrate your business backend into any MCP-compatible LLM.
41+
4042
[OpenAPI](https://www.openapis.org/) is a widely adopted standard for describing RESTful APIs in a machine-readable format, typically as a JSON file. Gradio now features the `gr.load_openapi` function, which creates a Gradio application directly from an OpenAPI schema. You can then launch the app with `mcp_server=True` to automatically create an MCP server for your API!
4143

4244
```python
@@ -94,9 +96,37 @@ You can read more about this in the Gradio [Guides](https://www.gradio.app/guide
9496

9597
## Modifying Tool Descriptions
9698

97-
Gradio automatically generates tool descriptions from your function names and docstrings. Now you can customize the tool description even further with the `api_description` parmeter. Read more in the [guide](https://www.gradio.app/guides/building-mcp-server-with-gradio#modifying-tool-descriptions).
99+
Gradio automatically generates tool descriptions from your function names and docstrings. Now you can customize the tool description even further with the `api_description` parmeter. In this example, the tool description will read "Apply a sepia filter to any image."
100+
101+
```python
102+
import gradio as gr
103+
import numpy as np
104+
105+
def sepia(input_img):
106+
"""
107+
Args:
108+
input_img (np.array): The input image to apply the sepia filter to.
109+
110+
Returns:
111+
The sepia filtered image.
112+
"""
113+
sepia_filter = np.array([
114+
[0.393, 0.769, 0.189],
115+
[0.349, 0.686, 0.168],
116+
[0.272, 0.534, 0.131]
117+
])
118+
sepia_img = input_img.dot(sepia_filter.T)
119+
sepia_img /= sepia_img.max()
120+
return sepia_img
121+
122+
gr.Interface(sepia, "image", "image",
123+
api_description="Apply a sepia filter to any image.")\
124+
.launch(mcp_server=True)
125+
```
126+
127+
Read more in the [guide](https://www.gradio.app/guides/building-mcp-server-with-gradio#modifying-tool-descriptions).
98128

99129

100130
## Conclusion
101131

102-
Want us to add a new MCP-related feature to Gradio? Let us know in the comments of the blog or on [GitHub](https://github.com/gradio-app/gradio/issues)
132+
Want us to add a new MCP-related feature to Gradio? Let us know in the comments of the blog or on [GitHub](https://github.com/gradio-app/gradio/issues). Also if you've built a cool MCP server or Gradio app let us know in the comments and we'll amplify it!

0 commit comments

Comments
 (0)