mirror of
https://github.com/PrefectHQ/fastmcp.git
synced 2026-08-27 15:51:33 +02:00
Enhance inspect command with structured output and format options (#1481)
This commit is contained in:
parent
68c9c051e6
commit
f4ab2e8127
24 changed files with 1194 additions and 205 deletions
|
|
@ -32,7 +32,7 @@ Add or update a FastMCP server in Claude's configuration.
|
|||
**Args:**
|
||||
- `file_spec`: Path to the server file, optionally with \:object suffix
|
||||
- `server_name`: Name for the server in Claude's config
|
||||
- `with_editable`: Optional directory to install in editable mode
|
||||
- `with_editable`: Optional list of directories to install in editable mode
|
||||
- `with_packages`: Optional list of additional packages to install
|
||||
- `env_vars`: Optional dictionary of environment variables. These are merged with
|
||||
any existing variables, with new values taking precedence.
|
||||
|
|
|
|||
|
|
@ -10,7 +10,24 @@ FastMCP CLI tools using Cyclopts.
|
|||
|
||||
## Functions
|
||||
|
||||
### `version` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/cli/cli.py#L63" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
||||
### `with_argv` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/cli/cli.py#L68" 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#L91" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
||||
|
||||
```python
|
||||
version()
|
||||
|
|
@ -20,7 +37,7 @@ version()
|
|||
Display version information and platform details.
|
||||
|
||||
|
||||
### `dev` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/cli/cli.py#L101" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
||||
### `dev` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/cli/cli.py#L129" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
||||
|
||||
```python
|
||||
dev(server_spec: str | None = None) -> None
|
||||
|
|
@ -33,7 +50,7 @@ Run an MCP server with the MCP Inspector for development.
|
|||
- `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#L319" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
||||
### `run` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/cli/cli.py#L349" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
||||
|
||||
```python
|
||||
run(server_spec: str | None = None, *server_args: str) -> None
|
||||
|
|
@ -57,28 +74,56 @@ fastmcp run server.py -- --config config.json --debug
|
|||
- `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#L582" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
||||
### `inspect` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/cli/cli.py#L622" 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 generate a JSON report.
|
||||
Inspect an MCP server and display information or generate a JSON report.
|
||||
|
||||
This command analyzes an MCP server and generates a comprehensive JSON report
|
||||
containing information about the server's name, instructions, version, tools,
|
||||
prompts, resources, templates, and capabilities.
|
||||
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
|
||||
fastmcp inspect server.py -o report.json
|
||||
fastmcp inspect server.py:mcp -o analysis.json
|
||||
fastmcp inspect path/to/server.py:app -o /tmp/server-info.json
|
||||
|
||||
# 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#L895" 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
|
||||
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ Install FastMCP server in Claude Code.
|
|||
- `file`: Path to the server file
|
||||
- `server_object`: Optional server object name (for \:object suffix)
|
||||
- `name`: Name for the server in Claude Code
|
||||
- `with_editable`: Optional directory to install in editable mode
|
||||
- `with_editable`: Optional list of directories to install in editable mode
|
||||
- `with_packages`: Optional list of additional packages to install
|
||||
- `env_vars`: Optional dictionary of environment variables
|
||||
- `python_version`: Optional Python version to use
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ Install FastMCP server in Claude Desktop.
|
|||
- `file`: Path to the server file
|
||||
- `server_object`: Optional server object name (for \:object suffix)
|
||||
- `name`: Name for the server in Claude's config
|
||||
- `with_editable`: Optional directory to install in editable mode
|
||||
- `with_editable`: Optional list of directories to install in editable mode
|
||||
- `with_packages`: Optional list of additional packages to install
|
||||
- `env_vars`: Optional dictionary of environment variables
|
||||
- `python_version`: Optional Python version to use
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ Install FastMCP server to workspace-specific Cursor configuration.
|
|||
- `server_object`: Optional server object name (for \:object suffix)
|
||||
- `name`: Name for the server in Cursor
|
||||
- `workspace_path`: Path to the workspace directory
|
||||
- `with_editable`: Optional directory to install in editable mode
|
||||
- `with_editable`: Optional list of directories to install in editable mode
|
||||
- `with_packages`: Optional list of additional packages to install
|
||||
- `env_vars`: Optional dictionary of environment variables
|
||||
- `python_version`: Optional Python version to use
|
||||
|
|
@ -81,7 +81,7 @@ Install FastMCP server in Cursor.
|
|||
- `file`: Path to the server file
|
||||
- `server_object`: Optional server object name (for \:object suffix)
|
||||
- `name`: Name for the server in Cursor
|
||||
- `with_editable`: Optional directory to install in editable mode
|
||||
- `with_editable`: Optional list of directories to install in editable mode
|
||||
- `with_packages`: Optional list of additional packages to install
|
||||
- `env_vars`: Optional dictionary of environment variables
|
||||
- `python_version`: Optional Python version to use
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ Generate MCP configuration JSON for manual installation.
|
|||
- `file`: Path to the server file
|
||||
- `server_object`: Optional server object name (for \:object suffix)
|
||||
- `name`: Name for the server in MCP config
|
||||
- `with_editable`: Optional directory to install in editable mode
|
||||
- `with_editable`: Optional list of directories to install in editable mode
|
||||
- `with_packages`: Optional list of additional packages to install
|
||||
- `env_vars`: Optional dictionary of environment variables
|
||||
- `copy`: If True, copy to clipboard instead of printing to stdout
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ Parse environment variable string in format KEY=VALUE.
|
|||
### `process_common_args` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/cli/install/shared.py#L29" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
||||
|
||||
```python
|
||||
process_common_args(server_spec: str, server_name: str | None, with_packages: list[str], env_vars: list[str], env_file: Path | None) -> tuple[Path, str | None, str, list[str], dict[str, str] | None]
|
||||
process_common_args(server_spec: str, server_name: str | None, with_packages: list[str] | None, env_vars: list[str] | None, env_file: Path | None) -> tuple[Path, str | None, str, list[str], dict[str, str] | None]
|
||||
```
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ FastMCP run command implementation with enhanced type hints.
|
|||
|
||||
## Functions
|
||||
|
||||
### `is_url` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/cli/run.py#L32" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
||||
### `is_url` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/cli/run.py#L29" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
||||
|
||||
```python
|
||||
is_url(path: str) -> bool
|
||||
|
|
@ -20,43 +20,10 @@ is_url(path: str) -> bool
|
|||
Check if a string is a URL.
|
||||
|
||||
|
||||
### `parse_file_path` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/cli/run.py#L38" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
||||
### `run_with_uv` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/cli/run.py#L35" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
||||
|
||||
```python
|
||||
parse_file_path(server_spec: str) -> tuple[Path, str | None]
|
||||
```
|
||||
|
||||
|
||||
Parse a file path that may include a server object specification.
|
||||
|
||||
**Args:**
|
||||
- `server_spec`: Path to file, optionally with \:object suffix
|
||||
|
||||
**Returns:**
|
||||
- Tuple of (file_path, server_object)
|
||||
|
||||
|
||||
### `import_server` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/cli/run.py#L69" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
||||
|
||||
```python
|
||||
import_server(file: Path, server_or_factory: str | None = None) -> Any
|
||||
```
|
||||
|
||||
|
||||
Import a MCP server from a file.
|
||||
|
||||
**Args:**
|
||||
- `file`: Path to the file
|
||||
- `server_or_factory`: Optional object name in format "module\:object" or just "object"
|
||||
|
||||
**Returns:**
|
||||
- The server object (or result of calling a factory function)
|
||||
|
||||
|
||||
### `run_with_uv` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/cli/run.py#L182" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
||||
|
||||
```python
|
||||
run_with_uv(server_spec: str, python_version: str | None = None, with_packages: list[str] | None = None, with_requirements: Path | None = None, project: Path | None = None, transport: TransportType | None = None, host: str | None = None, port: int | None = None, path: str | None = None, log_level: LogLevelType | None = None, show_banner: bool = True, editable: str | None = None) -> None
|
||||
run_with_uv(server_spec: str, python_version: str | None = None, with_packages: list[str] | None = None, with_requirements: Path | None = None, project: Path | None = None, transport: TransportType | None = None, host: str | None = None, port: int | None = None, path: str | None = None, log_level: LogLevelType | None = None, show_banner: bool = True, editable: str | list[str] | None = None) -> None
|
||||
```
|
||||
|
||||
|
||||
|
|
@ -76,7 +43,7 @@ Run a MCP server using uv run subprocess.
|
|||
- `show_banner`: Whether to show the server banner
|
||||
|
||||
|
||||
### `create_client_server` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/cli/run.py#L313" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
||||
### `create_client_server` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/cli/run.py#L170" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
||||
|
||||
```python
|
||||
create_client_server(url: str) -> Any
|
||||
|
|
@ -92,7 +59,7 @@ Create a FastMCP server from a client URL.
|
|||
- A FastMCP server instance
|
||||
|
||||
|
||||
### `create_mcp_config_server` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/cli/run.py#L333" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
||||
### `create_mcp_config_server` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/cli/run.py#L190" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
||||
|
||||
```python
|
||||
create_mcp_config_server(mcp_config_path: Path) -> FastMCP[None]
|
||||
|
|
@ -102,7 +69,7 @@ create_mcp_config_server(mcp_config_path: Path) -> FastMCP[None]
|
|||
Create a FastMCP server from a MCPConfig.
|
||||
|
||||
|
||||
### `load_fastmcp_config` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/cli/run.py#L344" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
||||
### `load_fastmcp_config` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/cli/run.py#L201" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
||||
|
||||
```python
|
||||
load_fastmcp_config(config_path: Path) -> FastMCPConfig
|
||||
|
|
@ -118,28 +85,10 @@ Load a FastMCP configuration from a fastmcp.json file.
|
|||
- FastMCPConfig object
|
||||
|
||||
|
||||
### `import_server_with_args` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/cli/run.py#L362" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
||||
### `run_command` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/cli/run.py#L219" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
||||
|
||||
```python
|
||||
import_server_with_args(file: Path, server_or_factory: str | None = None, server_args: list[str] | None = None) -> Any
|
||||
```
|
||||
|
||||
|
||||
Import a server with optional command line arguments.
|
||||
|
||||
**Args:**
|
||||
- `file`: Path to the server file
|
||||
- `server_or_factory`: Optional server object or factory function name
|
||||
- `server_args`: Optional command line arguments to inject
|
||||
|
||||
**Returns:**
|
||||
- The imported server object
|
||||
|
||||
|
||||
### `run_command` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/cli/run.py#L388" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
||||
|
||||
```python
|
||||
run_command(server_spec: str, transport: TransportType | None = None, host: str | None = None, port: int | None = None, path: str | None = None, log_level: LogLevelType | None = None, server_args: list[str] | None = None, show_banner: bool = True, use_direct_import: bool = False) -> None
|
||||
run_command(server_spec: str, transport: TransportType | None = None, host: str | None = None, port: int | None = None, path: str | None = None, log_level: LogLevelType | None = None, server_args: list[str] | None = None, show_banner: bool = True, use_direct_import: bool = False, skip_source: bool = False) -> None
|
||||
```
|
||||
|
||||
|
||||
|
|
@ -155,9 +104,10 @@ Run a MCP server or connect to a remote one.
|
|||
- `server_args`: Additional arguments to pass to the server
|
||||
- `show_banner`: Whether to show the server banner
|
||||
- `use_direct_import`: Whether to use direct import instead of subprocess
|
||||
- `skip_source`: Whether to skip source preparation step
|
||||
|
||||
|
||||
### `run_v1_server` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/cli/run.py#L496" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
||||
### `run_v1_server` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/cli/run.py#L341" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
||||
|
||||
```python
|
||||
run_v1_server(server: FastMCP1x, host: str | None = None, port: int | None = None, transport: TransportType | None = None) -> None
|
||||
|
|
|
|||
|
|
@ -226,7 +226,7 @@ The flow:
|
|||
4. When client reconnects with a different port, ProxyDCRClient accepts it
|
||||
|
||||
|
||||
#### `authorize` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/auth/oauth_proxy.py#L444" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
||||
#### `authorize` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/auth/oauth_proxy.py#L435" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
||||
|
||||
```python
|
||||
authorize(self, client: OAuthClientInformationFull, params: AuthorizationParams) -> str
|
||||
|
|
@ -240,7 +240,7 @@ This implements the DCR-compliant proxy pattern:
|
|||
3. Redirect to IdP with our fixed callback URL
|
||||
|
||||
|
||||
#### `load_authorization_code` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/auth/oauth_proxy.py#L501" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
||||
#### `load_authorization_code` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/auth/oauth_proxy.py#L491" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
||||
|
||||
```python
|
||||
load_authorization_code(self, client: OAuthClientInformationFull, authorization_code: str) -> AuthorizationCode | None
|
||||
|
|
@ -252,7 +252,7 @@ Look up our client code and return authorization code object
|
|||
with PKCE challenge for validation.
|
||||
|
||||
|
||||
#### `exchange_authorization_code` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/auth/oauth_proxy.py#L543" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
||||
#### `exchange_authorization_code` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/auth/oauth_proxy.py#L533" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
||||
|
||||
```python
|
||||
exchange_authorization_code(self, client: OAuthClientInformationFull, authorization_code: AuthorizationCode) -> OAuthToken
|
||||
|
|
@ -264,7 +264,7 @@ For the DCR-compliant proxy flow, we return the IdP tokens that were obtained
|
|||
during the IdP callback exchange. PKCE validation is handled by the MCP framework.
|
||||
|
||||
|
||||
#### `load_refresh_token` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/auth/oauth_proxy.py#L610" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
||||
#### `load_refresh_token` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/auth/oauth_proxy.py#L600" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
||||
|
||||
```python
|
||||
load_refresh_token(self, client: OAuthClientInformationFull, refresh_token: str) -> RefreshToken | None
|
||||
|
|
@ -273,7 +273,7 @@ load_refresh_token(self, client: OAuthClientInformationFull, refresh_token: str)
|
|||
Load refresh token from local storage.
|
||||
|
||||
|
||||
#### `exchange_refresh_token` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/auth/oauth_proxy.py#L618" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
||||
#### `exchange_refresh_token` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/auth/oauth_proxy.py#L608" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
||||
|
||||
```python
|
||||
exchange_refresh_token(self, client: OAuthClientInformationFull, refresh_token: RefreshToken, scopes: list[str]) -> OAuthToken
|
||||
|
|
@ -282,7 +282,7 @@ exchange_refresh_token(self, client: OAuthClientInformationFull, refresh_token:
|
|||
Exchange refresh token for new access token using authlib.
|
||||
|
||||
|
||||
#### `load_access_token` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/auth/oauth_proxy.py#L693" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
||||
#### `load_access_token` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/auth/oauth_proxy.py#L683" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
||||
|
||||
```python
|
||||
load_access_token(self, token: str) -> AccessToken | None
|
||||
|
|
@ -294,7 +294,7 @@ Delegates to the JWT verifier which handles signature validation,
|
|||
expiration checking, and claims validation using the upstream JWKS.
|
||||
|
||||
|
||||
#### `revoke_token` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/auth/oauth_proxy.py#L710" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
||||
#### `revoke_token` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/auth/oauth_proxy.py#L700" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
||||
|
||||
```python
|
||||
revoke_token(self, token: AccessToken | RefreshToken) -> None
|
||||
|
|
@ -306,7 +306,7 @@ Removes tokens from local storage and attempts to revoke them with
|
|||
the upstream server if a revocation endpoint is configured.
|
||||
|
||||
|
||||
#### `get_routes` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/auth/oauth_proxy.py#L903" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
||||
#### `get_routes` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/auth/oauth_proxy.py#L893" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
||||
|
||||
```python
|
||||
get_routes(self) -> list[Route]
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ sidebarTitle: elicitation
|
|||
|
||||
## Functions
|
||||
|
||||
### `get_elicitation_schema` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/elicitation.py#L42" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
||||
### `get_elicitation_schema` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/elicitation.py#L98" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
||||
|
||||
```python
|
||||
get_elicitation_schema(response_type: type[T]) -> dict[str, Any]
|
||||
|
|
@ -20,7 +20,7 @@ Get the schema for an elicitation response.
|
|||
- `response_type`: The type of the response
|
||||
|
||||
|
||||
### `validate_elicitation_json_schema` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/elicitation.py#L58" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
||||
### `validate_elicitation_json_schema` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/elicitation.py#L117" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
||||
|
||||
```python
|
||||
validate_elicitation_json_schema(schema: dict[str, Any]) -> None
|
||||
|
|
@ -45,10 +45,43 @@ This ensures the schema is compatible with MCP elicitation requirements:
|
|||
|
||||
## Classes
|
||||
|
||||
### `AcceptedElicitation` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/elicitation.py#L30" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
||||
### `ElicitationJsonSchema` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/elicitation.py#L31" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
||||
|
||||
|
||||
Custom JSON schema generator for MCP elicitation that always inlines enums.
|
||||
|
||||
MCP elicitation requires inline enum schemas without $ref/$defs references.
|
||||
This generator ensures enums are always generated inline for compatibility.
|
||||
Optionally adds enumNames for better UI display when available.
|
||||
|
||||
|
||||
**Methods:**
|
||||
|
||||
#### `generate_inner` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/elicitation.py#L39" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
||||
|
||||
```python
|
||||
generate_inner(self, schema: core_schema.CoreSchema) -> JsonSchemaValue
|
||||
```
|
||||
|
||||
Override to prevent ref generation for enums.
|
||||
|
||||
|
||||
#### `enum_schema` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/elicitation.py#L49" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
||||
|
||||
```python
|
||||
enum_schema(self, schema: core_schema.EnumSchema) -> JsonSchemaValue
|
||||
```
|
||||
|
||||
Generate inline enum schema with optional enumNames for better UI.
|
||||
|
||||
If enum members have a _display_name_ attribute or custom __str__,
|
||||
we'll include enumNames for better UI representation.
|
||||
|
||||
|
||||
### `AcceptedElicitation` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/elicitation.py#L86" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
||||
|
||||
|
||||
Result when user accepts the elicitation.
|
||||
|
||||
|
||||
### `ScalarElicitationType` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/elicitation.py#L38" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
||||
### `ScalarElicitationType` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/elicitation.py#L94" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ y=2)` will call the parent tool with `x=1` and `y=2`.
|
|||
- `RuntimeError`: If called outside a transformed tool context.
|
||||
|
||||
|
||||
### `apply_transformations_to_tools` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/tools/tool_transform.py#L915" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
||||
### `apply_transformations_to_tools` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/tools/tool_transform.py#L933" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
||||
|
||||
```python
|
||||
apply_transformations_to_tools(tools: dict[str, Tool], transformations: dict[str, ToolTransformConfig]) -> dict[str, Tool]
|
||||
|
|
@ -272,7 +272,7 @@ async def custom_output(**kwargs) -> ToolResult:
|
|||
```
|
||||
|
||||
|
||||
### `ToolTransformConfig` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/tools/tool_transform.py#L869" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
||||
### `ToolTransformConfig` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/tools/tool_transform.py#L887" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
||||
|
||||
|
||||
Provides a way to transform a tool.
|
||||
|
|
@ -280,7 +280,7 @@ Provides a way to transform a tool.
|
|||
|
||||
**Methods:**
|
||||
|
||||
#### `apply` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/tools/tool_transform.py#L901" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
||||
#### `apply` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/tools/tool_transform.py#L919" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
||||
|
||||
```python
|
||||
apply(self, tool: Tool) -> TransformedTool
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
---
|
||||
title: fastmcp_config
|
||||
sidebarTitle: fastmcp_config
|
||||
title: __init__
|
||||
sidebarTitle: __init__
|
||||
---
|
||||
|
||||
# `fastmcp.utilities.fastmcp_config`
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
---
|
||||
title: __init__
|
||||
sidebarTitle: __init__
|
||||
---
|
||||
|
||||
# `fastmcp.utilities.fastmcp_config.v1`
|
||||
|
||||
*This module is empty or contains only private/internal implementations.*
|
||||
|
|
@ -0,0 +1,297 @@
|
|||
---
|
||||
title: fastmcp_config
|
||||
sidebarTitle: fastmcp_config
|
||||
---
|
||||
|
||||
# `fastmcp.utilities.fastmcp_config.v1.fastmcp_config`
|
||||
|
||||
|
||||
FastMCP Configuration File Support.
|
||||
|
||||
This module provides support for fastmcp.json configuration files that allow
|
||||
users to specify server settings in a declarative format instead of using
|
||||
command-line arguments.
|
||||
|
||||
|
||||
## Functions
|
||||
|
||||
### `generate_schema` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/utilities/fastmcp_config/v1/fastmcp_config.py#L707" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
||||
|
||||
```python
|
||||
generate_schema(output_path: Path | str | None = None) -> dict[str, Any] | None
|
||||
```
|
||||
|
||||
|
||||
Generate JSON schema for fastmcp.json files.
|
||||
|
||||
This is used to create the schema file that IDEs can use for
|
||||
validation and auto-completion.
|
||||
|
||||
**Args:**
|
||||
- `output_path`: Optional path to write the schema to. If provided,
|
||||
writes the schema and returns None. If not provided,
|
||||
returns the schema as a dictionary.
|
||||
|
||||
**Returns:**
|
||||
- JSON schema as a dictionary if output_path is None, otherwise None
|
||||
|
||||
|
||||
## Classes
|
||||
|
||||
### `Environment` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/utilities/fastmcp_config/v1/fastmcp_config.py#L33" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
||||
|
||||
|
||||
Configuration for Python environment setup.
|
||||
|
||||
|
||||
**Methods:**
|
||||
|
||||
#### `build_uv_args` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/utilities/fastmcp_config/v1/fastmcp_config.py#L66" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
||||
|
||||
```python
|
||||
build_uv_args(self, command: str | list[str] | None = None) -> list[str]
|
||||
```
|
||||
|
||||
Build uv run arguments from this environment configuration.
|
||||
|
||||
**Args:**
|
||||
- `command`: Optional command to append (string or list of args)
|
||||
|
||||
**Returns:**
|
||||
- List of arguments for uv run command
|
||||
|
||||
|
||||
#### `run_with_uv` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/utilities/fastmcp_config/v1/fastmcp_config.py#L109" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
||||
|
||||
```python
|
||||
run_with_uv(self, command: list[str]) -> None
|
||||
```
|
||||
|
||||
Execute a command using uv run with this environment configuration.
|
||||
|
||||
**Args:**
|
||||
- `command`: Command and arguments to execute (e.g., ["fastmcp", "run", "server.py"])
|
||||
|
||||
|
||||
#### `needs_uv` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/utilities/fastmcp_config/v1/fastmcp_config.py#L132" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
||||
|
||||
```python
|
||||
needs_uv(self) -> bool
|
||||
```
|
||||
|
||||
Check if this environment config requires uv to set up.
|
||||
|
||||
**Returns:**
|
||||
- True if any environment settings require uv run
|
||||
|
||||
|
||||
#### `prepare` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/utilities/fastmcp_config/v1/fastmcp_config.py#L148" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
||||
|
||||
```python
|
||||
prepare(self, output_dir: Path | None = None) -> None
|
||||
```
|
||||
|
||||
Prepare the Python environment using uv.
|
||||
|
||||
**Args:**
|
||||
- `output_dir`: Directory where the persistent uv project will be created.
|
||||
If None, creates a temporary directory for ephemeral use.
|
||||
|
||||
|
||||
### `Deployment` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/utilities/fastmcp_config/v1/fastmcp_config.py#L313" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
||||
|
||||
|
||||
Configuration for server deployment and runtime settings.
|
||||
|
||||
|
||||
**Methods:**
|
||||
|
||||
#### `apply_runtime_settings` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/utilities/fastmcp_config/v1/fastmcp_config.py#L362" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
||||
|
||||
```python
|
||||
apply_runtime_settings(self, config_path: Path | None = None) -> None
|
||||
```
|
||||
|
||||
Apply runtime settings like environment variables and working directory.
|
||||
|
||||
**Args:**
|
||||
- `config_path`: Path to config file for resolving relative paths
|
||||
|
||||
Environment variables support interpolation with ${VAR_NAME} syntax.
|
||||
For example: "API_URL": "https://api.${ENVIRONMENT}.example.com"
|
||||
will substitute the value of the ENVIRONMENT variable at runtime.
|
||||
|
||||
|
||||
### `FastMCPConfig` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/utilities/fastmcp_config/v1/fastmcp_config.py#L411" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
||||
|
||||
|
||||
Configuration for a FastMCP server.
|
||||
|
||||
This configuration file allows you to specify all settings needed to run
|
||||
a FastMCP server in a declarative format.
|
||||
|
||||
|
||||
**Methods:**
|
||||
|
||||
#### `validate_source` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/utilities/fastmcp_config/v1/fastmcp_config.py#L460" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
||||
|
||||
```python
|
||||
validate_source(cls, v: dict | FileSystemSource) -> FileSystemSource
|
||||
```
|
||||
|
||||
Validate and convert source to proper format.
|
||||
|
||||
Supports:
|
||||
- Dict format: {"path": "server.py", "entrypoint": "app"}
|
||||
- FileSystemSource instance (passed through)
|
||||
|
||||
No string parsing happens here - that's only at CLI boundaries.
|
||||
FastMCPConfig works only with properly typed objects.
|
||||
|
||||
|
||||
#### `validate_environment` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/utilities/fastmcp_config/v1/fastmcp_config.py#L483" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
||||
|
||||
```python
|
||||
validate_environment(cls, v: dict | Environment) -> Environment
|
||||
```
|
||||
|
||||
Validate and convert environment to Environment.
|
||||
|
||||
Accepts:
|
||||
- Environment instance
|
||||
- dict that can be converted to Environment
|
||||
|
||||
|
||||
#### `validate_deployment` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/utilities/fastmcp_config/v1/fastmcp_config.py#L499" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
||||
|
||||
```python
|
||||
validate_deployment(cls, v: dict | Deployment) -> Deployment
|
||||
```
|
||||
|
||||
Validate and convert deployment to Deployment.
|
||||
|
||||
Accepts:
|
||||
- Deployment instance
|
||||
- dict that can be converted to Deployment
|
||||
|
||||
|
||||
#### `from_file` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/utilities/fastmcp_config/v1/fastmcp_config.py#L515" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
||||
|
||||
```python
|
||||
from_file(cls, file_path: Path) -> FastMCPConfig
|
||||
```
|
||||
|
||||
Load configuration from a JSON file.
|
||||
|
||||
**Args:**
|
||||
- `file_path`: Path to the configuration file
|
||||
|
||||
**Returns:**
|
||||
- FastMCPConfig instance
|
||||
|
||||
**Raises:**
|
||||
- `FileNotFoundError`: If the file doesn't exist
|
||||
- `json.JSONDecodeError`: If the file is not valid JSON
|
||||
- `pydantic.ValidationError`: If the configuration is invalid
|
||||
|
||||
|
||||
#### `from_cli_args` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/utilities/fastmcp_config/v1/fastmcp_config.py#L538" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
||||
|
||||
```python
|
||||
from_cli_args(cls, source: FileSystemSource, transport: Literal['stdio', 'http', 'sse', 'streamable-http'] | None = None, host: str | None = None, port: int | None = None, path: str | None = None, log_level: Literal['DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL'] | None = None, python: str | None = None, dependencies: list[str] | None = None, requirements: str | None = None, project: str | None = None, editable: str | None = None, env: dict[str, str] | None = None, cwd: str | None = None, args: list[str] | None = None) -> FastMCPConfig
|
||||
```
|
||||
|
||||
Create a config from CLI arguments.
|
||||
|
||||
This allows us to have a single code path where everything
|
||||
goes through a config object.
|
||||
|
||||
**Args:**
|
||||
- `source`: Server source (FileSystemSource instance)
|
||||
- `transport`: Transport protocol
|
||||
- `host`: Host for HTTP transport
|
||||
- `port`: Port for HTTP transport
|
||||
- `path`: URL path for server
|
||||
- `log_level`: Logging level
|
||||
- `python`: Python version
|
||||
- `dependencies`: Python packages to install
|
||||
- `requirements`: Path to requirements file
|
||||
- `project`: Path to project directory
|
||||
- `editable`: Path to install in editable mode
|
||||
- `env`: Environment variables
|
||||
- `cwd`: Working directory
|
||||
- `args`: Server arguments
|
||||
|
||||
**Returns:**
|
||||
- FastMCPConfig instance
|
||||
|
||||
|
||||
#### `find_config` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/utilities/fastmcp_config/v1/fastmcp_config.py#L615" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
||||
|
||||
```python
|
||||
find_config(cls, start_path: Path | None = None) -> Path | None
|
||||
```
|
||||
|
||||
Find a fastmcp.json file in the specified directory.
|
||||
|
||||
**Args:**
|
||||
- `start_path`: Directory to look in (defaults to current directory)
|
||||
|
||||
**Returns:**
|
||||
- Path to the configuration file, or None if not found
|
||||
|
||||
|
||||
#### `prepare` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/utilities/fastmcp_config/v1/fastmcp_config.py#L634" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
||||
|
||||
```python
|
||||
prepare(self, skip_source: bool = False, output_dir: Path | None = None) -> None
|
||||
```
|
||||
|
||||
Prepare environment and source for execution.
|
||||
|
||||
When output_dir is provided, creates a persistent uv project.
|
||||
When output_dir is None, does ephemeral caching (for backwards compatibility).
|
||||
|
||||
**Args:**
|
||||
- `skip_source`: Skip source preparation if True
|
||||
- `output_dir`: Directory to create the persistent uv project in (optional)
|
||||
|
||||
|
||||
#### `prepare_environment` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/utilities/fastmcp_config/v1/fastmcp_config.py#L655" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
||||
|
||||
```python
|
||||
prepare_environment(self, output_dir: Path | None = None) -> None
|
||||
```
|
||||
|
||||
Prepare the Python environment.
|
||||
|
||||
**Args:**
|
||||
- `output_dir`: If provided, creates a persistent uv project in this directory.
|
||||
If None, just populates uv's cache for ephemeral use.
|
||||
|
||||
Delegates to the environment's prepare() method
|
||||
|
||||
|
||||
#### `prepare_source` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/utilities/fastmcp_config/v1/fastmcp_config.py#L666" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
||||
|
||||
```python
|
||||
prepare_source(self) -> None
|
||||
```
|
||||
|
||||
Prepare the source for loading.
|
||||
|
||||
Delegates to the source's prepare() method.
|
||||
|
||||
|
||||
#### `run_server` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/utilities/fastmcp_config/v1/fastmcp_config.py#L673" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
||||
|
||||
```python
|
||||
run_server(self, **kwargs: Any) -> None
|
||||
```
|
||||
|
||||
Load and run the server with this configuration.
|
||||
|
||||
**Args:**
|
||||
- `**kwargs`: Additional arguments to pass to server.run_async()
|
||||
These override config settings
|
||||
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
---
|
||||
title: __init__
|
||||
sidebarTitle: __init__
|
||||
---
|
||||
|
||||
# `fastmcp.utilities.fastmcp_config.v1.sources`
|
||||
|
||||
*This module is empty or contains only private/internal implementations.*
|
||||
|
|
@ -0,0 +1,42 @@
|
|||
---
|
||||
title: base
|
||||
sidebarTitle: base
|
||||
---
|
||||
|
||||
# `fastmcp.utilities.fastmcp_config.v1.sources.base`
|
||||
|
||||
## Classes
|
||||
|
||||
### `BaseSource` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/utilities/fastmcp_config/v1/sources/base.py#L7" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
||||
|
||||
|
||||
Abstract base class for all source types.
|
||||
|
||||
|
||||
**Methods:**
|
||||
|
||||
#### `prepare` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/utilities/fastmcp_config/v1/sources/base.py#L12" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
||||
|
||||
```python
|
||||
prepare(self) -> None
|
||||
```
|
||||
|
||||
Prepare the source (download, clone, install, etc).
|
||||
|
||||
For sources that need preparation (e.g., git clone, download),
|
||||
this method performs that preparation. For sources that don't
|
||||
need preparation (e.g., local files), this is a no-op.
|
||||
|
||||
|
||||
#### `load_server` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/utilities/fastmcp_config/v1/sources/base.py#L23" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
||||
|
||||
```python
|
||||
load_server(self) -> Any
|
||||
```
|
||||
|
||||
Load and return the FastMCP server instance.
|
||||
|
||||
Must be called after prepare() if the source requires preparation.
|
||||
All information needed to load the server should be available
|
||||
as attributes on the source instance.
|
||||
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
---
|
||||
title: filesystem
|
||||
sidebarTitle: filesystem
|
||||
---
|
||||
|
||||
# `fastmcp.utilities.fastmcp_config.v1.sources.filesystem`
|
||||
|
||||
## Classes
|
||||
|
||||
### `FileSystemSource` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/utilities/fastmcp_config/v1/sources/filesystem.py#L15" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
||||
|
||||
|
||||
Source for local Python files.
|
||||
|
||||
|
||||
**Methods:**
|
||||
|
||||
#### `parse_path_with_object` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/utilities/fastmcp_config/v1/sources/filesystem.py#L27" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
||||
|
||||
```python
|
||||
parse_path_with_object(cls, v: str) -> str
|
||||
```
|
||||
|
||||
Parse path:object syntax and extract the object name.
|
||||
|
||||
This validator runs before the model is created, allowing us to
|
||||
handle the "file.py:object" syntax at the model boundary.
|
||||
|
||||
|
||||
#### `load_server` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/utilities/fastmcp_config/v1/sources/filesystem.py#L62" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
||||
|
||||
```python
|
||||
load_server(self) -> Any
|
||||
```
|
||||
|
||||
Load server from filesystem.
|
||||
|
||||
|
|
@ -10,7 +10,7 @@ Utilities for inspecting FastMCP instances.
|
|||
|
||||
## Functions
|
||||
|
||||
### `inspect_fastmcp_v2` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/utilities/inspect.py#L83" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
||||
### `inspect_fastmcp_v2` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/utilities/inspect.py#L98" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
||||
|
||||
```python
|
||||
inspect_fastmcp_v2(mcp: FastMCP[Any]) -> FastMCPInfo
|
||||
|
|
@ -26,7 +26,7 @@ Extract information from a FastMCP v2.x instance.
|
|||
- FastMCPInfo dataclass containing the extracted information
|
||||
|
||||
|
||||
### `inspect_fastmcp_v1` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/utilities/inspect.py#L185" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
||||
### `inspect_fastmcp_v1` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/utilities/inspect.py#L215" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
||||
|
||||
```python
|
||||
inspect_fastmcp_v1(mcp: FastMCP1x) -> FastMCPInfo
|
||||
|
|
@ -42,7 +42,7 @@ Extract information from a FastMCP v1.x instance using a Client.
|
|||
- FastMCPInfo dataclass containing the extracted information
|
||||
|
||||
|
||||
### `inspect_fastmcp` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/utilities/inspect.py#L306" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
||||
### `inspect_fastmcp` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/utilities/inspect.py#L336" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
||||
|
||||
```python
|
||||
inspect_fastmcp(mcp: FastMCP[Any] | FastMCP1x) -> FastMCPInfo
|
||||
|
|
@ -61,34 +61,83 @@ and uses the appropriate extraction method.
|
|||
- FastMCPInfo dataclass containing the extracted information
|
||||
|
||||
|
||||
### `format_fastmcp_info` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/utilities/inspect.py#L361" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
||||
|
||||
```python
|
||||
format_fastmcp_info(info: FastMCPInfo) -> bytes
|
||||
```
|
||||
|
||||
|
||||
Format FastMCPInfo as FastMCP-specific JSON.
|
||||
|
||||
This includes FastMCP-specific fields like tags, enabled, annotations, etc.
|
||||
|
||||
|
||||
### `format_mcp_info` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/utilities/inspect.py#L388" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
||||
|
||||
```python
|
||||
format_mcp_info(mcp: FastMCP[Any] | FastMCP1x) -> bytes
|
||||
```
|
||||
|
||||
|
||||
Format server info as standard MCP protocol JSON.
|
||||
|
||||
Uses Client to get the standard MCP protocol format with camelCase fields.
|
||||
Includes version metadata at the top level.
|
||||
|
||||
|
||||
### `format_info` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/utilities/inspect.py#L421" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
||||
|
||||
```python
|
||||
format_info(mcp: FastMCP[Any] | FastMCP1x, format: InspectFormat | Literal['fastmcp', 'mcp'], info: FastMCPInfo | None = None) -> bytes
|
||||
```
|
||||
|
||||
|
||||
Format server information according to the specified format.
|
||||
|
||||
**Args:**
|
||||
- `mcp`: The FastMCP instance
|
||||
- `format`: Output format ("fastmcp" or "mcp")
|
||||
- `info`: Pre-extracted FastMCPInfo (optional, will be extracted if not provided)
|
||||
|
||||
**Returns:**
|
||||
- JSON bytes in the requested format
|
||||
|
||||
|
||||
## Classes
|
||||
|
||||
### `ToolInfo` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/utilities/inspect.py#L17" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
||||
### `ToolInfo` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/utilities/inspect.py#L19" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
||||
|
||||
|
||||
Information about a tool.
|
||||
|
||||
|
||||
### `PromptInfo` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/utilities/inspect.py#L30" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
||||
### `PromptInfo` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/utilities/inspect.py#L35" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
||||
|
||||
|
||||
Information about a prompt.
|
||||
|
||||
|
||||
### `ResourceInfo` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/utilities/inspect.py#L42" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
||||
### `ResourceInfo` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/utilities/inspect.py#L49" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
||||
|
||||
|
||||
Information about a resource.
|
||||
|
||||
|
||||
### `TemplateInfo` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/utilities/inspect.py#L55" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
||||
### `TemplateInfo` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/utilities/inspect.py#L65" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
||||
|
||||
|
||||
Information about a resource template.
|
||||
|
||||
|
||||
### `FastMCPInfo` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/utilities/inspect.py#L68" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
||||
### `FastMCPInfo` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/utilities/inspect.py#L82" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
||||
|
||||
|
||||
Information extracted from a FastMCP instance.
|
||||
|
||||
|
||||
### `InspectFormat` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/utilities/inspect.py#L354" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
||||
|
||||
|
||||
Output format for inspect command.
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue