Gradio is an open source Python package for creating AI-powered web applications. Gradio is MCP Server protocol compliant and powers thousands of MCP servers hosted by embracing face spaces. The Gradio team is making a big bet on gradients and space, the best way to build and host AI-powered MCP servers.
To that end, here are some of the major improvements we’ve added to the Gradio MCP server, such as version 5.38.0.
Seamless local file support
If you were trying to use a remote gradient MCP server that uses the file as input (image, video, audio), you probably encountered this error.
This occurs because the Gradio Server is hosted on another machine. This means that the input file can be accessed via a public URL and can be downloaded remotely.
There are many ways to host files online, but they all add manual steps to your workflow. In the age of LLM agents, shouldn’t you expect them to handle this for you?
Gradio now includes a “File Upload” MCP server that agents can use to upload files directly to grade applications. If the Gradio MCP server tool requires file entry, the connection document shows how to start the “File Upload” MCP server.
Learn more about using this server (and critical security considerations) in the Gradio Guide.
Real-time progress notifications
Depending on your AI task, it may take some time to get results. Now, Gradio Streams Progress notifications provide notifications to MCP clients and allow you to monitor status in real time.
As an MCP developer, I highly recommend implementing MCP tools to release these progressions. Our guide shows you how to do that.
Convert Openapi spec to MCP in one line
If you want to integrate an existing backend API into LLM, you will need to manually map the API endpoints to the MCP tool. This can be a time-consuming and error-prone chore. With this release, Gradio can automate the entire process! A single code allows you to integrate your business backend into an MCP-compatible LLM.
Openapi is a standard widely adopted for writing RESTFUL APIs in machine readable format, usually as JSON files. Gradio now has the Gr.load_openapi function. This creates the Gradio application directly from the Openapi schema. You can then launch the app with MCP_SERVER = TRUE to automatically create an MCP server for your API.
Import Gradation As Gr demo = gr.load_openapi(openapi_spec =“https://petstore3.swagher.io/api/v3/openapi.json”base_url =“https://petstore3.swagher.io/api/v3”,paths =(“/Pets.*”), method = ((“obtain”, “post”),) demo.launch(mcp_server =truth))
Find out more in Gradio Guides.
Improved authentication
A common pattern in MCP server development is to use authentication headers to invoke services on behalf of the user. As an MCP server developer, I want to clearly communicate with users the credentials needed to provide the appropriate server usage.
To make this possible, you can now enter arguments for the MCP server as Gr.Header. Gradio automatically extracts its header from incoming requests (if any) and passes it to the function. The advantage of using Gr.header is that it automatically displays the headers that MCP connection documents need to provide when connecting to the server.
In the example below, the X-API-TOKEN header is extracted from the incoming request and passed as the X_API_TOKEN argument to MAKE_API_REQUEST_ON_BEHALF_OF_USER.
Import Gradation As gr
def make_api_request_on_behalf_of_user(prompt: strx_api_token:gr.header):
“” “Make requests to everyone’s favorite APIs.
args:
Prompt: A prompt to send to the API.
Returns:
Response from the API.
Salary raise:
ASSERTIONERROR: If the API token is not valid.
“” “
return “Hello from API” if do not have x_api_token Other than that “Hello from the API with tokens!”
demo = gr.interface(make_api_request_on_behalf_of_user,(gr.textbox(label=.)“prompt”),), gr.textbox(label =“response”),) demo.launch(mcp_server =truth))
For more information, see Gradio Guides.
Change tool description
Gradio automatically generates a description of the tool from the function names and Docstrings. You can now further customize the tool description with the API_Description Card. In this example, the tool description reads “Apply sepia filter to any image.”
Import Gradation As gr
Import numpy As np
def sepia(input_img):
“” “
args:
input_img (NP.Array): Input image to which the SEPIA filter is applied.
Returns:
Sepia filtered image.
“” “
sepia_filter = np.array(((())0.393, 0.769, 0.189), (0.349, 0.686, 0.168), (0.272, 0.534, 0.131))) sepia_img = input_img.dot(sepia_filter.t) sepia_img /= sepia_img.Max()
return sepia_img gr.interface(sepia, “image”, “image”,api_description =“Apply a sepia filter to any image.”)\.launch(mcp_server =truth))
Read the details in our guide.
Conclusion
Would you like to see Gradio add a new MCP-related feature? Let us know in the blog or in the comments on github. Also, if you have built a cool MCP server or Gradio app, let us know in the comments.