Skip to content

Commit 5e0211d

Browse files
chore: Update SDK documentation (#3069)
Co-authored-by: marvin-context-protocol[bot] <225465937+marvin-context-protocol[bot]@users.noreply.github.com>
1 parent b776089 commit 5e0211d

File tree

7 files changed

+116
-51
lines changed

7 files changed

+116
-51
lines changed

docs/docs.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,7 @@
304304
"python-sdk/fastmcp-cli-cli",
305305
"python-sdk/fastmcp-cli-client",
306306
"python-sdk/fastmcp-cli-discovery",
307+
"python-sdk/fastmcp-cli-generate",
307308
{
308309
"group": "install",
309310
"pages": [

docs/python-sdk/fastmcp-cli-cli.mdx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ FastMCP CLI tools using Cyclopts.
1010

1111
## Functions
1212

13-
### `with_argv` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/cli/cli.py#L71" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
13+
### `with_argv` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/cli/cli.py#L72" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
1414

1515
```python
1616
with_argv(args: list[str] | None)
@@ -27,7 +27,7 @@ Args are provided without the script name, so we preserve sys.argv[0]
2727
and replace the rest.
2828

2929

30-
### `version` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/cli/cli.py#L94" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
30+
### `version` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/cli/cli.py#L95" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
3131

3232
```python
3333
version()
@@ -37,7 +37,7 @@ version()
3737
Display version information and platform details.
3838

3939

40-
### `dev` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/cli/cli.py#L136" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
40+
### `dev` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/cli/cli.py#L137" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
4141

4242
```python
4343
dev(server_spec: str | None = None) -> None
@@ -50,7 +50,7 @@ Run an MCP server with the MCP Inspector for development.
5050
- `server_spec`: Python file to run, optionally with \:object suffix, or None to auto-detect fastmcp.json
5151

5252

53-
### `run` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/cli/cli.py#L316" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
53+
### `run` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/cli/cli.py#L317" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
5454

5555
```python
5656
run(server_spec: str | None = None, *server_args: str) -> None
@@ -74,7 +74,7 @@ fastmcp run server.py -- --config config.json --debug
7474
- `server_spec`: Python file, object specification (file\:obj), config file, URL, or None to auto-detect
7575

7676

77-
### `inspect` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/cli/cli.py#L618" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
77+
### `inspect` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/cli/cli.py#L619" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
7878

7979
```python
8080
inspect(server_spec: str | None = None) -> None
@@ -105,7 +105,7 @@ fastmcp inspect # auto-detect fastmcp.json
105105
- `server_spec`: Python file to inspect, optionally with \:object suffix, or fastmcp.json
106106

107107

108-
### `prepare` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/cli/cli.py#L860" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
108+
### `prepare` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/cli/cli.py#L861" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
109109

110110
```python
111111
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
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
---
2+
title: generate
3+
sidebarTitle: generate
4+
---
5+
6+
# `fastmcp.cli.generate`
7+
8+
9+
Generate a standalone CLI script from an MCP server's capabilities.
10+
11+
## Functions
12+
13+
### `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>
14+
15+
```python
16+
serialize_transport(resolved: str | dict[str, Any] | ClientTransport) -> tuple[str, set[str]]
17+
```
18+
19+
20+
Serialize a resolved transport to a Python expression string.
21+
22+
Returns ``(expression, extra_imports)`` where *extra_imports* is a set of
23+
import lines needed by the expression.
24+
25+
26+
### `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>
27+
28+
```python
29+
generate_cli_script(server_name: str, server_spec: str, transport_code: str, extra_imports: set[str], tools: list[mcp.types.Tool]) -> str
30+
```
31+
32+
33+
Generate the full CLI script source code.
34+
35+
36+
### `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>
37+
38+
```python
39+
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
40+
```
41+
42+
43+
Generate a standalone CLI script from an MCP server.
44+
45+
Connects to the server, reads its tools/resources/prompts, and writes
46+
a Python script that can invoke them directly.
47+
48+
**Examples:**
49+
50+
fastmcp generate-cli weather
51+
fastmcp generate-cli weather my_cli.py
52+
fastmcp generate-cli http://localhost:8000/mcp
53+
fastmcp generate-cli server.py output.py -f
54+

docs/python-sdk/fastmcp-cli-run.mdx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ FastMCP run command implementation with enhanced type hints.
1010

1111
## Functions
1212

13-
### `is_url` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/cli/run.py#L80" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
13+
### `is_url` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/cli/run.py#L81" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
1414

1515
```python
1616
is_url(path: str) -> bool
@@ -20,7 +20,7 @@ is_url(path: str) -> bool
2020
Check if a string is a URL.
2121

2222

23-
### `create_client_server` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/cli/run.py#L86" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
23+
### `create_client_server` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/cli/run.py#L87" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
2424

2525
```python
2626
create_client_server(url: str) -> Any
@@ -36,7 +36,7 @@ Create a FastMCP server from a client URL.
3636
- A FastMCP server instance
3737

3838

39-
### `create_mcp_config_server` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/cli/run.py#L106" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
39+
### `create_mcp_config_server` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/cli/run.py#L107" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
4040

4141
```python
4242
create_mcp_config_server(mcp_config_path: Path) -> FastMCP[None]
@@ -46,7 +46,7 @@ create_mcp_config_server(mcp_config_path: Path) -> FastMCP[None]
4646
Create a FastMCP server from a MCPConfig.
4747

4848

49-
### `load_mcp_server_config` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/cli/run.py#L115" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
49+
### `load_mcp_server_config` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/cli/run.py#L116" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
5050

5151
```python
5252
load_mcp_server_config(config_path: Path) -> MCPServerConfig
@@ -62,7 +62,7 @@ Load a FastMCP configuration from a fastmcp.json file.
6262
- MCPServerConfig object
6363

6464

65-
### `run_command` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/cli/run.py#L132" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
65+
### `run_command` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/cli/run.py#L133" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
6666

6767
```python
6868
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, stateless: bool = False) -> None
@@ -85,7 +85,7 @@ Run a MCP server or connect to a remote one.
8585
- `stateless`: Whether to run in stateless mode (no session)
8686

8787

88-
### `run_v1_server_async` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/cli/run.py#L257" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
88+
### `run_v1_server_async` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/cli/run.py#L258" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
8989

9090
```python
9191
run_v1_server_async(server: FastMCP1x, host: str | None = None, port: int | None = None, transport: TransportType | None = None) -> None
@@ -101,7 +101,7 @@ Run a FastMCP 1.x server using async methods.
101101
- `transport`: Transport protocol to use
102102

103103

104-
### `run_with_reload` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/cli/run.py#L298" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
104+
### `run_with_reload` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/cli/run.py#L323" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
105105

106106
```python
107107
run_with_reload(cmd: list[str], reload_dirs: list[Path] | None = None, is_stdio: bool = False) -> None

docs/python-sdk/fastmcp-server-providers-openapi-components.mdx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Tool implementation for OpenAPI endpoints.
1818

1919
**Methods:**
2020

21-
#### `run` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/providers/openapi/components.py#L108" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
21+
#### `run` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/providers/openapi/components.py#L106" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
2222

2323
```python
2424
run(self, arguments: dict[str, Any]) -> ToolResult
@@ -27,15 +27,15 @@ run(self, arguments: dict[str, Any]) -> ToolResult
2727
Execute the HTTP request using RequestDirector.
2828

2929

30-
### `OpenAPIResource` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/providers/openapi/components.py#L167" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
30+
### `OpenAPIResource` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/providers/openapi/components.py#L168" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
3131

3232

3333
Resource implementation for OpenAPI endpoints.
3434

3535

3636
**Methods:**
3737

38-
#### `read` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/providers/openapi/components.py#L199" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
38+
#### `read` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/providers/openapi/components.py#L198" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
3939

4040
```python
4141
read(self) -> ResourceResult
@@ -44,15 +44,15 @@ read(self) -> ResourceResult
4444
Fetch the resource data by making an HTTP request.
4545

4646

47-
### `OpenAPIResourceTemplate` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/providers/openapi/components.py#L281" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
47+
### `OpenAPIResourceTemplate` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/providers/openapi/components.py#L282" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
4848

4949

5050
Resource template implementation for OpenAPI endpoints.
5151

5252

5353
**Methods:**
5454

55-
#### `create_resource` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/providers/openapi/components.py#L313" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
55+
#### `create_resource` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/providers/openapi/components.py#L312" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
5656

5757
```python
5858
create_resource(self, uri: str, params: dict[str, Any], context: Context | None = None) -> Resource

docs/python-sdk/fastmcp-server-providers-openapi-provider.mdx

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ OpenAPIProvider for creating MCP components from OpenAPI specifications.
1010

1111
## Classes
1212

13-
### `OpenAPIProvider` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/providers/openapi/provider.py#L48" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
13+
### `OpenAPIProvider` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/providers/openapi/provider.py#L51" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
1414

1515

1616
Provider that creates MCP components from an OpenAPI specification.
@@ -21,7 +21,16 @@ spec. Each component makes HTTP calls to the described API endpoints.
2121

2222
**Methods:**
2323

24-
#### `get_tasks` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/providers/openapi/provider.py#L403" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
24+
#### `lifespan` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/providers/openapi/provider.py#L175" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
25+
26+
```python
27+
lifespan(self) -> AsyncIterator[None]
28+
```
29+
30+
Manage the lifecycle of the auto-created httpx client.
31+
32+
33+
#### `get_tasks` <sup><a href="https://github.com/jlowin/fastmcp/blob/main/src/fastmcp/server/providers/openapi/provider.py#L427" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
2534

2635
```python
2736
get_tasks(self) -> Sequence[FastMCPComponent]

0 commit comments

Comments
 (0)