summarylogtreecommitdiffstats
path: root/use-installed-binary.patch
blob: 008f7e3d6180e49a5538fcfe27c4e493b72ad1c7 (plain)
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
--- a/src/jcodemunch_mcp/cli/init.py
+++ b/src/jcodemunch_mcp/cli/init.py
@@ -47,9 +47,22 @@
 # capabilities at need instead of carrying 91 schemas plus a long policy in every
 # turn. Naming the workflow, not the catalogue, is what keeps that promise.

+def _server_command() -> str:
+    """Executable for the MCP server entry.
+
+    This distro package installs a real ``jcodemunch-mcp`` on PATH, so launch
+    it directly. The upstream default of ``uvx jcodemunch-mcp`` is wrong for a
+    system install: ``uvx`` may not be present (and is not a dependency), and
+    even when it is it fetches a *separate* copy from PyPI, bypassing the
+    installed package. Resolve to an absolute path so it works regardless of
+    the spawning shell's PATH; fall back to the bare name.
+    """
+    return shutil.which("jcodemunch-mcp") or "jcodemunch-mcp"
+
+
 _MCP_ENTRY = {
-    "command": "uvx",
-    "args": ["jcodemunch-mcp"],
+    "command": _server_command(),
+    "args": [],
 }

 def _hook_invocation() -> str:
@@ -477,7 +490,7 @@
         servers = {}
     servers["jcodemunch"] = {
         "type": "local",
-        "command": ["uvx", "jcodemunch-mcp"],
+        "command": [_MCP_ENTRY["command"]],
         "enabled": True,
     }
     data["mcp"] = servers
@@ -500,17 +513,17 @@
 def _configure_claude_code(*, dry_run: bool = False) -> str:
     """Run `claude mcp add` for Claude Code CLI."""
     if dry_run:
-        return "  would run: claude mcp add jcodemunch uvx jcodemunch-mcp"
+        return f"  would run: claude mcp add jcodemunch {_MCP_ENTRY['command']}"
     claude = _claude_cli_exe()
     if not claude:
         return "  claude CLI not found — skipped"
     try:
         result = subprocess.run(
-            [claude, "mcp", "add", "jcodemunch", "uvx", "jcodemunch-mcp"],
+            [claude, "mcp", "add", "jcodemunch", _MCP_ENTRY["command"]],
             capture_output=True, text=True, encoding="utf-8", errors="replace", timeout=30,
         )
         if result.returncode == 0:
-            return "  ran: claude mcp add jcodemunch uvx jcodemunch-mcp"
+            return f"  ran: claude mcp add jcodemunch {_MCP_ENTRY['command']}"
         # Already exists or other non-fatal issue
         stderr = result.stderr.strip()
         if "already exists" in stderr.lower():