-
-
Notifications
You must be signed in to change notification settings - Fork 397
Description
Bug Description
When using claude-mem MCP search tools (e.g., search, get_recent_context, decisions) without explicitly passing the project parameter, the tools default to the project name "thedotmack" instead of the user's actual project directory.
Expected Behavior
MCP search tools should default to the user's current working directory project name (e.g., T9_Oracle_v8 when running Claude Code from /path/to/T9_Oracle_v8).
Actual Behavior
The tools return:
No previous sessions found for project "thedotmack".
Even when running Claude Code from a completely different project directory.
Root Cause
The issue is in src/shared/paths.ts in the getCurrentProjectName() function:
export function getCurrentProjectName(): string {
try {
const gitRoot = execSync('git rev-parse --show-toplevel', {
cwd: process.cwd(), // ← BUG: This is the MCP server's cwd, not user's project
encoding: 'utf8',
stdio: ['pipe', 'pipe', 'ignore'],
windowsHide: true
}).trim();
return basename(gitRoot);
} catch {
return basename(process.cwd());
}
}When the MCP server runs, process.cwd() is the plugin installation directory (~/.claude/plugins/marketplaces/thedotmack/), which is itself a git repository. So git rev-parse --show-toplevel returns that directory, and basename() returns "thedotmack".
Verification
# From plugin directory:
cd ~/.claude/plugins/marketplaces/thedotmack && git rev-parse --show-toplevel | xargs basename
# Output: thedotmackEnvironment
- claude-mem version: 7.1.14
- OS: Fedora Linux 43 (also likely affects all platforms)
- Claude Code version: Latest
- Worker status: Running and healthy (port 37777)
- Database: Exists at
~/.claude-mem/claude-mem.db
Workaround
Explicitly pass the project parameter to all MCP search calls:
mcp__plugin_claude-mem_claude-mem-search__search(
query="your search",
project="YourProjectName" # Must be explicit
)Suggested Fix
The MCP server needs to receive the Claude Code session's working directory context. Possible approaches:
- Pass cwd via MCP protocol: If Claude Code can pass the session's cwd to MCP servers, use that instead of
process.cwd() - Environment variable: Set an env var like
CLAUDE_CODE_CWDthat the MCP server can read - Hooks approach: The hooks already have correct cwd access - perhaps cache the project name from hook calls and use it as fallback in MCP tools
Additional Context
- The hooks (
context-hook.ts,new-hook.ts,user-message-hook.ts) correctly usepath.basename(cwd)wherecwdcomes from the Claude Code context - Only the MCP server-side tools are affected because they run in a separate process