Something went wrong. Try again.
mirror of github.com/PrefectHQ/fastmcp
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126---title: sharedsidebarTitle: shared---
# `fastmcp.cli.install.shared`
Shared utilities for install commands.
## Functions
### `validate_server_name` <sup><a href="https://github.com/PrefectHQ/fastmcp/blob/main/fastmcp_slim/fastmcp/cli/install/shared.py#L32" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
```pythonvalidate_server_name(name: str) -> str```
Validate that a server name is safe for use as a subprocess argument.
Raises SystemExit if the name contains shell metacharacters.
### `quote_windows_batch_argument` <sup><a href="https://github.com/PrefectHQ/fastmcp/blob/main/fastmcp_slim/fastmcp/cli/install/shared.py#L80" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
```pythonquote_windows_batch_argument(argument: str) -> str```
Quote one argument for a command line that runs a `.cmd` or `.bat` file.
The result reaches the program that the batch file launches as theoriginal literal string. This follows the batch file argument quoting inRust's standard library: arguments are wrapped in double quotes so cmd.exetreats `&`, `|`, `<`, `>`, `^`, parentheses and similar characters astext, including when the batch file expands them again through `%*`.Embedded quotes are doubled, which both cmd.exe and the Microsoft Cruntime read as a literal quote. Each `%` is rewritten so cmd.exe does notexpand environment variables. Delayed `!` expansion is disabled by thecommand processor options in `windows_batch_command_line`.
**Raises:**- `ValueError`: If the argument contains a line break. cmd.exe ends thecommand at a line break, so it cannot be passed literally.
### `windows_batch_command_line` <sup><a href="https://github.com/PrefectHQ/fastmcp/blob/main/fastmcp_slim/fastmcp/cli/install/shared.py#L113" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
```pythonwindows_batch_command_line(command: Sequence[str]) -> str```
Build a cmd.exe command line that runs a batch file with literal arguments.
`command[0]` is the batch file path and the remaining items are itsarguments. The returned string is passed verbatim to `CreateProcess` withcmd.exe as the executable. Command extensions are enabled for the `%`handling, delayed expansion and AutoRun commands are disabled, and `/s`makes cmd.exe remove exactly the outer pair of quotes.
**Raises:**- `ValueError`: If the batch file path or an argument cannot be passed.
### `run_cli_command` <sup><a href="https://github.com/PrefectHQ/fastmcp/blob/main/fastmcp_slim/fastmcp/cli/install/shared.py#L142" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
```pythonrun_cli_command(command: list[str]) -> subprocess.CompletedProcess[str]```
Run a client CLI so that it receives each argument literally.
On Windows, a `.cmd` or `.bat` file always runs through cmd.exe, whichwould otherwise interpret operators and `%` expansions in the arguments.For those files the command line is built with`windows_batch_command_line`. Other executables, and every executable onother platforms, receive the argument list directly.
**Raises:**- `subprocess.CalledProcessError`: If the command exits with an error.- `ValueError`: If an argument cannot be passed to a batch file.
### `parse_env_var` <sup><a href="https://github.com/PrefectHQ/fastmcp/blob/main/fastmcp_slim/fastmcp/cli/install/shared.py#L166" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
```pythonparse_env_var(env_var: str) -> tuple[str, str]```
Parse environment variable string in format KEY=VALUE.
### `process_common_args` <sup><a href="https://github.com/PrefectHQ/fastmcp/blob/main/fastmcp_slim/fastmcp/cli/install/shared.py#L182" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
```pythonprocess_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]```
Process common arguments shared by all install commands.
Handles both fastmcp.json config files and traditional file.py:object syntax.
### `open_deeplink` <sup><a href="https://github.com/PrefectHQ/fastmcp/blob/main/fastmcp_slim/fastmcp/cli/install/shared.py#L298" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>
```pythonopen_deeplink(url: str) -> bool```
Attempt to open a deeplink URL using the system's default handler.
**Args:**- `url`: The deeplink URL to open.- `expected_scheme`: The URL scheme to validate (e.g. "cursor", "goose").
**Returns:**- True if the command succeeded, False otherwise.