mirror of
https://github.com/PrefectHQ/fastmcp.git
synced 2026-08-09 07:09:11 +02:00
* Initialize 2.14 deprecation removal branch * Remove deprecated FASTMCP_SERVER_ environment variable prefix (#2330) * Remove deprecated Context.get_http_request method (#2332) * Remove fastmcp.Image top-level import (deprecated 2.8.1) (#2334) * Remove test warnings (#2331) * Create new branch and fix issue * Remove deprecated client parameter from FastMCPProxy (#2333) * Remove deprecated run_streamable_http_async method (#2338) * Remove deprecated sse_app method (#2337) * Remove deprecated run_sse_async method (#2335) * Remove deprecated run_sse_async method * Update CLI and tests to use run_http_async(transport="sse") - Change CLI to call run_http_async with transport="sse" instead of run_sse_async - Update test to mock run_http_async with create=True for v1 servers * Revert CLI changes - v1 servers do have run_sse_async - Keep CLI calling run_sse_async() for v1 compatibility - Update test to mock run_sse_async (which exists on v1) * Remove unnecessary type ignore for run_sse_async Method exists on v1 FastMCP class, no type error * Remove unused imports after test deletion * Remove deprecated streamable_http_app method (#2336) * Remove deprecated dependencies parameter from FastMCP constructor (#2340) * Remove output_schema=False support (deprecated 2.11.4) (#2339) * Remove deprecated client parameter from FastMCPProxy (#2333) * Delete deprecated test_output_schema_false.py Tests functionality that has been removed * Remove deprecated BearerAuthProvider module (#2341) * Remove resource_prefix_format="protocol" support (deprecated 2.4.0) (#2342) * Remove resource_prefix_format="protocol" support (fixes #2195) Removes deprecated protocol format (prefix+resource://path) and keeps only path format (resource://prefix/path). Since only one format remains: - Removed resource_prefix_format from settings, FastMCP.__init__, and helpers - Simplified add_resource_prefix, remove_resource_prefix, has_resource_prefix - Removed MountedServer.resource_prefix_format field - Deleted tests for protocol format All resource prefixes now use path format exclusively. * Clean up resource_prefix_format references - Remove from test files - Update documentation to remove protocol format section - Move custom HTTP routes note to mounting section - Remove resource_prefix_format from settings docs * Use inline version note instead of badge for prefix format * Remove obsolete test functions and update docs - Delete test functions that no longer assert anything - Remove proxy.mdx reference to deleted prefix format section * Format error messages per ruff * Remove from_client classmethod (deprecated 2.8.0) (#2343) * Remove deprecated from_client classmethod (fixes #2192) * Remove unused Client import * Remove add_resource_fn method (deprecated 2.7.0) (#2345) * Update SDK * Add missing imports for exclude_args deprecation warning
129 lines
4.4 KiB
Text
129 lines
4.4 KiB
Text
---
|
|
title: cli
|
|
sidebarTitle: cli
|
|
---
|
|
|
|
# `fastmcp.cli.cli`
|
|
|
|
|
|
FastMCP CLI tools using Cyclopts.
|
|
|
|
## Functions
|
|
|
|
### `with_argv` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/cli/cli.py#L65" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
|
|
|
```python
|
|
with_argv(args: list[str] | None)
|
|
```
|
|
|
|
|
|
Temporarily replace sys.argv if args provided.
|
|
|
|
This context manager is used at the CLI boundary to inject
|
|
server arguments when needed, without mutating sys.argv deep
|
|
in the source loading logic.
|
|
|
|
Args are provided without the script name, so we preserve sys.argv[0]
|
|
and replace the rest.
|
|
|
|
|
|
### `version` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/cli/cli.py#L88" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
|
|
|
```python
|
|
version()
|
|
```
|
|
|
|
|
|
Display version information and platform details.
|
|
|
|
|
|
### `dev` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/cli/cli.py#L126" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
|
|
|
```python
|
|
dev(server_spec: str | None = None) -> None
|
|
```
|
|
|
|
|
|
Run an MCP server with the MCP Inspector for development.
|
|
|
|
**Args:**
|
|
- `server_spec`: Python file to run, optionally with \:object suffix, or None to auto-detect fastmcp.json
|
|
|
|
|
|
### `run` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/cli/cli.py#L286" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
|
|
|
```python
|
|
run(server_spec: str | None = None, *server_args: str) -> None
|
|
```
|
|
|
|
|
|
Run an MCP server or connect to a remote one.
|
|
|
|
The server can be specified in several ways:
|
|
1. Module approach: "server.py" - runs the module directly, looking for an object named 'mcp', 'server', or 'app'
|
|
2. Import approach: "server.py:app" - imports and runs the specified server object
|
|
3. URL approach: "http://server-url" - connects to a remote server and creates a proxy
|
|
4. MCPConfig file: "mcp.json" - runs as a proxy server for the MCP Servers in the MCPConfig file
|
|
5. FastMCP config: "fastmcp.json" - runs server using FastMCP configuration
|
|
6. No argument: looks for fastmcp.json in current directory
|
|
|
|
Server arguments can be passed after -- :
|
|
fastmcp run server.py -- --config config.json --debug
|
|
|
|
**Args:**
|
|
- `server_spec`: Python file, object specification (file\:obj), config file, URL, or None to auto-detect
|
|
|
|
|
|
### `inspect` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/cli/cli.py#L520" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
|
|
|
```python
|
|
inspect(server_spec: str | None = None) -> None
|
|
```
|
|
|
|
|
|
Inspect an MCP server and display information or generate a JSON report.
|
|
|
|
This command analyzes an MCP server. Without flags, it displays a text summary.
|
|
Use --format to output complete JSON data.
|
|
|
|
**Examples:**
|
|
|
|
# Show text summary
|
|
fastmcp inspect server.py
|
|
|
|
# Output FastMCP format JSON to stdout
|
|
fastmcp inspect server.py --format fastmcp
|
|
|
|
# Save MCP protocol format to file (format required with -o)
|
|
fastmcp inspect server.py --format mcp -o manifest.json
|
|
|
|
# Inspect from fastmcp.json configuration
|
|
fastmcp inspect fastmcp.json
|
|
fastmcp inspect # auto-detect fastmcp.json
|
|
|
|
**Args:**
|
|
- `server_spec`: Python file to inspect, optionally with \:object suffix, or fastmcp.json
|
|
|
|
|
|
### `prepare` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/cli/cli.py#L765" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
|
|
|
```python
|
|
prepare(config_path: Annotated[str | None, cyclopts.Parameter(help='Path to fastmcp.json configuration file')] = None, output_dir: Annotated[str | None, cyclopts.Parameter(help='Directory to create the persistent environment in')] = None, skip_source: Annotated[bool, cyclopts.Parameter(help='Skip source preparation (e.g., git clone)')] = False) -> None
|
|
```
|
|
|
|
|
|
Prepare a FastMCP project by creating a persistent uv environment.
|
|
|
|
This command creates a persistent uv project with all dependencies installed:
|
|
- Creates a pyproject.toml with dependencies from the config
|
|
- Installs all Python packages into a .venv
|
|
- Prepares the source (git clone, download, etc.) unless --skip-source
|
|
|
|
After running this command, you can use:
|
|
fastmcp run <config> --project <output-dir>
|
|
|
|
This is useful for:
|
|
- CI/CD pipelines with separate build and run stages
|
|
- Docker images where you prepare during build
|
|
- Production deployments where you want fast startup times
|
|
|