- Explore MCP Servers
- gradio-mcp-minimal
Gradio Mcp Minimal
What is Gradio Mcp Minimal
Gradio MCP Minimal is a minimal setup for launching a Gradio application that also functions as a Model Context Protocol (MCP) server. It allows users to run a web UI and an MCP SSE endpoint with just one file.
Use cases
Use cases include deploying machine learning models with a user-friendly interface, creating interactive data visualizations, and providing real-time model predictions through the MCP protocol.
How to use
To use Gradio MCP Minimal, create a virtual environment, activate it, install the required dependencies from ‘requirements.txt’, and run the application using the command ‘python app.py’. The web UI will be accessible at http://127.0.0.1:7860.
Key features
Key features include a simple setup with a single file, integration of Gradio UI with MCP server capabilities, and the ability to access both a web interface and an MCP SSE endpoint.
Where to use
Gradio MCP Minimal can be used in various fields such as machine learning, data science, and web application development, where interactive interfaces for models are needed.
Clients Supporting MCP
The following are the main client software that supports the Model Context Protocol. Click the link to visit the official website for more information.
Overview
What is Gradio Mcp Minimal
Gradio MCP Minimal is a minimal setup for launching a Gradio application that also functions as a Model Context Protocol (MCP) server. It allows users to run a web UI and an MCP SSE endpoint with just one file.
Use cases
Use cases include deploying machine learning models with a user-friendly interface, creating interactive data visualizations, and providing real-time model predictions through the MCP protocol.
How to use
To use Gradio MCP Minimal, create a virtual environment, activate it, install the required dependencies from ‘requirements.txt’, and run the application using the command ‘python app.py’. The web UI will be accessible at http://127.0.0.1:7860.
Key features
Key features include a simple setup with a single file, integration of Gradio UI with MCP server capabilities, and the ability to access both a web interface and an MCP SSE endpoint.
Where to use
Gradio MCP Minimal can be used in various fields such as machine learning, data science, and web application development, where interactive interfaces for models are needed.
Clients Supporting MCP
The following are the main client software that supports the Model Context Protocol. Click the link to visit the official website for more information.
Content
title: Gradio MCP Minimal
emoji: 🌍
colorFrom: blue
colorTo: blue
sdk: gradio
sdk_version: 5.26.0
app_file: app.py
pinned: false
✨ 概要
このリポジトリは 最小構成 で Gradio アプリを立ち上げ、同時に MCP (Model Context Protocol) サーバー として機能させるサンプルです。
たった 1 つのファイルを実行するだけで、Web UI と MCP SSE エンドポイントの両方が手に入ります。
📄 ファイル構成
| ファイル / ディレクトリ | 役割 |
|---|---|
app.py |
Gradio UI + MCP サーバー(letter_counter ツール) |
requirements.txt |
依存パッケージ(gradio[mcp] のみ) |
assets/header.svg |
README 用ヘッダー画像(任意) |
📦 セットアップ
🚀 uv を使ったクイックスタート(推奨)
# 仮想環境の作成
uv venv
# 仮想環境の有効化
source .venv/bin/activate
# 依存インストール
uv pip install -r requirements.txt
🐍 標準 pip のみで実行したい場合
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
🚀 実行
以下のコマンドを実行でローカルサーバーが起動します。
python app.py
- Web UI: http://127.0.0.1:7860
- MCP SSE エンドポイント: http://127.0.0.1:7860/gradio_api/mcp/sse
- UI フッター → View API → MCP をクリックすると、コピペ可能な設定 JSON が表示されます。
⚙️ MCP クライアント設定例
Claude Desktop / Cline などで claude_desktop_config.json 等に追記:
{
"mcpServers": {
"gradio-local": {
"url": "http://127.0.0.1:7860/gradio_api/mcp/sse"
}
}
}
クライアントを再起動すると letter_counter ツールが利用できるようになります 🎉
🔧 仕組み
demo.launch(mcp_server=True)
この 1 行で Gradio アプリが SSE ベースの MCP サーバーとして動作します。
ドキュストリングと型ヒントから自動でスキーマが生成されます。
🌠 拡張方法
app.pyに関数を追加し、適切なドキュストリングを記述Interface(...)へ登録(または Blocks を使用)- 再起動すれば新しい MCP ツールとして自動公開
🛫 🤗 Spaces へ無料デプロイ
ファイル一式を Hugging Face Spaces (Gradio テンプレート) へプッシュすると、無料の公開 MCP サーバーになります:
https://<your-space>.hf.space/gradio_api/mcp/sse
例)https://makiai-gradio-mcp-minimal.hf.space/gradio_api/mcp/sse
🔗 MCP クライアント設定例 (Spaces)
Spaces で公開したサーバーを MCP クライアント(Claude Desktop / Cline など) から呼び出す手順です。
-
エンドポイント URL
https://<your-space>.hf.space/gradio_api/mcp/sse例)
https://makiai-gradio-mcp-minimal.hf.space/gradio_api/mcp/sse -
config 追記例 (
claude_desktop_config.json等){ "mcpServers": { "gradio-space": { // 任意の名前 "url": "https://makiai-gradio-mcp-minimal.hf.space/gradio_api/mcp/sse" } } } -
動作確認
クライアントを再起動 → Tool Palette でserver = gradio-spaceを選択 →
letter_counterツールにtext: "hello"を送信し、length: 5が返れば接続完了です 🎉
📝 ライセンス
MIT
Dev Tools Supporting MCP
The following are the main code editors that support the Model Context Protocol. Click the link to visit the official website for more information.










