From bc84961ab97c9e2d2515d16a72cb89f7de87b2ac Mon Sep 17 00:00:00 2001 From: "marvin-context-protocol[bot]" <225465937+marvin-context-protocol[bot]@users.noreply.github.com> Date: Fri, 29 Aug 2025 22:35:28 -0400 Subject: [PATCH] chore: Update SDK documentation (#1675) Co-authored-by: marvin-context-protocol[bot] <225465937+marvin-context-protocol[bot]@users.noreply.github.com> --- docs/docs.json | 8 ++ docs/python-sdk/fastmcp-cli-cli.mdx | 12 +-- ...server_config-v1-environments-__init__.mdx | 9 ++ ...mcp_server_config-v1-environments-base.mdx | 43 +++++++++ ...s-mcp_server_config-v1-environments-uv.mdx | 75 ++++++++++++++++ ...mcp_server_config-v1-mcp_server_config.mdx | 90 ++++--------------- 6 files changed, 156 insertions(+), 81 deletions(-) create mode 100644 docs/python-sdk/fastmcp-utilities-mcp_server_config-v1-environments-__init__.mdx create mode 100644 docs/python-sdk/fastmcp-utilities-mcp_server_config-v1-environments-base.mdx create mode 100644 docs/python-sdk/fastmcp-utilities-mcp_server_config-v1-environments-uv.mdx diff --git a/docs/docs.json b/docs/docs.json index 3cd031270..e2bc06e02 100644 --- a/docs/docs.json +++ b/docs/docs.json @@ -394,6 +394,14 @@ "group": "v1", "pages": [ "python-sdk/fastmcp-utilities-mcp_server_config-v1-__init__", + { + "group": "environments", + "pages": [ + "python-sdk/fastmcp-utilities-mcp_server_config-v1-environments-__init__", + "python-sdk/fastmcp-utilities-mcp_server_config-v1-environments-base", + "python-sdk/fastmcp-utilities-mcp_server_config-v1-environments-uv" + ] + }, "python-sdk/fastmcp-utilities-mcp_server_config-v1-mcp_server_config", { "group": "sources", diff --git a/docs/python-sdk/fastmcp-cli-cli.mdx b/docs/python-sdk/fastmcp-cli-cli.mdx index 83677c671..4dddc51ad 100644 --- a/docs/python-sdk/fastmcp-cli-cli.mdx +++ b/docs/python-sdk/fastmcp-cli-cli.mdx @@ -10,7 +10,7 @@ FastMCP CLI tools using Cyclopts. ## Functions -### `with_argv` +### `with_argv` ```python with_argv(args: list[str] | None) @@ -27,7 +27,7 @@ Args are provided without the script name, so we preserve sys.argv[0] and replace the rest. -### `version` +### `version` ```python version() @@ -37,7 +37,7 @@ version() Display version information and platform details. -### `dev` +### `dev` ```python dev(server_spec: str | None = None) -> None @@ -50,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` +### `run` ```python run(server_spec: str | None = None, *server_args: str) -> None @@ -74,7 +74,7 @@ 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` +### `inspect` ```python inspect(server_spec: str | None = None) -> None @@ -105,7 +105,7 @@ fastmcp inspect # auto-detect fastmcp.json - `server_spec`: Python file to inspect, optionally with \:object suffix, or fastmcp.json -### `prepare` +### `prepare` ```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 diff --git a/docs/python-sdk/fastmcp-utilities-mcp_server_config-v1-environments-__init__.mdx b/docs/python-sdk/fastmcp-utilities-mcp_server_config-v1-environments-__init__.mdx new file mode 100644 index 000000000..01f147482 --- /dev/null +++ b/docs/python-sdk/fastmcp-utilities-mcp_server_config-v1-environments-__init__.mdx @@ -0,0 +1,9 @@ +--- +title: __init__ +sidebarTitle: __init__ +--- + +# `fastmcp.utilities.mcp_server_config.v1.environments` + + +Environment configuration for MCP servers. diff --git a/docs/python-sdk/fastmcp-utilities-mcp_server_config-v1-environments-base.mdx b/docs/python-sdk/fastmcp-utilities-mcp_server_config-v1-environments-base.mdx new file mode 100644 index 000000000..52b0de9a8 --- /dev/null +++ b/docs/python-sdk/fastmcp-utilities-mcp_server_config-v1-environments-base.mdx @@ -0,0 +1,43 @@ +--- +title: base +sidebarTitle: base +--- + +# `fastmcp.utilities.mcp_server_config.v1.environments.base` + +## Classes + +### `Environment` + + +Base class for environment configuration. + + +**Methods:** + +#### `build_command` + +```python +build_command(self, command: list[str]) -> list[str] +``` + +Build the full command with environment setup. + +**Args:** +- `command`: Base command to wrap with environment setup + +**Returns:** +- Full command ready for subprocess execution + + +#### `prepare` + +```python +prepare(self, output_dir: Path | None = None) -> None +``` + +Prepare the environment (optional, can be no-op). + +**Args:** +- `output_dir`: Directory for persistent environment setup + diff --git a/docs/python-sdk/fastmcp-utilities-mcp_server_config-v1-environments-uv.mdx b/docs/python-sdk/fastmcp-utilities-mcp_server_config-v1-environments-uv.mdx new file mode 100644 index 000000000..84d117078 --- /dev/null +++ b/docs/python-sdk/fastmcp-utilities-mcp_server_config-v1-environments-uv.mdx @@ -0,0 +1,75 @@ +--- +title: uv +sidebarTitle: uv +--- + +# `fastmcp.utilities.mcp_server_config.v1.environments.uv` + +## Classes + +### `UVEnvironment` + + +Configuration for Python environment setup. + + +**Methods:** + +#### `build_command` + +```python +build_command(self, command: list[str]) -> list[str] +``` + +Build complete uv run command with environment args and command to execute. + +**Args:** +- `command`: Command to execute (e.g., ["fastmcp", "run", "server.py"]) + +**Returns:** +- Complete command ready for subprocess.run, including "uv" prefix if needed. +- If no environment configuration is set, returns the command unchanged. + + +#### `run_with_uv` + +```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` + +```python +needs_uv(self) -> bool +``` + +Deprecated: Use _needs_setup() internally or check if build_command modifies the command. + + +#### `build_uv_run_command` + +```python +build_uv_run_command(self, command: list[str]) -> list[str] +``` + +Deprecated: Use build_command() instead. + + +#### `prepare` + +```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. + diff --git a/docs/python-sdk/fastmcp-utilities-mcp_server_config-v1-mcp_server_config.mdx b/docs/python-sdk/fastmcp-utilities-mcp_server_config-v1-mcp_server_config.mdx index fe7815a9b..7096185a0 100644 --- a/docs/python-sdk/fastmcp-utilities-mcp_server_config-v1-mcp_server_config.mdx +++ b/docs/python-sdk/fastmcp-utilities-mcp_server_config-v1-mcp_server_config.mdx @@ -15,7 +15,7 @@ command-line arguments. ## Functions -### `generate_schema` +### `generate_schema` ```python generate_schema(output_path: Path | str | None = None) -> dict[str, Any] | None @@ -38,67 +38,7 @@ validation and auto-completion. ## Classes -### `Environment` - - -Configuration for Python environment setup. - - -**Methods:** - -#### `build_uv_run_command` - -```python -build_uv_run_command(self, command: list[str]) -> list[str] -``` - -Build complete uv run command with environment args and command to execute. - -**Args:** -- `command`: Command to execute (e.g., ["fastmcp", "run", "server.py"]) - -**Returns:** -- Complete command ready for subprocess.run, including "uv" prefix - - -#### `run_with_uv` - -```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` - -```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` - -```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` +### `Deployment` Configuration for server deployment and runtime settings. @@ -106,7 +46,7 @@ Configuration for server deployment and runtime settings. **Methods:** -#### `apply_runtime_settings` +#### `apply_runtime_settings` ```python apply_runtime_settings(self, config_path: Path | None = None) -> None @@ -122,7 +62,7 @@ For example: "API_URL": "https://api.${ENVIRONMENT}.example.com" will substitute the value of the ENVIRONMENT variable at runtime. -### `MCPServerConfig` +### `MCPServerConfig` Configuration for a FastMCP server. @@ -133,7 +73,7 @@ a FastMCP server in a declarative format. **Methods:** -#### `validate_source` +#### `validate_source` ```python validate_source(cls, v: dict | FileSystemSource) -> FileSystemSource @@ -149,10 +89,10 @@ No string parsing happens here - that's only at CLI boundaries. MCPServerConfig works only with properly typed objects. -#### `validate_environment` +#### `validate_environment` ```python -validate_environment(cls, v: dict | Environment) -> Environment +validate_environment(cls, v: dict | UVEnvironment) -> UVEnvironment ``` Validate and convert environment to Environment. @@ -162,7 +102,7 @@ Accepts: - dict that can be converted to Environment -#### `validate_deployment` +#### `validate_deployment` ```python validate_deployment(cls, v: dict | Deployment) -> Deployment @@ -175,7 +115,7 @@ Accepts: - dict that can be converted to Deployment -#### `from_file` +#### `from_file` ```python from_file(cls, file_path: Path) -> MCPServerConfig @@ -195,7 +135,7 @@ Load configuration from a JSON file. - `pydantic.ValidationError`: If the configuration is invalid -#### `from_cli_args` +#### `from_cli_args` ```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) -> MCPServerConfig @@ -226,7 +166,7 @@ goes through a config object. - MCPServerConfig instance -#### `find_config` +#### `find_config` ```python find_config(cls, start_path: Path | None = None) -> Path | None @@ -241,7 +181,7 @@ Find a fastmcp.json file in the specified directory. - Path to the configuration file, or None if not found -#### `prepare` +#### `prepare` ```python prepare(self, skip_source: bool = False, output_dir: Path | None = None) -> None @@ -257,7 +197,7 @@ When output_dir is None, does ephemeral caching (for backwards compatibility). - `output_dir`: Directory to create the persistent uv project in (optional) -#### `prepare_environment` +#### `prepare_environment` ```python prepare_environment(self, output_dir: Path | None = None) -> None @@ -272,7 +212,7 @@ Prepare the Python environment. Delegates to the environment's prepare() method -#### `prepare_source` +#### `prepare_source` ```python prepare_source(self) -> None @@ -283,7 +223,7 @@ Prepare the source for loading. Delegates to the source's prepare() method. -#### `run_server` +#### `run_server` ```python run_server(self, **kwargs: Any) -> None