MakiAi commited on
Commit
8608413
·
verified ·
1 Parent(s): a5ef4df

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +50 -30
app.py CHANGED
@@ -125,12 +125,15 @@ def text_analyzer(text: str) -> str:
125
 
126
  # メインアプリケーションの作成
127
  with gr.Blocks(
128
- title="Gradio Streamable HTTP MCP Demo",
129
  theme=gr.themes.Soft(),
130
  css="""
131
  .tab-nav button {
132
  font-size: 16px !important;
133
  }
 
 
 
134
  """
135
  ) as demo:
136
 
@@ -139,10 +142,10 @@ with gr.Blocks(
139
 
140
  このアプリは、Gradio の新しい **Streamable HTTP Transport for MCP server** 機能のデモです。
141
 
142
- ## 🔗 MCP エンドポイント
143
- アプリ起動後、以下のエンドポイントでMCPツールにアクセスできます:
144
- - **HTTP Transport**: `{APP_URL}/gradio_api/mcp/http/`
145
- - **SSE Transport**: `{APP_URL}/gradio_api/mcp/sse`
146
 
147
  ## 🛠️ 利用可能なツール
148
  """)
@@ -240,43 +243,60 @@ with gr.Blocks(
240
  gr.Markdown("""
241
  ## 📋 MCP クライアントでの使用方法
242
 
243
- 1. **MCP Inspector** でテスト:
244
- ```
245
- https://your-app-url/gradio_api/mcp/http/
246
- ```
247
 
248
- 2. **Claude Desktop** での設定例:
249
- ```json
250
- {
251
- "mcpServers": {
252
- "gradio-demo": {
253
- "command": "curl",
254
- "args": ["-X", "POST", "https://your-app-url/gradio_api/mcp/http/"]
255
- }
256
- }
257
- }
258
- ```
 
 
 
259
 
260
- 3. **利用可能なツール**:
261
- - `calculator`: 数学計算
262
- - `image_processor`: 画像処理
263
- - `text_analyzer`: テキスト分析
264
 
265
  ## 🔧 技術詳細
266
 
267
- - **Transport**: Streamable HTTP
268
- - **Protocol**: MCP (Model Context Protocol)
269
- - **Endpoints**: `/gradio_api/mcp/http/` (HTTP), `/gradio_api/mcp/sse` (SSE)
270
- - **Features**: ファイル入出力、状態管理、リアルタイム処理
 
 
 
 
 
 
 
 
 
 
 
 
271
  """)
272
 
273
- # アプリケーションの設定
 
 
274
  if __name__ == "__main__":
275
  demo.launch(
276
  server_name="0.0.0.0",
277
  server_port=7860,
278
  share=False,
279
  show_error=True,
280
- mcp_server=True, # MCP server を有効化
281
  inbrowser=False
282
  )
 
125
 
126
  # メインアプリケーションの作成
127
  with gr.Blocks(
128
+ title="Gradio Streamable HTTP MCP Demo - MakiAi",
129
  theme=gr.themes.Soft(),
130
  css="""
131
  .tab-nav button {
132
  font-size: 16px !important;
133
  }
134
+ .markdown-body h2 {
135
+ color: #2563eb !important;
136
+ }
137
  """
138
  ) as demo:
139
 
 
142
 
143
  このアプリは、Gradio の新しい **Streamable HTTP Transport for MCP server** 機能のデモです。
144
 
145
+ ## 🔗 ライブ MCP エンドポイント
146
+ 以下のエンドポイントで実際にMCPツールにアクセスできます:
147
+ - **HTTP Transport**: `https://makiai-gradio-streamable-mcp-demo.hf.space/gradio_api/mcp/http/`
148
+ - **SSE Transport**: `https://makiai-gradio-streamable-mcp-demo.hf.space/gradio_api/mcp/sse`
149
 
150
  ## 🛠️ 利用可能なツール
151
  """)
 
243
  gr.Markdown("""
244
  ## 📋 MCP クライアントでの使用方法
245
 
246
+ ### 🧪 **MCP Inspector でテスト**
247
+ ```bash
248
+ npx @modelcontextprotocol/inspector https://makiai-gradio-streamable-mcp-demo.hf.space/gradio_api/mcp/http/
249
+ ```
250
 
251
+ ### 🖥️ **Claude Desktop での設定例**
252
+ ```json
253
+ {
254
+ "mcpServers": {
255
+ "gradio-mcp-demo": {
256
+ "command": "npx",
257
+ "args": [
258
+ "@modelcontextprotocol/server-everything",
259
+ "https://makiai-gradio-streamable-mcp-demo.hf.space/gradio_api/mcp/http/"
260
+ ]
261
+ }
262
+ }
263
+ }
264
+ ```
265
 
266
+ ### 🛠️ **利用可能なツール**
267
+ - **`calculator`**: 基本的な数学計算(加算、減算、乗算、除算、べき乗、平方根)
268
+ - **`image_processor`**: 画像エフェクト処理(ぼかし、シャープ化、明度、コントラスト調整)
269
+ - **`text_analyzer`**: テキスト統計分析(文字数、単語数、文字種別分析)
270
 
271
  ## 🔧 技術詳細
272
 
273
+ - **🌐 Space URL**: [Hugging Face Space](https://huggingface.co/spaces/MakiAi/gradio-streamable-mcp-demo)
274
+ - **🚀 Transport**: Streamable HTTP (最新機能!)
275
+ - **📡 Protocol**: MCP (Model Context Protocol)
276
+ - **🔗 HTTP Endpoint**: `https://makiai-gradio-streamable-mcp-demo.hf.space/gradio_api/mcp/http/`
277
+ - **📺 SSE Endpoint**: `https://makiai-gradio-streamable-mcp-demo.hf.space/gradio_api/mcp/sse`
278
+ - **✨ Features**: ファイル入出力対応、リアルタイム処理、状態管理
279
+
280
+ ## 🎯 デモの特徴
281
+
282
+ このアプリは **Gradio PR #11300** で実装された最新の Streamable HTTP Transport 機能を使用しています。
283
+ 従来のSSE(Server-Sent Events)に加えて、より効率的なHTTP通信でMCPツールを利用できます。
284
+
285
+ **🔗 関連リンク**:
286
+ - [Original PR #11300](https://github.com/gradio-app/gradio/pull/11300)
287
+ - [MCP Protocol](https://modelcontextprotocol.io/)
288
+ - [Gradio MCP Documentation](https://gradio.app/docs/mcp)
289
  """)
290
 
291
+ # アプリケーションの設定とデプロイ
292
+ # Live Demo: https://huggingface.co/spaces/MakiAi/gradio-streamable-mcp-demo
293
+ # MCP HTTP Endpoint: https://makiai-gradio-streamable-mcp-demo.hf.space/gradio_api/mcp/http/
294
  if __name__ == "__main__":
295
  demo.launch(
296
  server_name="0.0.0.0",
297
  server_port=7860,
298
  share=False,
299
  show_error=True,
300
+ mcp_server=True, # 🚀 Streamable HTTP Transport for MCP を有効化!
301
  inbrowser=False
302
  )