freddyaboulton HF Staff commited on
Commit
6d823c7
·
verified ·
1 Parent(s): 9c3ca08

Upload folder using huggingface_hub

Browse files
Files changed (3) hide show
  1. README.md +7 -7
  2. run.ipynb +1 -0
  3. run.py +27 -0
README.md CHANGED
@@ -1,12 +1,12 @@
 
1
  ---
2
- title: Mcp Tool Only
3
- emoji: 👁
4
  colorFrom: indigo
5
- colorTo: red
6
  sdk: gradio
7
- sdk_version: 5.33.2
8
- app_file: app.py
9
  pinned: false
 
10
  ---
11
-
12
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
1
+
2
  ---
3
+ title: mcp_tool_only
4
+ emoji: 🔥
5
  colorFrom: indigo
6
+ colorTo: indigo
7
  sdk: gradio
8
+ sdk_version: 5.34.0
9
+ app_file: run.py
10
  pinned: false
11
+ hf_oauth: true
12
  ---
 
 
run.ipynb ADDED
@@ -0,0 +1 @@
 
 
1
+ {"cells": [{"cell_type": "markdown", "id": "302934307671667531413257853548643485645", "metadata": {}, "source": ["# Gradio Demo: mcp_tool_only"]}, {"cell_type": "code", "execution_count": null, "id": "272996653310673477252411125948039410165", "metadata": {}, "outputs": [], "source": ["!pip install -q gradio "]}, {"cell_type": "code", "execution_count": null, "id": "288918539441861185822528903084949547379", "metadata": {}, "outputs": [], "source": ["import gradio as gr\n", "\n", "def slice_list(lst: list, start: int, end: int) -> list:\n", " \"\"\"\n", " A tool that slices a list given a start and end index.\n", " Args:\n", " lst: The list to slice.\n", " start: The start index.\n", " end: The end index.\n", " Returns:\n", " The sliced list.\n", " \"\"\"\n", " return lst[start:end]\n", "\n", "with gr.Blocks() as demo:\n", " gr.Markdown(\n", " \"\"\"\n", " This is a demo of a MCP-only tool.\n", " This tool slices a list.\n", " This tool is MCP-only, so it does not have a UI.\n", " \"\"\"\n", " )\n", " gr.api(\n", " slice_list\n", " )\n", "\n", "_, url, _ = demo.launch(mcp_server=True)"]}], "metadata": {}, "nbformat": 4, "nbformat_minor": 5}
run.py ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+
3
+ def slice_list(lst: list, start: int, end: int) -> list:
4
+ """
5
+ A tool that slices a list given a start and end index.
6
+ Args:
7
+ lst: The list to slice.
8
+ start: The start index.
9
+ end: The end index.
10
+ Returns:
11
+ The sliced list.
12
+ """
13
+ return lst[start:end]
14
+
15
+ with gr.Blocks() as demo:
16
+ gr.Markdown(
17
+ """
18
+ This is a demo of a MCP-only tool.
19
+ This tool slices a list.
20
+ This tool is MCP-only, so it does not have a UI.
21
+ """
22
+ )
23
+ gr.api(
24
+ slice_list
25
+ )
26
+
27
+ _, url, _ = demo.launch(mcp_server=True)