File size: 5,182 Bytes
1814d17
 
 
 
 
 
 
 
a2aa9d2
1814d17
 
 
dcd54e9
1814d17
 
 
 
 
 
 
 
 
dcd54e9
1814d17
 
 
 
 
 
 
 
 
e526bb1
1814d17
 
 
 
 
dcd54e9
1814d17
 
 
 
 
 
 
 
 
 
e526bb1
1814d17
 
 
 
 
dcd54e9
293074b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
dcd54e9
1814d17
 
 
 
 
 
 
 
 
 
 
 
 
 
 
dcd54e9
293074b
 
 
 
 
 
 
 
 
dcd54e9
1814d17
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
dcd54e9
1814d17
 
293074b
1814d17
 
 
 
 
 
293074b
1814d17
 
 
a2aa9d2
1814d17
 
a2aa9d2
293074b
1814d17
dcd54e9
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
---
title: run
sidebarTitle: run
---

# `fastmcp.cli.run`


FastMCP run command implementation with enhanced type hints.

## Functions

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

```python
is_url(path: str) -> bool
```


Check if a string is a URL.


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

```python
parse_file_path(server_spec: str) -> tuple[Path, str | None]
```


Parse a file path that may include a server object specification.

**Args:**
- `server_spec`: Path to file, optionally with \:object suffix

**Returns:**
- Tuple of (file_path, server_object)


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

```python
import_server(file: Path, server_object: str | None = None) -> Any
```


Import a MCP server from a file.

**Args:**
- `file`: Path to the file
- `server_object`: Optional object name in format "module\:object" or just "object"

**Returns:**
- The server object


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

```python
run_with_uv(server_spec: str, python_version: str | None = None, with_packages: list[str] | None = None, with_requirements: Path | None = None, project: Path | None = None, transport: TransportType | None = None, host: str | None = None, port: int | None = None, path: str | None = None, log_level: LogLevelType | None = None, show_banner: bool = True) -> None
```


Run a MCP server using uv run subprocess.

**Args:**
- `server_spec`: Python file, object specification (file\:obj), or URL
- `python_version`: Python version to use (e.g. "3.10")
- `with_packages`: Additional packages to install
- `with_requirements`: Requirements file to use
- `project`: Run the command within the given project directory
- `transport`: Transport protocol to use
- `host`: Host to bind to when using http transport
- `port`: Port to bind to when using http transport
- `path`: Path to bind to when using http transport
- `log_level`: Log level
- `show_banner`: Whether to show the server banner


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

```python
create_client_server(url: str) -> Any
```


Create a FastMCP server from a client URL.

**Args:**
- `url`: The URL to connect to

**Returns:**
- A FastMCP server instance


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

```python
create_mcp_config_server(mcp_config_path: Path) -> FastMCP[None]
```


Create a FastMCP server from a MCPConfig.


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

```python
import_server_with_args(file: Path, server_object: str | None = None, server_args: list[str] | None = None) -> Any
```


Import a server with optional command line arguments.

**Args:**
- `file`: Path to the server file
- `server_object`: Optional server object name
- `server_args`: Optional command line arguments to inject

**Returns:**
- The imported server object


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

```python
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) -> None
```


Run a MCP server or connect to a remote one.

**Args:**
- `server_spec`: Python file, object specification (file\:obj), MCPConfig file, or URL
- `transport`: Transport protocol to use
- `host`: Host to bind to when using http transport
- `port`: Port to bind to when using http transport
- `path`: Path to bind to when using http transport
- `log_level`: Log level
- `server_args`: Additional arguments to pass to the server
- `show_banner`: Whether to show the server banner
- `use_direct_import`: Whether to use direct import instead of subprocess


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

```python
run_v1_server(server: FastMCP1x, host: str | None = None, port: int | None = None, transport: TransportType | None = None) -> None
```