Fix capture-hooks install wiring a non-runnable in-wheel MCP wrapper (#26)#28
Open
danielhertz1999-bit wants to merge 1 commit into
Open
Conversation
…a#26) _resolve_wrapper_path() returned the wheel-bundled wrapper (iai_mcp/_wrapper/index.js) whenever it merely existed, ahead of a working mcp-wrapper/dist/index.js. The in-wheel copy ships the JS but no node_modules, so Node fails at spawn with "ERR_MODULE_NOT_FOUND: @modelcontextprotocol/sdk" and the iai-mcp MCP entry shows up as failed in Claude. Prefer a wrapper whose npm deps actually resolve: gather the candidate paths in preference order, then return the first one that has a reachable node_modules/@modelcontextprotocol/sdk (matching how Node resolves bare imports). When a wrapper exists but its deps aren't installed, raise FileNotFoundError with a clear "build it / set IAI_MCP_WRAPPER_PATH" message; callers already route that through the placeholder/warning path, so install no longer silently registers a broken MCP server. Reported by @Marsu6996 on v1.2.0. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
Fixes the first half of #26.
The bug
_resolve_wrapper_path()returns the wheel-bundled wrapper (iai_mcp/_wrapper/index.js) as soon as it exists, ahead of a workingmcp-wrapper/dist/index.js. But the in-wheel copy ships the JS with nopackage.jsonand nonode_modules/, so when Claude spawns it Node throws:and the
iai-mcpMCP entry shows as failed.capture-hooks installoverwrites a previously-working dev path with this broken one.The fix
Prefer a wrapper whose npm deps actually resolve. Node resolves bare imports like
@modelcontextprotocol/sdkby walking parent dirs for anode_modulescontaining the package, so the resolver now does the same: it collects the candidate paths in preference order and returns the first one with a reachablenode_modules/@modelcontextprotocol/sdk. The depless in-wheel wrapper is skipped in favour ofmcp-wrapper/distsitting next to itsnode_modules.When a wrapper exists but its deps aren't installed (e.g.
pip install .with nonpmbuild and no dev tree), it now raisesFileNotFoundErrorwith a clear "build it / setIAI_MCP_WRAPPER_PATH" message instead of silently wiring a broken entry — callers already route that through the existing placeholder/warning path (_iai_entry_or_placeholder), so install degrades gracefully rather than producing afailedMCP server.Verification
Unit-tested the resolver against both layouts: in-wheel-without-
node_modulesis correctly treated as not-runnable and skipped;dist-with-node_modulesis preferred. No behavioral change when the in-wheel wrapper is genuinely runnable (i.e. once the wheel bundles its deps).Not included here
The second half of #26 (SessionStart hook re-registration / lack of a
--componentsopt-out) is a separate ergonomics change — happy to send a follow-up adding a--components=stop,turnstyle flag if you'd like that approach.🤖 Generated with Claude Code