|
9 | 9 |
|
10 | 10 | [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.
|
11 | 11 |
|
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). |
13 | 13 |
|
14 | 14 | ## Seamless Local File Support
|
15 | 15 |
|
@@ -37,6 +37,8 @@ As an MCP developer, it's highly recommended to implement your MCP tools to emit
|
37 | 37 |
|
38 | 38 | ## Transform OpenAPI Specs to MCP in One Line
|
39 | 39 |
|
| 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 | + |
40 | 42 | [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!
|
41 | 43 |
|
42 | 44 | ```python
|
@@ -94,9 +96,37 @@ You can read more about this in the Gradio [Guides](https://www.gradio.app/guide
|
94 | 96 |
|
95 | 97 | ## Modifying Tool Descriptions
|
96 | 98 |
|
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). |
98 | 128 |
|
99 | 129 |
|
100 | 130 | ## Conclusion
|
101 | 131 |
|
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