PrefectHQ/fastmcp · error · RuntimeError
Failed to add dependencies: {e.stderr}
Error message
Failed to add dependencies: {e.stderr} What it means
prepare() runs `uv add <deps> fastmcp --no-sync --project <dir>` and wraps any nonzero exit in this RuntimeError. It means uv failed to resolve or add the configured `dependencies` (plus fastmcp itself) to the generated project's pyproject.toml. uv's stderr is embedded in the message.
Source
Thrown at fastmcp_slim/fastmcp/utilities/mcp_server_config/v1/environments/uv.py:207
dependencies = (self.dependencies or []) + ["fastmcp"]
logger.debug(f"Adding dependencies: {', '.join(dependencies)}")
try:
subprocess.run(
[
"uv",
"add",
*dependencies,
"--no-sync",
"--project",
str(output_dir),
],
check=True,
capture_output=True,
text=True,
)
except subprocess.CalledProcessError as e:
logger.error(f"Failed to add dependencies: {e.stderr}")
raise RuntimeError(f"Failed to add dependencies: {e.stderr}") from e
# Add requirements file if specified
if self.requirements:
logger.debug(f"Adding requirements from {self.requirements}")
# Resolve requirements path relative to current directory
req_path = Path(self.requirements).resolve()
try:
subprocess.run(
[
"uv",
"add",
"-r",
str(req_path),
"--no-sync",
"--project",
str(output_dir),
],
check=True,View on GitHub (pinned to 1f02114297)
Solutions
- Read e.stderr: fix the exact package/spec uv reports (typo, nonexistent package, invalid specifier).
- Relax or remove the conflicting version pin reported in the resolution error (e.g. fastmcp>=2.0 instead of fastmcp==2.3.1 if it conflicts).
- Verify the package exists on the configured index; add private indexes via UV_INDEX_URL/--index if needed.
- Test resolution outside fastmcp: `uv add <dep> --no-sync --project <tmpdir>` to reproduce and iterate quickly.
- Temporarily remove entries from environment.dependencies to isolate which one breaks resolution.
Example fix
// before "dependencies": ["fastmcp==2.3.1", "pandas<2.0"] # conflicts with deps needing pandas>=2 // after "dependencies": ["fastmcp>=2.0", "pandas>=2.0"]
Defensive patterns
Strategy: validation
Validate before calling
import subprocess, tempfile, pathlib
deps = cfg.environment.dependencies or []
with tempfile.TemporaryDirectory() as d:
subprocess.run(["uv", "init", "--project", d, "--name", "probe"], check=True, capture_output=True)
r = subprocess.run(["uv", "add", *deps, "fastmcp", "--no-sync", "--project", d], capture_output=True, text=True)
if r.returncode != 0:
raise SystemExit(f"deps unresolvable: {r.stderr}") Try / catch
try:
await env.prepare(output_dir)
except RuntimeError as e:
if str(e).startswith("Failed to add dependencies"):
print(e) # stderr names the unresolvable spec; fix config, then retry
else:
raise Prevention
- Validate every entry is a well-formed PEP 508 specifier before adding it to config
- Avoid hard equality pins on fastmcp or your deps' transitive requirements
- Test the dependency set in a scratch uv project first
- Document required private index config (UV_INDEX_URL) for teammates
When it happens
Trigger: prepare() with environment.dependencies containing a package name/spec uv cannot resolve: nonexistent package, an invalid PEP 508 specifier, or a version that conflicts with fastmcp or another entry (uv resolves all adds together).
Common situations: Typo'd package name ("reqests"); pinning fastmcp==1.x alongside an installed fastmcp 2.x wheel requirement; conflicting pins like httpx<0.24 with a dep requiring newer httpx; private packages not reachable from the configured index.
Related errors
- Failed to add requirements: {e.stderr}
- Failed to pin Python version: {e.stderr}
- Failed to add editable packages: {e.stderr}
- Failed to sync dependencies: {e.stderr}
- uv is not installed. Please install it with: curl -LsSf http
AI-assisted analysis of PrefectHQ/fastmcp@1f02114297 (2026-08-29).
Data as JSON: /api/errors/4effa35a665bb2de.
Report an issue: GitHub.