|
| 1 | +--- |
| 2 | +title: Examples |
| 3 | +sidebarTitle: Examples |
| 4 | +description: Example apps you can run right now. |
| 5 | +icon: images |
| 6 | +tag: NEW |
| 7 | +--- |
| 8 | + |
| 9 | +import { VersionBadge } from '/snippets/version-badge.mdx' |
| 10 | + |
| 11 | +<VersionBadge version="3.2.0" /> |
| 12 | + |
| 13 | +Every example below is a working FastMCP server you can run with `fastmcp dev apps` or connect to from any MCP host. The source is in `examples/apps/` in the repository. |
| 14 | + |
| 15 | +<Columns cols={2}> |
| 16 | + <Tile href="#sales-dashboard" title="Sales Dashboard" description="Metrics, charts, and deal pipeline"> |
| 17 | + <div style={{overflow: "hidden", width: "100%"}}> |
| 18 | + <img src="/apps/images/app-example-sales-dashboard.png" /> |
| 19 | + </div> |
| 20 | + </Tile> |
| 21 | + <Tile href="#system-monitor" title="System Monitor" description="Live CPU, memory, disk with auto-refresh"> |
| 22 | + <img src="/apps/images/app-example-system-dashboard.png" /> |
| 23 | + </Tile> |
| 24 | + <Tile href="#quiz" title="Quiz" description="LLM-generated trivia with scoring"> |
| 25 | + <img src="/apps/images/app-example-quiz.png" /> |
| 26 | + </Tile> |
| 27 | + <Tile href="#interactive-map" title="Interactive Map" description="Geocoded addresses on Leaflet"> |
| 28 | + <img src="/apps/images/app-example-map.png" /> |
| 29 | + </Tile> |
| 30 | + <Tile href="/apps/providers/file-upload" title="File Upload" description="Drag-and-drop upload provider"> |
| 31 | + <img src="/apps/images/app-file-upload.png" /> |
| 32 | + </Tile> |
| 33 | + <Tile href="/apps/providers/approval" title="Approval" description="Human-in-the-loop confirmation"> |
| 34 | + <img src="/apps/images/app-approval.png" /> |
| 35 | + </Tile> |
| 36 | + <Tile href="/apps/providers/choice" title="Choice" description="Clickable option selection"> |
| 37 | + <img src="/apps/images/app-choice.png" /> |
| 38 | + </Tile> |
| 39 | + <Tile href="/apps/providers/form" title="Form Input" description="Pydantic model forms"> |
| 40 | + <img src="/apps/images/app-form.png" /> |
| 41 | + </Tile> |
| 42 | + <Tile href="/apps/generative" title="Generative UI" description="LLM writes the UI at runtime"> |
| 43 | + <img src="/apps/images/app-showcase.png" /> |
| 44 | + </Tile> |
| 45 | +</Columns> |
| 46 | + |
| 47 | +## Running Examples |
| 48 | + |
| 49 | +Preview any example in your browser with the dev server: |
| 50 | + |
| 51 | +```bash |
| 52 | +pip install "fastmcp[apps]" |
| 53 | +fastmcp dev apps examples/apps/sales_dashboard/sales_dashboard_server.py |
| 54 | +``` |
| 55 | + |
| 56 | +The dev server opens an interactive browser UI where you can select a tool and provide arguments. In a real deployment, the LLM provides these arguments on the fly based on the conversation. For example, the quiz example works best when connected to an MCP host like Goose or Claude Desktop, where the LLM generates the questions itself. |
| 57 | + |
| 58 | +## Standalone Examples |
| 59 | + |
| 60 | +### Sales Dashboard |
| 61 | + |
| 62 | +A full dashboard with KPI metrics, revenue trends, segment breakdown, and a deal pipeline table. Shows what you can build with a single `app=True` tool and Prefab's chart and data components. |
| 63 | + |
| 64 | +```bash |
| 65 | +fastmcp dev apps examples/apps/sales_dashboard/sales_dashboard_server.py |
| 66 | +``` |
| 67 | + |
| 68 | +### System Monitor |
| 69 | + |
| 70 | +Reads live CPU, memory, and disk stats from your machine using `psutil`. Auto-refreshes via `SetInterval` calling a backend tool, with a dropdown to control the refresh rate. The chart accumulates 100 data points over time. |
| 71 | + |
| 72 | +```bash |
| 73 | +pip install psutil |
| 74 | +fastmcp dev apps examples/apps/system_monitor/system_monitor_server.py |
| 75 | +``` |
| 76 | + |
| 77 | +### Quiz |
| 78 | + |
| 79 | +The LLM generates trivia questions and passes them to the tool. The user answers via buttons, sees correct/incorrect feedback, and tracks score across questions. Demonstrates multi-turn client-side state with FastMCPApp. |
| 80 | + |
| 81 | +```bash |
| 82 | +fastmcp dev apps examples/apps/quiz/quiz_server.py |
| 83 | +``` |
| 84 | + |
| 85 | +### Interactive Map |
| 86 | + |
| 87 | +Accepts addresses or place names, geocodes them via OpenStreetMap Nominatim (free, no API key), and renders an interactive Leaflet map using Prefab's `Embed` component with inline HTML. Proves that Prefab apps aren't limited to built-in components. |
| 88 | + |
| 89 | +```bash |
| 90 | +fastmcp dev apps examples/apps/map/map_server.py |
| 91 | +``` |
| 92 | + |
| 93 | +## Built-in Providers |
| 94 | + |
| 95 | +These are ready-made capabilities you add with a single `add_provider()` call. |
| 96 | + |
| 97 | +### [File Upload](/apps/providers/file-upload) |
| 98 | + |
| 99 | +Drag-and-drop file upload. The user drops files, clicks Upload, and the server stores them. The LLM can list and read uploaded files through model-visible tools. |
| 100 | + |
| 101 | +```python |
| 102 | +from fastmcp.apps.file_upload import FileUpload |
| 103 | +mcp.add_provider(FileUpload()) |
| 104 | +``` |
| 105 | + |
| 106 | +### [Approval](/apps/providers/approval) |
| 107 | + |
| 108 | +Human-in-the-loop confirmation. The LLM presents what it's about to do, the user clicks Approve or Reject, and the decision flows back as a message. |
| 109 | + |
| 110 | +```python |
| 111 | +from fastmcp.apps.approval import Approval |
| 112 | +mcp.add_provider(Approval()) |
| 113 | +``` |
| 114 | + |
| 115 | +### [Choice](/apps/providers/choice) |
| 116 | + |
| 117 | +Present clickable options instead of asking users to type. Clean structured input without parsing free text. |
| 118 | + |
| 119 | +```python |
| 120 | +from fastmcp.apps.choice import Choice |
| 121 | +mcp.add_provider(Choice()) |
| 122 | +``` |
| 123 | + |
| 124 | +### [Form Input](/apps/providers/form) |
| 125 | + |
| 126 | +Generate a validated form from a Pydantic model. Submission is validated against the model before being returned. |
| 127 | + |
| 128 | +```python |
| 129 | +from fastmcp.apps.form import FormInput |
| 130 | +mcp.add_provider(FormInput(model=MyModel)) |
| 131 | +``` |
| 132 | + |
| 133 | +### [Generative UI](/apps/providers/generative) |
| 134 | + |
| 135 | +The LLM writes Prefab Python code at runtime and the result renders as a streaming interactive UI. Tailored visualizations for any data. See the [full guide](/apps/generative) for details. |
| 136 | + |
| 137 | +```python |
| 138 | +from fastmcp.apps.generative import GenerativeUI |
| 139 | +mcp.add_provider(GenerativeUI()) |
| 140 | +``` |
0 commit comments