Content
---
title: Gradio MCP Minimal
emoji: 🌍
colorFrom: blue
colorTo: blue
sdk: gradio
sdk_version: 5.26.0
app_file: app.py
pinned: false
---
<div align="center">

# 🚀 **Gradio MCP Minimal**
<p align="center">
<a href="https://www.python.org">
<img alt="Python" src="https://img.shields.io/badge/Python-3.12-blue?logo=python&logoColor=white">
</a>
<a href="https://www.gradio.app">
<img alt="Gradio" src="https://img.shields.io/badge/Gradio-5.26.0-orange?logo=gradio">
</a>
<a href="https://github.com/makiai/gradio-mcp-minimal/blob/main/LICENSE">
<img alt="License: MIT" src="https://img.shields.io/badge/License-MIT-green">
</a>
<a href="https://github.com/makiai/gradio-mcp-minimal/stargazers">
<img alt="GitHub Stars" src="https://img.shields.io/github/stars/makiai/gradio-mcp-minimal?style=social">
</a>
<a href="https://huggingface.co/spaces/MakiAi/gradio-mcp-minimal">
<img alt="HF Spaces" src="https://img.shields.io/badge/Spaces-Live%20Demo-blueviolet?logo=huggingface&logoColor=white">
</a>
</p>
</div>
## ✨ Overview
This repository is a sample that launches a Gradio app with a **minimal configuration** while also functioning as an **MCP (Model Context Protocol) server**.
By executing just one file, you will have access to both the Web UI and the MCP SSE endpoint.
## 📄 File Structure
| File / Directory | Role |
|------------------------|-------------------------------------------|
| `app.py` | Gradio UI + MCP server (`letter_counter` tool) |
| `requirements.txt` | Dependency packages (only `gradio[mcp]`) |
| `assets/header.svg` | Header image for README (optional) |
## 📦 Setup
### 🚀 Quick Start with uv (Recommended)
```bash
# Create a virtual environment
uv venv
# Activate the virtual environment
source .venv/bin/activate
# Install dependencies
uv pip install -r requirements.txt
```
### 🐍 If you want to run with standard pip only
```bash
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
```
## 🚀 Run
Execute the following command to start the local server.
```bash
python app.py
```
- Web UI: <http://127.0.0.1:7860>
- MCP SSE Endpoint: <http://127.0.0.1:7860/gradio_api/mcp/sse>
- In the UI footer → click **View API** → **MCP** to display a copyable configuration JSON.
## ⚙️ Example MCP Client Configuration
Add to `claude_desktop_config.json` or similar in Claude Desktop / Cline:
```jsonc
{
"mcpServers": {
"gradio-local": {
"url": "http://127.0.0.1:7860/gradio_api/mcp/sse"
}
}
}
```
After restarting the client, the `letter_counter` tool will be available 🎉
## 🔧 Mechanism
```python
demo.launch(mcp_server=True)
```
With this single line, the Gradio app operates as an SSE-based MCP server.
Schemas are automatically generated from the docstrings and type hints.
## 🌠 How to Extend
1. Add functions to `app.py` and write appropriate docstrings.
2. Register them in `Interface(...)` (or use Blocks).
3. Restart to automatically publish as new MCP tools.
## 🛫 Free Deployment to 🤗 Spaces
Push all files to Hugging Face Spaces (Gradio template) to create a free public MCP server:
```
https://<your-space>.hf.space/gradio_api/mcp/sse
```
Example: `https://makiai-gradio-mcp-minimal.hf.space/gradio_api/mcp/sse`
## 🔗 Example MCP Client Configuration (Spaces)
Here are the steps to call the server published on Spaces from an **MCP client (Claude Desktop / Cline, etc.)**.
1. **Endpoint URL**
```
https://<your-space>.hf.space/gradio_api/mcp/sse
```
Example: `https://makiai-gradio-mcp-minimal.hf.space/gradio_api/mcp/sse`
2. **Example config addition** (`claude_desktop_config.json`, etc.)
```jsonc
{
"mcpServers": {
"gradio-space": { // Any name
"url": "https://makiai-gradio-mcp-minimal.hf.space/gradio_api/mcp/sse"
}
}
}
```
3. **Functionality Check**
Restart the client → Select `server = gradio-space` in the Tool Palette →
Send `text: "hello"` to the `letter_counter` tool, and if `length: 5` is returned, the connection is complete 🎉
## 📝 License
MIT
Connection Info
You Might Also Like
Fetch
Model Context Protocol Servers
semantic-kernel
Integrate cutting-edge LLM technology quickly and easily into your apps
repomix
Repomix packages your codebase into AI-friendly formats for seamless integration.
SmartDB_MCP
Universal database MCP server connecting to MySQL, PostgreSQL, SQL Server,...
awesome-context-engineering
A curated list of awesome open-source libraries for context engineering...
aks-mcp
A Model Context Protocol (MCP) server that enables AI assistants to interact...