fix: Claude Code support for MCP server installation#169
Merged
Conversation
Add support for --debug flag in MCP add/remove commands to enable verbose logging during MCP server configuration. Changes: - Add debug?: boolean to runMCPInstall() parameters in bin.ts - Call enableDebugLogs() when debug flag is set in src/mcp.ts This enables users to troubleshoot MCP server installation issues by running: wizard mcp add --debug
Add debug logging to MCP client detection and fix a bug where the wizard warned about MCP servers installed in unselected clients. Changes: - Import and use debug() in getSupportedClients() - Log each client's detection status (✓ supported / ✗ not supported) - Log final count and list of supported clients - Fix: only check isServerInstalled() for user-selected clients instead of all supported clients Bug fixed: When user selects "Claude Code", wizard no longer warns about PostHog MCP server already being installed in "Claude Desktop". This improves UX by only showing relevant reinstall prompts and makes troubleshooting easier with visibility into detection logic.
Claude Code detection was failing when the 'claude' binary wasn't in the shell's PATH. The wizard uses execSync with /bin/sh which doesn't load shell startup files (.zshrc, .bashrc) that configure PATH. Root cause: Users install Claude Code which creates the binary at ~/.claude/local/claude, then add a shell alias. When the wizard runs, it can't find 'claude' because aliases don't work in execSync. Solution: Check standard Claude Code installation locations: - ~/.claude/local/claude (standard installation path) - /usr/local/bin/claude (system install) - /opt/homebrew/bin/claude (Homebrew on Apple Silicon) - Falls back to PATH check using 'command -v' The found binary path is cached and reused for all MCP operations (mcp list, mcp add, mcp remove) to ensure consistent behavior. Debug logging shows which paths were checked when Claude Code isn't found, helping users troubleshoot installation issues. Fixes: Users reported Claude Code not appearing in the MCP client selection list despite having it installed and working.
joshsny
approved these changes
Nov 8, 2025
Collaborator
joshsny
left a comment
There was a problem hiding this comment.
This looks great - thanks for doing this!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes multiple issues preventing Claude Code from appearing in the MCP client selection list and successfully installing the PostHog MCP server.
Issues Fixed
1. Claude Code not detected
Problem: The
claudebinary wasn't found because it's typically installed at~/.claude/local/claudeand added as a shell alias, butexecSyncdoesn't load shell configurations.Solution: Check known Claude Code installation paths:
~/.claude/local/claude(standard installation)/usr/local/bin/claude/opt/homebrew/bin/claude2. Wrong client shown in reinstall warning
Problem: When selecting only Claude Code, wizard warned about PostHog MCP server already installed in Claude Desktop.
Solution: Only check
isServerInstalled()for user-selected clients, not all supported clients.3. Environment variable expansion broken in Claude Code
Problem: Claude Code has multiple bugs with environment variable expansion in MCP server args. The behavior is inconsistent across different config locations and versions:
GitHub Issues:
${VAR}not sent from.mcp.json.mcp.jsonObserved behavior:
${VAR}works in~/.claude.json(user config) but not.mcp.json(project config)${VAR}expansion fails in~/.claude.jsonas well, sending literal"${POSTHOG_AUTH_HEADER}"instead of the token valueSolution: Claude Code uses a custom config builder (
buildClaudeCodeConfig()) that:https://protocol (mcp-remote requires valid URLs, was missing causing "Invalid URL" errors)Authorization:Bearer phx_...instead ofAuthorization:${VAR}This workaround works reliably across all Claude Code configurations (user and project scope).
Other clients (Claude Desktop, Cursor, VS Code, Zed) continue using the standard config with
${VAR}expansion as they don't have these bugs.4. Debug flag support
Enhancement: Added
--debugflag support to MCP commands with logging showing:Testing
wizard mcp add --debugNotes
claude mcp add-json) rather than file-based config like other clients. Properly testing would require extensive mocking ofexecSynccalls. Manual testing confirms all fixes work correctly.