Skip to content

Commit 21ac404

Browse files
authored
Merge pull request #118 from samefarrar/mcp-instead-of-fastmcp-install
Use mcp instead of fastmcp CLI as command in "mcp install"
2 parents 59fff69 + e65404a commit 21ac404

File tree

2 files changed

+58
-2
lines changed

2 files changed

+58
-2
lines changed

src/mcp/cli/claude.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ def update_claude_config(
8787
args = ["run"]
8888

8989
# Collect all packages in a set to deduplicate
90-
packages = {"fastmcp"}
90+
packages = {"mcp"}
9191
if with_packages:
9292
packages.update(pkg for pkg in with_packages if pkg)
9393

@@ -107,7 +107,7 @@ def update_claude_config(
107107
file_spec = str(Path(file_spec).resolve())
108108

109109
# Add fastmcp run command
110-
args.extend(["fastmcp", "run", file_spec])
110+
args.extend(["mcp", "run", file_spec])
111111

112112
server_config = {
113113
"command": "uv",

tests/client/test_config.py

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
import json
2+
import subprocess
3+
from pathlib import Path
4+
from unittest.mock import patch
5+
6+
import pytest
7+
8+
from mcp.cli.claude import update_claude_config
9+
10+
11+
@pytest.fixture
12+
def temp_config_dir(tmp_path):
13+
"""Create a temporary Claude config directory."""
14+
config_dir = tmp_path / "Claude"
15+
config_dir.mkdir()
16+
return config_dir
17+
18+
@pytest.fixture
19+
def mock_config_path(temp_config_dir):
20+
"""Mock get_claude_config_path to return our temporary directory."""
21+
with patch('mcp.cli.claude.get_claude_config_path', return_value=temp_config_dir):
22+
yield temp_config_dir
23+
24+
def test_command_execution(mock_config_path):
25+
"""Test that the generated command can actually be executed."""
26+
# Setup
27+
server_name = "test_server"
28+
file_spec = "test_server.py:app"
29+
30+
# Update config
31+
success = update_claude_config(
32+
file_spec=file_spec,
33+
server_name=server_name,
34+
)
35+
assert success
36+
37+
# Read the generated config
38+
config_file = mock_config_path / "claude_desktop_config.json"
39+
config = json.loads(config_file.read_text())
40+
41+
# Get the command and args
42+
server_config = config["mcpServers"][server_name]
43+
command = server_config["command"]
44+
args = server_config["args"]
45+
46+
test_args = [command] + args + ["--help"]
47+
48+
result = subprocess.run(
49+
test_args,
50+
capture_output=True,
51+
text=True,
52+
timeout=5
53+
)
54+
55+
assert result.returncode == 0
56+
assert "usage" in result.stdout.lower()

0 commit comments

Comments
 (0)