mirror of
https://github.com/PrefectHQ/fastmcp.git
synced 2026-08-09 23:29:10 +02:00
* Add FastMCPApp — a Provider for composable MCP applications * Wire Prefab callable resolver via to_json(tool_resolver=) parameter * Remove inspect.signature compat check, use try/except until prefab 0.10.0 * Address review: fix add_tool registry gaps, normalize auth errors, bump prefab to 0.10.0 * Register global key after _add_component succeeds * Simplify: extract decorator dispatch, use get_fastmcp_meta, expose get_global_tool * Remove prek from Marvin workflows These workflows run Claude to respond to /marvin mentions — linting the repo is unnecessary and fails without renderer deps installed. * Return ResolvedTool from callable resolver, add contacts example The callable resolver now returns ResolvedTool (from prefab_ui) instead of a plain string, carrying metadata like unwrap_result that the renderer needs to correctly handle structuredContent envelopes. The unwrap_result flag is derived from the tool's x-fastmcp-wrap-result output schema marker. * Bump prefab-ui requirement to >=0.11.0 * Remove stale ty ignore comments now that prefab-ui 0.11 is published * Add fastmcp dev apps command with browser UI preview * Improve fastmcp dev apps: dropdown picker, reload flag, process cleanup - Replace Tabs with Pages+Select for tool picker (Rx-based reactive state) - Add --reload/--no-reload flag (default: True) to fastmcp dev apps - Kill entire process group on shutdown so port 8000 is freed properly - Suppress uvicorn websockets deprecation warning (websockets-sansio) - Bump prefab-ui to >=0.11.1 (fixes get_renderer_head bug in 0.11.0) - Add farewell tool to greet_server example for multi-tool testing * Add docs for fastmcp dev apps command * Fix orphaned server on startup failure, guard Unix-only signal handling * Show tool title in picker, remove editable prefab source * Bump prefab-ui to >=0.11.2 * Fail fast when prefab-ui is not installed * Add apps/development docs, link from prefab and sidebar * Fix optional field defaults, fail with non-zero on startup timeout
104 lines
3.9 KiB
Text
104 lines
3.9 KiB
Text
---
|
|
title: CLI
|
|
sidebarTitle: Overview
|
|
description: The fastmcp command-line interface
|
|
icon: terminal
|
|
---
|
|
|
|
import { VersionBadge } from '/snippets/version-badge.mdx'
|
|
|
|
The `fastmcp` CLI is installed automatically with FastMCP. It's the primary way to run, test, install, and interact with MCP servers from your terminal.
|
|
|
|
```bash
|
|
fastmcp --help
|
|
```
|
|
|
|
## Commands at a Glance
|
|
|
|
| Command | What it does |
|
|
| ------- | ------------ |
|
|
| [`run`](/cli/running) | Run a server (local file, factory function, remote URL, or config file) |
|
|
| [`dev apps`](/cli/running#previewing-apps) | Launch a browser-based preview UI for Prefab App tools |
|
|
| [`dev inspector`](/cli/running#development-with-the-inspector) | Launch a server inside the MCP Inspector for interactive testing |
|
|
| [`install`](/cli/install-mcp) | Install a server into Claude Code, Claude Desktop, Cursor, Gemini CLI, or Goose |
|
|
| [`inspect`](/cli/inspecting) | Print a server's tools, resources, and prompts as a summary or JSON report |
|
|
| [`list`](/cli/client) | List a server's tools (and optionally resources and prompts) |
|
|
| [`call`](/cli/client#calling-tools) | Call a single tool with arguments |
|
|
| [`discover`](/cli/client#discovering-configured-servers) | Find MCP servers configured in your editors and tools |
|
|
| [`generate-cli`](/cli/generate-cli) | Scaffold a standalone typed CLI from a server's tool schemas |
|
|
| [`project prepare`](/cli/running#pre-building-environments) | Pre-install dependencies into a reusable uv project |
|
|
| [`auth cimd`](/cli/auth) | Create and validate CIMD documents for OAuth |
|
|
| `version` | Print version info (`--copy` to copy to clipboard) |
|
|
|
|
## Server Targets
|
|
|
|
Most commands need to know *which server* to talk to. You pass a "server spec" as the first argument, and FastMCP resolves the right transport automatically.
|
|
|
|
**URLs** connect to a running HTTP server:
|
|
|
|
```bash
|
|
fastmcp list http://localhost:8000/mcp
|
|
fastmcp call http://localhost:8000/mcp get_forecast city=London
|
|
```
|
|
|
|
**Python files** are loaded directly — no `mcp.run()` boilerplate needed. FastMCP finds a server instance named `mcp`, `server`, or `app` in the file, or you can specify one explicitly:
|
|
|
|
```bash
|
|
fastmcp list server.py
|
|
fastmcp run server.py:my_custom_server
|
|
```
|
|
|
|
**Config files** work too — both FastMCP's own `fastmcp.json` format and standard MCP config files with an `mcpServers` key:
|
|
|
|
```bash
|
|
fastmcp run fastmcp.json
|
|
fastmcp list mcp-config.json
|
|
```
|
|
|
|
**Stdio commands** connect to any MCP server that speaks over standard I/O. Use `--command` instead of a positional argument:
|
|
|
|
```bash
|
|
fastmcp list --command 'npx -y @modelcontextprotocol/server-github'
|
|
```
|
|
|
|
### Name-Based Resolution
|
|
|
|
If your servers are already configured in an editor or tool, you can refer to them by name. FastMCP scans configs from Claude Desktop, Claude Code, Cursor, Gemini CLI, and Goose:
|
|
|
|
```bash
|
|
fastmcp list weather
|
|
fastmcp call weather get_forecast city=London
|
|
```
|
|
|
|
When the same name appears in multiple configs, use the `source:name` form to be specific:
|
|
|
|
```bash
|
|
fastmcp list claude-code:my-server
|
|
fastmcp call cursor:weather get_forecast city=London
|
|
```
|
|
|
|
Run [`fastmcp discover`](/cli/client#discovering-configured-servers) to see what's available on your machine.
|
|
|
|
## Authentication
|
|
|
|
When targeting an HTTP URL, the CLI enables OAuth authentication by default. If the server requires it, you'll be guided through the flow (typically opening a browser). If it doesn't, the setup is a silent no-op.
|
|
|
|
To skip authentication entirely — useful for local development servers — pass `--auth none`:
|
|
|
|
```bash
|
|
fastmcp call http://localhost:8000/mcp my_tool --auth none
|
|
```
|
|
|
|
You can also pass a bearer token directly:
|
|
|
|
```bash
|
|
fastmcp list http://localhost:8000/mcp --auth "Bearer sk-..."
|
|
```
|
|
|
|
## Transport Override
|
|
|
|
FastMCP defaults to Streamable HTTP for URL targets. If the server only supports Server-Sent Events (SSE), force the older transport:
|
|
|
|
```bash
|
|
fastmcp list http://localhost:8000 --transport sse
|
|
```
|