@lb-internal/mem-install
v0.5.0
Published
Install the LongBridge mem MCP server + memory PROTOCOL plugin (hooks/rules) into local AI coding clients (Claude Code, Claude Desktop, Cursor, Codex, Cline, Windsurf, …).
Maintainers
Readme
@lb-internal/mem-install
Install the LongBridge mem MCP server and the memory PROTOCOL plugin into local AI coding clients — Claude Desktop, Claude Code, Cursor, Codex, Cline, Roo Cline, Windsurf, Witsy, Enconvo.
A single npx invocation ships TWO things:
- MCP server config (always) — so the client knows where to find the remote memory server at
memory.longbridge.xyz. - Plugin material (default, can be disabled with
--mcp-only) — hooks (SessionStart,UserPromptSubmit, etc.) for hook-capable clients and PROTOCOL rule / system-prompt files for the rest. Essential because most MCP clients do NOT forwardFastMCP.instructionsto the model — only tool descriptions and user-scope context reach it. Without the plugin, even a perfectly-configured MCP server can be silently ignored on the first user turn.
Since v0.5.0, Plugin install covers:
- Claude Code + Claude Cowork/Desktop (shared
~/.claude/config; user-scope hooks dodge the Cowork plugin-hook bug) - Cursor, Cline, Windsurf (workspace
Rulesfiles) - Codex CLI (
~/.codex/hooks.json+codex_hooks=trueflag +AGENTS.override.md)
Replaces @openmemory/install local for memory.longbridge.xyz. The upstream installer still pins SSE, which the LongBridge mem server no longer exposes after the Streamable HTTP migration.
Usage
One-shot install for every detected client (recommended)
npx @lb-internal/mem-installAuto-detects each installed MCP client and:
- registers one
lb-memMCP server entry in its config, and - installs PROTOCOL plugin material (hooks for Claude Code, rule files for IDE-rule clients, user-global override for Codex).
Sample output:
✓ claudecode mcp → ~/.claude.json
plugin → ~/.claude/settings.json (8 script(s) → ~/.claude/scripts/lb-mem/, 6 hook event(s) merged)
✓ claude mcp → ~/Library/Application Support/Claude/claude_desktop_config.json
plugin → ~/.claude/settings.json (8 script(s) → ~/.claude/scripts/lb-mem/, 6 hook event(s) merged)
✓ cursor mcp → ~/.cursor/mcp.json
plugin → ./.cursor/rules/mem0-protocol.mdc
✓ codex mcp → ~/.codex/config.toml
plugin → ~/.codex/hooks.json (AGENTS.override.md → .codex/AGENTS.override.md; 8 script(s) → ~/.codex/scripts/lb-mem/, 6 hook event(s); codex_hooks=true set in config.toml)
- cline (skipped: client not detected)
- windsurf (skipped: client not detected)
- roocline (skipped: client not detected)
- witsy (skipped: client not detected)
- enconvo (skipped: client not detected)
4 installed · 5 skipped · 0 error(s)
→ restart each updated client to pick up the new server.Install for one specific client
npx @lb-internal/mem-install --client cursorInstall MCP config only (skip plugin)
npx @lb-internal/mem-install --mcp-onlyReverts to v0.3.0 behaviour — useful when you already manage your protocol prompt some other way, or when you're testing MCP config changes in isolation.
Scope memory to a specific user
npx @lb-internal/mem-install --header "X-User-Id: alice"Different deployment (staging / preview / dev)
npx @lb-internal/mem-install --host https://memory-staging-2.longbridge.xyzWhat the Plugin actually installs
| Client | Plugin action | Where it lands | Scope |
|---|---|---|---|
| claudecode | Copy 8 lifecycle hook scripts + merge hook entries into settings.json | ~/.claude/scripts/lb-mem/ + ~/.claude/settings.json | User-global |
| claude (Desktop / Cowork) | Same as claudecode — Cowork shares ~/.claude/ with Claude Code. User-scope hooks at ~/.claude/settings.json deliberately dodge the Cowork plugin-hook silent-exclusion bug. | ~/.claude/scripts/lb-mem/ + ~/.claude/settings.json | User-global |
| cursor | Always-apply rule file with alwaysApply: true frontmatter | <cwd>/.cursor/rules/mem0-protocol.mdc | Workspace (run per repo) |
| cline | Rule file under .clinerules/ directory | <cwd>/.clinerules/mem0-protocol.md | Workspace (run per repo) |
| windsurf | Managed-block append into .windsurfrules | <cwd>/.windsurfrules | Workspace (run per repo) |
| codex | TWO complementary pieces — system-prompt AGENTS.override (read every session) and lifecycle hooks (8 scripts + hooks.json + codex_hooks=true enabled in config.toml) | ~/.codex/AGENTS.override.md + ~/.codex/hooks.json + ~/.codex/scripts/lb-mem/ + ~/.codex/config.toml | User-global |
| roocline, witsy, enconvo | (skipped) | — | No rules / hooks mechanism (Roo Code falls back to .clinerules if cline is also installed). |
Idempotency
Re-running npx @lb-internal/mem-install is safe:
- Claude Code hooks: existing lb-mem hook entries are removed before re-adding, so no duplicates.
- Cursor / Cline / Codex rule files: rewritten verbatim (file is fully owned by the installer; identified by the
<!-- managed by lb-mem-install -->header). - Windsurf: only the content between
<!-- BEGIN lb-mem-install managed block -->and<!-- END lb-mem-install managed block -->is replaced; any user-authored content above or below is preserved.
What workspace files get committed?
The Cursor / Cline / Windsurf rule files land in your current working directory. If that's a Git repo, you probably want to commit them so teammates pick up the same protocol. Each file starts with a <!-- managed by lb-mem-install --> header that documents how to regenerate.
What about Claude Desktop / Cowork?
v0.5.0 update: Claude Desktop (Cowork) now supports the same plugin format as Claude Code and shares the ~/.claude/ config tree. The installer detects claude and writes user-scope hooks into ~/.claude/settings.json plus scripts into ~/.claude/scripts/lb-mem/ — these fire in Cowork because they're in the user scope (the Cowork plugin-hook silent-exclusion bug only affects plugin-scoped hooks under ~/.claude/plugins/).
If you have BOTH Claude Code AND Claude Desktop detected, the installer writes the same hook entries twice idempotently — no duplicates, no harm.
Transport per client (MCP-config side)
Most clients are bridged through supergateway in --streamableHttp mode (stdio command → HTTP). A few clients speak the MCP Streamable HTTP transport natively, so the installer writes a direct HTTP entry for them and skips the supergateway hop:
| Client | Transport | Config file |
|---|---|---|
| Claude Desktop | supergateway (stdio) | ~/Library/Application Support/Claude/claude_desktop_config.json |
| Claude Code | native HTTP | ~/.claude.json |
| Cursor | native HTTP | ~/.cursor/mcp.json |
| Codex CLI | supergateway (stdio) | ~/.codex/config.toml (TOML) |
| Cline | supergateway (stdio) | VS Code globalStorage / saoudrizwan.claude-dev |
| Roo Cline | supergateway (stdio) | VS Code globalStorage / rooveterinaryinc.roocline |
| Windsurf | supergateway (stdio) | ~/.codeium/windsurf/mcp_config.json |
| Witsy | supergateway (stdio) | ~/Library/Application Support/Witsy/settings.json |
| Enconvo | supergateway (stdio) | ~/.config/enconvo/mcp_config.json |
Options
| Flag | Default | Notes |
|---|---|---|
| --client <name> | (auto-detect all) | One of claude, claudecode, cursor, codex, cline, roocline, windsurf, witsy, enconvo, or all. Omit to install for every detected client. |
| --host <url> | https://memory.longbridge.xyz | Remote MCP host. Endpoint is auto-derived as {host}/mcp/{client}/. |
| --url <url> | (auto from --host) | Override the auto-derived endpoint entirely. Escape hatch for non-standard paths. With install-all, the same URL is reused for every client (skip derivation). |
| --name <id> | lb-mem | Server entry key written to each client's config. |
| --header "K: V" | — | HTTP header to forward. Repeat for multiple. |
| --config-path <path> | (auto) | Force-write to this path. Requires explicit --client <name> (install-all writes to many paths). |
| --mcp-only | (plugin install enabled by default) | Skip plugin install (hooks for Claude Code, rule files for Cursor/Cline/Windsurf, AGENTS.override.md for Codex). Reverts to v0.3.0 behaviour. |
Known issue: conflict with mem0@mem0-plugins
If you previously installed the official mem0@mem0-plugins Claude Code plugin (via /plugin install mem0@mem0-plugins), it registers hooks via the plugin marketplace path (~/.claude/plugins/cache/mem0-plugins/...). Running mem-install adds a second set of hooks under ~/.claude/scripts/lb-mem/. Result: lifecycle hooks fire twice (one set hits hosted mcp.mem0.ai, the other hits memory.longbridge.xyz).
If you want LongBridge-only:
/plugin uninstall mem0@mem0-pluginsin Claude Code- Re-run
npx @lb-internal/mem-installto register hooks viasettings.json
Auto-detection of this collision and a --migrate-from-plugin helper are out of scope for v0.4.0.
Development
cd tools/lb-mem-install
pnpm install
pnpm build
# Sandbox test (writes to /tmp, not your real config locations):
mkdir /tmp/test && cd /tmp/test
node /path/to/dist/index.js --client cursor --config-path /tmp/test/mcp.json
ls -R /tmp/testThe prebuild npm script runs scripts/build-payload.mjs, which copies the canonical hook scripts from ../../mem0-plugin/scripts/ and the canonical PROTOCOL text from ../../openmemory/PROTOCOL.md into src/payload/. The postbuild script then mirrors src/payload/ → dist/payload/ so tsup's output ships the bundled assets.
src/payload/ is .gitignored; edit the canonical sources instead.
Publish
npm login # log into @lb-internal org owner
npm publish --access public --registry=https://registry.npmjs.org/publishConfig.access=public is pinned in package.json; --registry is required because the system-wide registry may point at a Chinese mirror.
