-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Description
Bug Report: Hive-Mind Session Resume Does Not Restore MCP Server State
Environment
- claude-flow version: 2.7.42 (alpha)
- Node.js version: v25.2.1
- Platform: macOS Darwin 25.1.0 (arm64)
- Claude Code: Latest
Summary
When resuming a hive-mind session with --claude flag, the MCP server starts with empty in-memory state instead of loading the persisted session/swarm data from .hive-mind/sessions/. This causes all mcp__claude-flow__* tool calls to fail with "Swarm not found" errors, even though the CLI correctly shows the session as active.
Steps to Reproduce
-
Create a hive-mind session:
claude-flow hive-mind spawn --objective "Test task" --workers 4 --claude -
Work with the session, then pause (Ctrl+C)
-
Resume the session:
claude-flow hive-mind resume session-1765101696583-uqbb9abjt --claude
-
In the spawned Claude Code instance, try to use MCP tools:
mcp__claude-flow__swarm_status(swarmId: "swarm-1765101696582-fbc3nfj1p")
Expected Behavior
The MCP server should load the persisted swarm state from .hive-mind/sessions/ so that:
mcp__claude-flow__swarm_statusreturns the active swarm infomcp__claude-flow__memory_usageretrieves stored collective memory- All swarm coordination tools work with the resumed session
Actual Behavior
{
"success": false,
"error": "Swarm swarm-1765101696582-fbc3nfj1p not found",
"timestamp": "2025-12-08T10:34:05.020Z"
}The CLI shows the session correctly:
claude-flow hive-mind status
# Shows: hive-1765101696578 with 5 agents, status: active
But MCP tools cannot find it because:
- CLI stores state in
.hive-mind/sessions/directory (JSON files) - MCP server maintains separate in-memory state
- On resume,
--claudeonly injects context into Claude's prompt, but doesn't initialize MCP server state
Additional Issue: SQLite Module Incompatibility
The MCP server also fails to initialize the memory store due to native module version mismatch:
[ERROR] [memory-store] Failed to initialize: Error: The module
'/Users/aleksi/.npm/_npx/.../better_sqlite3.node'
was compiled against a different Node.js version using
NODE_MODULE_VERSION 137. This version of Node.js requires
NODE_MODULE_VERSION 141.
This occurs because:
npx claude-flow@alphacaches the package with native modules compiled for an older Node.js- User updates Node.js but the cached native module is stale
Workaround: npm cache clean --force and reinstall
Proposed Solution
Option A: MCP Server Loads State from Disk
On startup, MCP server should:
- Check for active sessions in
.hive-mind/sessions/ - Load swarm state from checkpoint JSON files
- Initialize in-memory state to match persisted state
Option B: CLI Initializes MCP State on Resume
The hive-mind resume --claude command should:
- After spawning Claude Code, send initialization commands to MCP
- Use MCP tools to recreate the swarm with same ID/state
- Populate memory namespace with persisted data
Option C: Unified State Store
Replace separate CLI/MCP state stores with a single source of truth:
- Both CLI and MCP read/write to same SQLite database
- Use file locking for concurrent access
- MCP server watches for changes
Files Involved
.hive-mind/sessions/session-*-auto-save-*.json- Checkpoint data.hive-mind/sessions/hive-mind-resume-*.txt- Resume prompt templatessrc/mcp/mcp-server.js- MCP server (starts with empty state)src/cli/- CLI commands (manage.hive-mind/sessions/)
Workaround
Currently, users must either:
- Initialize a new swarm via MCP after resume (loses continuity)
- Use only CLI commands, not MCP tools
- Manually track progress outside of hive-mind (e.g., TODO.md file)
Related Issues
- May be related to the general architecture of having separate CLI and MCP systems
- Similar to issues with multiple MCP server instances causing state confusion