xgmem

mcp
Security Audit
Fail
Health Warn
  • License — License: MIT
  • Description — Repository has a description
  • Active repo — Last push 0 days ago
  • Low visibility — Only 7 GitHub stars
Code Fail
  • exec() — Shell command execution in index.ts
  • os.homedir — User home directory access in index.ts
  • process.env — Environment variable access in index.ts
  • exec() — Shell command execution in test.mjs
  • fs.rmSync — Destructive file system operation in test.mjs
  • process.env — Environment variable access in test.mjs
Permissions Pass
  • Permissions — No dangerous permissions requested

No AI report is available for this listing yet.

SUMMARY

Global Memory MCP server, that manage all projects data.

README.md

MseeP.ai Security Assessment Badge

xgmem

Long-term memory for coding agents. Claude Code, Codex, Cursor and any other MCP client share one local store, so what one agent learns about a project, the next one recalls instead of re-reading the code.

  • Free-text memories. No schemas; notes of any length.
  • Hybrid search, small results. Local embeddings (bge-small-en-v1.5 via fastembed) plus SQLite FTS5 keywords. Only the best matches come back in full, so recall stays cheap.
  • Stays in sync. Memories fingerprint the files they describe; stale and recall flag the ones whose code changed.
  • Follows the repo. Git projects are identified by their first commit, so memories survive moves, renames and re-clones.
  • Local only. One SQLite file, no API keys. Nothing leaves the machine.

Quick setup (Claude Code, Codex, Cursor)

Open your agent (Claude Code, Codex or Cursor's agent) in the project and paste this. It installs the server, adds the memory rules and saves the first memories. It's safe to paste again, because steps that are already done get skipped.

Set up xgmem (long-term memory MCP server) for this project. Skip any step that's already done, and don't ask me questions unless a step fails.

1. Check `node --version` is 22.13 or newer. If not, stop and tell me.
2. Add the xgmem MCP server for the tool you are running in, if it isn't there yet:
   - Claude Code: claude mcp add xgmem --scope user -- npx -y xgmem@latest
   - Codex: codex mcp add xgmem -- npx -y xgmem@latest
   - Cursor: add "xgmem": { "command": "npx", "args": ["-y", "xgmem@latest"] } under "mcpServers" in ~/.cursor/mcp.json (merge, keep existing servers)
3. Add the text between BEGIN and END to the rules file for your tool (create it if missing, don't add it twice):
   - Claude Code: CLAUDE.md at the repo root
   - Codex: AGENTS.md at the repo root, without the `@xgmem.md` line
   - Cursor: .cursor/rules/xgmem.mdc, starting with the frontmatter `---` / `alwaysApply: true` / `---`, without the `@xgmem.md` line
4. Add `xgmem.md` to .gitignore.
5. If the xgmem tools (recall, remember) aren't available in this session yet, tell me what to do (Claude Code or Codex: restart it; Cursor: enable xgmem in Settings → MCP) and to paste this prompt again, then stop.
6. Otherwise, explore the repo and save 10-15 memories with `remember` (projectPath = repo root) covering architecture, main flows, config and gotchas. List the files each one describes in `files`.
7. Finish with one line: what you set up and how many memories you saved.

BEGIN
@xgmem.md

## Memory (xgmem)

Before reading code to answer a question or start a task:
1. Look at the titles in xgmem.md, then call xgmem `recall` with a short query and `projectPath` set to this repo's root.
2. If the results answer it, use them and don't re-read those files. Weaker matches come back as one-liners; call `recall` with their `ids` only if you need them. If a result is marked STALE, re-read only the files it lists.
3. If nothing relevant comes back, or it's not enough, explore the code as usual.

After learning something non-obvious (architecture, data flow, decisions and why, gotchas, where things live, conventions):
- Call `remember` with a short title, specific facts (file paths, function names, values) and `files` = the files it describes. Same title replaces the old memory.
- Skip anything obvious from a single file, and never store secrets.

After changing code: call `stale` and re-save every memory it lists (same title), or `forget` it if it no longer applies.
END

Manual setup

1. Install Node.js 22.13+. The first run downloads the embedding model (~65MB) into ~/.xgmem/models.

2. Add the MCP server.

Claude Code

claude mcp add xgmem --scope user -- npx -y xgmem@latest

Codex (CLI, IDE extension and app share ~/.codex/config.toml)

codex mcp add xgmem -- npx -y xgmem@latest

or add it to ~/.codex/config.toml yourself:

[mcp_servers.xgmem]
command = "npx"
args = ["-y", "xgmem@latest"]

Cursor (~/.cursor/mcp.json for all projects, or .cursor/mcp.json for one)

{
  "mcpServers": {
    "xgmem": { "command": "npx", "args": ["-y", "xgmem@latest"] }
  }
}

Other tools (Windsurf, Cline, VS Code, Gemini CLI, ...): any MCP client works. Use the Cursor JSON or the Codex TOML above, whichever format your tool expects, in the config file its MCP docs name. The server is always npx -y xgmem@latest over stdio.

3. Check it's connected. Claude Code: /mcp. Codex: codex mcp list. Cursor: Settings → MCP, then enable xgmem. Other tools: their MCP or tools panel.

4. Add the memory rules. Copy the text between BEGIN and END in the Quick setup prompt into your tool's rules file. That text makes the agent recall first, read code only when memory falls short, and save what it learns.

Tool Rules file
Claude Code CLAUDE.md (keep the @xgmem.md line, which loads the index)
Codex AGENTS.md (drop the @xgmem.md line)
Cursor .cursor/rules/xgmem.mdc with alwaysApply: true frontmatter, or AGENTS.md (drop the @xgmem.md line)
Other tools Their rules or instructions file, or AGENTS.md, which many tools read (drop the @xgmem.md line)

5. Ignore the index. Add xgmem.md to .gitignore. It's created on the first remember, and its ids only make sense on your machine.

6. Save the first memories. Ask once: "Explore this repo and save 10–15 xgmem memories covering architecture, main flows, config and gotchas." Later sessions recall instead of re-exploring.

Tools

Tool Arguments What it does
remember title, content, projectPath?, tags?, files? Saves a memory; same title in the same project replaces it. No projectPath = global.
recall query, projectPath?, limit? (default 5), or ids Hybrid search over that project plus global memories (no projectPath = everything). The best matches come back in full, weaker ones as one-liners. ids returns specific memories in full.
stale projectPath Lists memories whose files changed since they were saved.
forget id Deletes a memory (ids are in xgmem.md and recall results).

How projects are matched: projectPath can be any folder inside the project (the git root is used). Git repos are keyed by their first commit; folders outside git by path. Recalling from a folder outside any repo (e.g. a parent of several repos) also searches the projects below it.

Where memories live

Everything is in one SQLite file, ~/.xgmem/xgmem.db (table memories). Browse it with DB Browser for SQLite, or print it:

node -e "const {DatabaseSync}=require('node:sqlite');const db=new DatabaseSync(require('os').homedir()+'/.xgmem/xgmem.db',{readOnly:true});for(const m of db.prepare('SELECT id,root,title,content FROM memories').all())console.log('#'+m.id,m.title,'('+(m.root||'global')+')\n'+m.content+'\n')"
Variable Default Purpose
XGMEM_HOME ~/.xgmem Database and global xgmem.md
XGMEM_MODEL_DIR ~/.xgmem/models Embedding model cache

Development

npm install
npm test   # builds, then runs an end-to-end check against the real server

CI runs npm test on Ubuntu, macOS and Windows with Node 22.13 and 24.

Try a local build in your agent by pointing the MCP config at it instead of npx:

npm run build
claude mcp add xgmem --scope user -- node /absolute/path/to/xgmem/dist/index.js

Codex and Cursor use the same idea: command = node, args = the path to dist/index.js.

Docker: docker build -t xgmem . && docker run -i -v ~/.xgmem:/data xgmem. The container can only write xgmem.md for mounted project paths, so npx fits per-project memory better.

Upgrading from 0.0.x

1.0 replaces the 0.0.x knowledge-graph tools (create_entities, read_graph, search_nodes, ...) with the four tools above. Old memories aren't migrated. The 0.0.x JSON files in MEMORY_DIR_PATH are left untouched, so you can keep or delete them.

License

MIT

Reviews (0)

No results found