mirror of
https://github.com/PrefectHQ/fastmcp.git
synced 2026-08-23 05:54:19 +02:00
chore: Update SDK documentation (#3069)
Co-authored-by: marvin-context-protocol[bot] <225465937+marvin-context-protocol[bot]@users.noreply.github.com>
This commit is contained in:
parent
b776089ecc
commit
5e0211dd5e
7 changed files with 116 additions and 51 deletions
54
docs/python-sdk/fastmcp-cli-generate.mdx
Normal file
54
docs/python-sdk/fastmcp-cli-generate.mdx
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
---
|
||||
title: generate
|
||||
sidebarTitle: generate
|
||||
---
|
||||
|
||||
# `fastmcp.cli.generate`
|
||||
|
||||
|
||||
Generate a standalone CLI script from an MCP server's capabilities.
|
||||
|
||||
## Functions
|
||||
|
||||
### `serialize_transport` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/cli/generate.py#L122" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
||||
|
||||
```python
|
||||
serialize_transport(resolved: str | dict[str, Any] | ClientTransport) -> tuple[str, set[str]]
|
||||
```
|
||||
|
||||
|
||||
Serialize a resolved transport to a Python expression string.
|
||||
|
||||
Returns ``(expression, extra_imports)`` where *extra_imports* is a set of
|
||||
import lines needed by the expression.
|
||||
|
||||
|
||||
### `generate_cli_script` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/cli/generate.py#L283" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
||||
|
||||
```python
|
||||
generate_cli_script(server_name: str, server_spec: str, transport_code: str, extra_imports: set[str], tools: list[mcp.types.Tool]) -> str
|
||||
```
|
||||
|
||||
|
||||
Generate the full CLI script source code.
|
||||
|
||||
|
||||
### `generate_cli_command` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/cli/generate.py#L526" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
|
||||
|
||||
```python
|
||||
generate_cli_command(server_spec: Annotated[str, cyclopts.Parameter(help='Server URL, Python file, MCPConfig JSON, discovered name, or .js file')], output: Annotated[str, cyclopts.Parameter(help='Output file path (default: cli.py)')] = 'cli.py') -> None
|
||||
```
|
||||
|
||||
|
||||
Generate a standalone CLI script from an MCP server.
|
||||
|
||||
Connects to the server, reads its tools/resources/prompts, and writes
|
||||
a Python script that can invoke them directly.
|
||||
|
||||
**Examples:**
|
||||
|
||||
fastmcp generate-cli weather
|
||||
fastmcp generate-cli weather my_cli.py
|
||||
fastmcp generate-cli http://localhost:8000/mcp
|
||||
fastmcp generate-cli server.py output.py -f
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue