Skip to content

Fix: Use absolute path to uv executable when installing MCP server (closes #478) #481

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 35 additions & 1 deletion src/mcp/cli/claude.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import json
import os
import platform
import subprocess
import sys
from pathlib import Path
from typing import Any
Expand All @@ -13,6 +15,30 @@
MCP_PACKAGE = "mcp[cli]"


def find_uv_path() -> str | None:
"""Find the full path to the 'uv' executable across platforms"""

system = platform.system()

if system == "Windows":
try:
result = subprocess.run(
["where", "uv"], capture_output=True, text=True, check=True
)
paths = result.stdout.strip().split("\n")
return paths[0] if paths else None
except subprocess.CalledProcessError:
return None
else:
try:
result = subprocess.run(
["which", "uv"], capture_output=True, text=True, check=True
)
return result.stdout.strip()
except subprocess.CalledProcessError:
return None


def get_claude_config_path() -> Path | None:
"""Get the Claude config directory based on platform."""
if sys.platform == "win32":
Expand Down Expand Up @@ -117,7 +143,15 @@ def update_claude_config(
# Add fastmcp run command
args.extend(["mcp", "run", file_spec])

server_config: dict[str, Any] = {"command": "uv", "args": args}
uv_path = find_uv_path()
if uv_path:
server_config: dict[str, Any] = {"command": uv_path, "args": args}
logger.debug(f"Using full path to uv: {uv_path}")
else:
server_config: dict[str, Any] = {"command": "uv", "args": args}
logger.warning(
"Could not determine full path to uv executable, using without path"
)

# Add environment variables if specified
if env_vars:
Expand Down