Spaces:
Sleeping
Sleeping
File size: 1,256 Bytes
6d823c7 |
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} |