|
10 | 10 | from rich import print |
11 | 11 |
|
12 | 12 | from fastmcp.mcp_config import StdioMCPServer, update_config_file |
| 13 | +from fastmcp.utilities.cli import build_uv_run_args |
13 | 14 | from fastmcp.utilities.logging import get_logger |
14 | 15 |
|
15 | 16 | from .shared import process_common_args |
@@ -106,31 +107,14 @@ def install_cursor_workspace( |
106 | 107 |
|
107 | 108 | config_file = cursor_dir / "mcp.json" |
108 | 109 |
|
109 | | - # Build uv run command |
110 | | - args = ["run"] |
111 | | - |
112 | | - # Add Python version if specified |
113 | | - if python_version: |
114 | | - args.extend(["--python", python_version]) |
115 | | - |
116 | | - # Add project if specified |
117 | | - if project: |
118 | | - args.extend(["--project", str(project)]) |
119 | | - |
120 | | - # Collect all packages in a set to deduplicate |
121 | | - packages = {"fastmcp"} |
122 | | - if with_packages: |
123 | | - packages.update(pkg for pkg in with_packages if pkg) |
124 | | - |
125 | | - # Add all packages with --with |
126 | | - for pkg in sorted(packages): |
127 | | - args.extend(["--with", pkg]) |
128 | | - |
129 | | - if with_editable: |
130 | | - args.extend(["--with-editable", str(with_editable)]) |
131 | | - |
132 | | - if with_requirements: |
133 | | - args.extend(["--with-requirements", str(with_requirements)]) |
| 110 | + # Build uv run command using centralized function |
| 111 | + args = build_uv_run_args( |
| 112 | + with_editable=with_editable, |
| 113 | + with_packages=with_packages, |
| 114 | + python_version=python_version, |
| 115 | + with_requirements=with_requirements, |
| 116 | + project=project, |
| 117 | + ) |
134 | 118 |
|
135 | 119 | # Build server spec from parsed components |
136 | 120 | if server_object: |
@@ -194,31 +178,14 @@ def install_cursor( |
194 | 178 | Returns: |
195 | 179 | True if installation was successful, False otherwise |
196 | 180 | """ |
197 | | - # Build uv run command |
198 | | - args = ["run"] |
199 | | - |
200 | | - # Add Python version if specified |
201 | | - if python_version: |
202 | | - args.extend(["--python", python_version]) |
203 | | - |
204 | | - # Add project if specified |
205 | | - if project: |
206 | | - args.extend(["--project", str(project)]) |
207 | | - |
208 | | - # Collect all packages in a set to deduplicate |
209 | | - packages = {"fastmcp"} |
210 | | - if with_packages: |
211 | | - packages.update(pkg for pkg in with_packages if pkg) |
212 | | - |
213 | | - # Add all packages with --with |
214 | | - for pkg in sorted(packages): |
215 | | - args.extend(["--with", pkg]) |
216 | | - |
217 | | - if with_editable: |
218 | | - args.extend(["--with-editable", str(with_editable)]) |
219 | | - |
220 | | - if with_requirements: |
221 | | - args.extend(["--with-requirements", str(with_requirements)]) |
| 181 | + # Build uv run command using centralized function |
| 182 | + args = build_uv_run_args( |
| 183 | + with_editable=with_editable, |
| 184 | + with_packages=with_packages, |
| 185 | + python_version=python_version, |
| 186 | + with_requirements=with_requirements, |
| 187 | + project=project, |
| 188 | + ) |
222 | 189 |
|
223 | 190 | # Build server spec from parsed components |
224 | 191 | if server_object: |
|
0 commit comments