MCP ExplorerExplorer

Gradio Mcp Minimal

@Sunwood-ai-labson 9 months ago
1 MIT
FreeCommunity
AI Systems
Gradio MCP Minimal is a simple app using Gradio 5.26.0 for interactive demos.

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.

Content


title: Gradio MCP Minimal
emoji: 🌍
colorFrom: blue
colorTo: blue
sdk: gradio
sdk_version: 5.26.0
app_file: app.py
pinned: false

Image

🚀 Gradio MCP Minimal

Python Gradio License: MIT GitHub Stars HF Spaces

✨ 概要

このリポジトリは 最小構成 で 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

⚙️ 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 サーバーとして動作します。
ドキュストリングと型ヒントから自動でスキーマが生成されます。

🌠 拡張方法

  1. app.py に関数を追加し、適切なドキュストリングを記述
  2. Interface(...) へ登録(または Blocks を使用)
  3. 再起動すれば新しい 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 など) から呼び出す手順です。

  1. エンドポイント URL

    https://<your-space>.hf.space/gradio_api/mcp/sse
    

    例)https://makiai-gradio-mcp-minimal.hf.space/gradio_api/mcp/sse

  2. config 追記例 (claude_desktop_config.json 等)

    {
      "mcpServers": {
        "gradio-space": {                // 任意の名前
          "url": "https://makiai-gradio-mcp-minimal.hf.space/gradio_api/mcp/sse"
        }
      }
    }
    
  3. 動作確認
    クライアントを再起動 → Tool Palette で server = gradio-space を選択 →
    letter_counter ツールに text: "hello" を送信し、length: 5 が返れば接続完了です 🎉

📝 ライセンス

MIT

Tools

No tools

Comments

Recommend MCP Servers

View All MCP Servers