fix(mcp): actionable error when [mcp] extra is missing (#159)#162
Closed
J0nd1sk wants to merge 1 commit into
Closed
fix(mcp): actionable error when [mcp] extra is missing (#159)#162J0nd1sk wants to merge 1 commit into
J0nd1sk wants to merge 1 commit into
Conversation
`brainctl-mcp` (entry point agentmemory.mcp_server:run) imported the MCP SDK at module top level with no guard. On a plain `pip install brainctl` / `pipx install brainctl` (no `[mcp]` extra) it died with a bare `ModuleNotFoundError: No module named 'mcp'` traceback, and the MCP client only reported "failed to connect" — giving the user no idea an extra was required. Guard the import and exit(1) with the exact fix (`pip install 'brainctl[mcp]'`, plus the pipx-inject variant). Also clarify the README Install section so `[mcp]` is presented as part of the install command, not an optional second step. Fixes #159 Co-Authored-By: Claude Opus 4.8 (1M context) <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.
Closes #159.
Problem
brainctl-mcpimported the MCP SDK unguarded atmcp_server.py:36. Without the optional[mcp]extra (the default forpip install brainctl/pipx install brainctl), it crashed with a bareModuleNotFoundError, surfacing to MCP clients only as "failed to connect."Fix
from mcp.server import Server; on a missingmcppackage, write an actionable hint to stderr (pip install 'brainctl[mcp]', plus thepipx injectvariant) andexit(1). Any otherModuleNotFoundErrorre-raises unchanged.[mcp]reads as part of the install command, not an optional second step.Test
tests/test_mcp_missing_extra.pyruns the server import in a subprocess withmcpblocked at import time and asserts a cleanexit(1)with the hint (no traceback). Normal import path (withmcppresent) is unaffected.Verification