The Model Context Protocol (MCP) is the primary way MemPalace JS connects to AI agents.
MemPalace JS is designed to work seamlessly with Claude Code.
First, ensure you have the package installed globally, or use npx:
Option A: Global Install (Recommended)
npm install -g @mempalace/core
mempalace install-hooksOption B: One-time use via npx
npx -y @mempalace/core install-hooksYou can configure Claude Code to automatically save the conversation to MemPalace every few exchanges.
- Install the hooks as shown above.
- Add the
postExchangeHookto your Claude configuration:claude config set postExchangeHook "~/.mempalace/hooks/mempal_save_hook.sh"
Claude Code periodically "compacts" its context window. You can trigger a memory save right before this happens to ensure no information is lost:
claude config set preCompactHook "~/.mempalace/hooks/mempal_precompact_hook.sh"To give the Claude Desktop app access to your memory palace:
-
Locate your Claude Desktop configuration:
- macOS:
~/Library/Application Support/Claude/claude_desktop_config.json - Windows:
%APPDATA%\Claude\claude_desktop_config.json
- macOS:
-
Add the
mempalaceserver entry:
{
"mcpServers": {
"mempalace": {
"command": "npx",
"args": ["-y", "@mempalace/core", "mcp"]
}
}
}- Restart Claude Desktop. You should see a ⚡ icon (or tool list) showing the
mempalacetools.
Once connected via MCP, the agent has access to 19 tools:
| Tool Name | Purpose |
|---|---|
mempalace_status |
Get total drawer count and palace path. |
mempalace_search |
Semantic vector search for specific queries. |
mempalace_wake_up |
Load L0 Identity and L1 Essential Story. |
mempalace_recall |
Fetch verbatim drawers from a specific wing/room. |
mempalace_get_taxonomy |
See the full list of wings and rooms. |
mempalace_kg_query |
Query the relationship graph (triples) for an entity. |
mempalace_kg_add |
Manually add a fact to the knowledge graph. |
mempalace_diary_write |
Allow an agent to record its own "thoughts" in a diary wing. |
mempalace_traverse_graph |
Navigate connected rooms across different wings. |
If you see timeouts in your agent, it usually means the AI model is being downloaded for the first time.
- Background Download: MemPalace JS automatically downloads the ~90MB model on the first search/mine if it's missing.
- Silent Progress: The download progress is redirected to
stderr, so it won't crash your MCP connection, but it may cause the first few tool calls to exceed the default timeout. - Fix: Run
mempalace setup(ornpx @mempalace/core setup) in your terminal once to pre-download the model before using it in Claude.
Ensure you have run the mempalace mine <dir> command on your project first. The MCP server only reads what has been indexed into the lancedb folder.