> ## Documentation Index
> Fetch the complete documentation index at: https://gofastmcp.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# shared

# `fastmcp.cli.install.shared`

Shared utilities for install commands.

## Functions

### `validate_server_name` <sup>[https://github.com/PrefectHQ/fastmcp/blob/main/fastmcp\_slim/fastmcp/cli/install/shared.py#L32](https://github.com/PrefectHQ/fastmcp/blob/main/fastmcp_slim/fastmcp/cli/install/shared.py#L32)</sup>

```python theme={"theme":{"light":"snazzy-light","dark":"dark-plus"}}
validate_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>[https://github.com/PrefectHQ/fastmcp/blob/main/fastmcp\_slim/fastmcp/cli/install/shared.py#L80](https://github.com/PrefectHQ/fastmcp/blob/main/fastmcp_slim/fastmcp/cli/install/shared.py#L80)</sup>

```python theme={"theme":{"light":"snazzy-light","dark":"dark-plus"}}
quote_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 the
original literal string. This follows the batch file argument quoting in
Rust's standard library: arguments are wrapped in double quotes so cmd.exe
treats `&`, `|`, `<`, `>`, `^`, parentheses and similar characters as
text, including when the batch file expands them again through `%*`.
Embedded quotes are doubled, which both cmd.exe and the Microsoft C
runtime read as a literal quote. Each `%` is rewritten so cmd.exe does not
expand environment variables. Delayed `!` expansion is disabled by the
command processor options in `windows_batch_command_line`.

**Raises:**

* `ValueError`: If the argument contains a line break. cmd.exe ends the
  command at a line break, so it cannot be passed literally.

### `windows_batch_command_line` <sup>[https://github.com/PrefectHQ/fastmcp/blob/main/fastmcp\_slim/fastmcp/cli/install/shared.py#L113](https://github.com/PrefectHQ/fastmcp/blob/main/fastmcp_slim/fastmcp/cli/install/shared.py#L113)</sup>

```python theme={"theme":{"light":"snazzy-light","dark":"dark-plus"}}
windows_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 its
arguments. The returned string is passed verbatim to `CreateProcess` with
cmd.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>[https://github.com/PrefectHQ/fastmcp/blob/main/fastmcp\_slim/fastmcp/cli/install/shared.py#L142](https://github.com/PrefectHQ/fastmcp/blob/main/fastmcp_slim/fastmcp/cli/install/shared.py#L142)</sup>

```python theme={"theme":{"light":"snazzy-light","dark":"dark-plus"}}
run_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, which
would 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 on
other 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>[https://github.com/PrefectHQ/fastmcp/blob/main/fastmcp\_slim/fastmcp/cli/install/shared.py#L166](https://github.com/PrefectHQ/fastmcp/blob/main/fastmcp_slim/fastmcp/cli/install/shared.py#L166)</sup>

```python theme={"theme":{"light":"snazzy-light","dark":"dark-plus"}}
parse_env_var(env_var: str) -> tuple[str, str]
```

Parse environment variable string in format KEY=VALUE.

### `process_common_args` <sup>[https://github.com/PrefectHQ/fastmcp/blob/main/fastmcp\_slim/fastmcp/cli/install/shared.py#L182](https://github.com/PrefectHQ/fastmcp/blob/main/fastmcp_slim/fastmcp/cli/install/shared.py#L182)</sup>

```python theme={"theme":{"light":"snazzy-light","dark":"dark-plus"}}
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]
```

Process common arguments shared by all install commands.

Handles both fastmcp.json config files and traditional file.py:object syntax.

### `open_deeplink` <sup>[https://github.com/PrefectHQ/fastmcp/blob/main/fastmcp\_slim/fastmcp/cli/install/shared.py#L298](https://github.com/PrefectHQ/fastmcp/blob/main/fastmcp_slim/fastmcp/cli/install/shared.py#L298)</sup>

```python theme={"theme":{"light":"snazzy-light","dark":"dark-plus"}}
open_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.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.