Skip to main content
Glama

agent-memory

Local memory for AI coding agents. An MCP server that gives Claude Code, Cursor and any other MCP client a shared memory across sessions: hybrid search over notes and past conversations, a knowledge graph, a code graph, a web UI and a small CLI (amx). Everything is stored on your machine in ~/.agent-memory/.

Knowledge map in the web UI, demo data

Features

  • Master context: a short briefing per project that a new session loads first, plus session handoffs (in progress, next steps, blockers).

  • Hybrid search: BM25 and local embeddings fused with reciprocal rank fusion, weighted by source and recency.

  • Conversation ingest: reads Claude Code transcripts (~/.claude*/projects/) and curated memory notes into the store.

  • Knowledge graph: typed entities and labeled links.

  • Code graph: imports, exports, routes, models and env vars of a repo, with an optional file watcher (watcher/) that keeps it fresh.

  • Web UI: live knowledge map, ranked search with a Cmd-K palette, memory editor, sessions and briefing, agent chat, code graph, health and the key vault.

  • Agent chat: agents on the same machine send each other short messages (amx msg), with an optional Telegram bridge to your phone.

  • Key vault: API keys in the macOS Keychain, filed by project, injected into commands as env vars.

Related MCP server: mcp-vector-memory

Install

Needs Bun and Node.js 20+.

git clone https://github.com/kumard3/agent-memory
cd agent-memory
bun install
bun run build

amx search and amx pattern also need ripgrep and ast-grep on your PATH.

MCP config

Claude Code:

claude mcp add agent-memory -- node /path/to/agent-memory/dist/index.js

Cursor or any other MCP client:

{
  "mcpServers": {
    "agent-memory": {
      "command": "node",
      "args": ["/path/to/agent-memory/dist/index.js"]
    }
  }
}

dist/index.js is a small stdio front. It starts the real server on the first request and stops it after 10 idle minutes, so an idle session holds about 16 MB. Change the delay with AGENT_MEMORY_IDLE_MS (0 keeps it running).

SKILL.md tells an agent when to call memory_context, memory_store, memory_query and memory_session_end. Copy it into your agent's skills or instructions.

MCP tools

Tool

What it does

memory_context

Load the project briefing. Call it first.

memory_store / memory_query

Save knowledge, search it

memory_relate / memory_graph

Link entities, read the graph

memory_forget / memory_prune / memory_compact

Remove or tidy entries

memory_session_end

Save a handoff and refresh the briefing

memory_ingest / memory_sync_notes

Pull in Claude Code transcripts and memory notes

memory_distill_session

Turn a transcript into memories (uses the claude CLI)

memory_backfill_embeddings / memory_stats

Maintenance

code_graph_index / code_graph_query

Build and query the code graph

code_search / repo_map

Text or structural code search, repo map by import rank

vault_set / vault_list

Save a key, list key names (values never returned)

Web UI

bun run ui
# http://127.0.0.1:41999 (change with AGENT_MEMORY_UI_PORT)

Binds to localhost only.

To try it on fake data without touching your own store:

scripts/demo-ui.sh
# seeds a demo store in $TMPDIR on first run, then serves http://127.0.0.1:41997

amx CLI

bun link            # puts amx on your PATH, or run: bun src/cli.ts <cmd>

amx map --focus billing --max-tokens 300     # repo map ranked by imports
amx query invoice                            # code graph lookup
amx search "ctx.db.invoice" --max 5          # ripgrep
amx pattern 'ctx.db.$M.findMany($$$)' --lang ts

amx msg send claude-main codex-web "pushed feat/x, need a review" --project myapp
amx msg inbox codex-web

printf %s "$TOKEN" | amx key set myapp STRIPE_SECRET_KEY --note "test mode"
amx key env myapp -- npm run dev             # runs with the keys as env vars

Run amx, amx msg, amx key or amx tg for full help.

Telegram bridge (optional): store TELEGRAM_BOT_TOKEN with amx key set agent-memory TELEGRAM_BOT_TOKEN, run amx tg run, then pair with amx tg pair. Agents reach you with amx msg send <id> <owner> "text", where the owner id is $AMX_OWNER (default owner).

Numbers

Measured on an Apple Silicon Mac:

  • Idle MCP server: 16 MB.

  • Warm search: about 0.08 s on a store with 105k memories.

  • Code graph query: 0.2 s.

Privacy

  • Runs fully local and works offline. The embedding model downloads once from Hugging Face on first use and is cached in ~/.agent-memory/models. After that nothing leaves your machine, except the optional Telegram bridge and memory_distill_session (which calls the claude CLI).

  • The key vault stores values in the macOS Keychain (macOS only). The UI and MCP tools can write keys and list names, but never send values over HTTP or MCP.

Environment

Variable

Default

Purpose

AGENT_MEMORY_UI_PORT

41999

Web UI port

AGENT_MEMORY_IDLE_MS

600000

Idle time before the server stops

AGENT_MEMORY_EMBEDDING_MODEL

Xenova/bge-small-en-v1.5

Embedding model

AGENT_MEMORY_RERANK

off

1 enables a cross-encoder rerank

AMX_PROJECT

folder name

Default project for amx msg and the Telegram bridge

AMX_OWNER

owner

Your id in agent chat, reserved for the Telegram bridge

Development

bunx tsc --noEmit
bun src/msg.ts && bun src/tg.ts && bun src/vault.ts
bun scripts/ui-check.ts    # and the other scripts/*-check.ts

scripts/eval.ts measures retrieval (recall@K, MRR) against a query set, for example HOME=<demo-home> bun scripts/eval.ts live eval/demo-eval.json.

License

MIT

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      C
      maintenance
      Gives multiple AI coding agents a shared, persistent memory by indexing your code and documentation into a vector database with AST-aware chunking and hybrid semantic/keyword search. Agents can search across projects and store, update, or forget decisions, conventions and lessons learned, all self-hosted with local embeddings.
      MIT
    • F
      license
      Not graded
      quality
      A
      maintenance
      Enables AI coding agents to read and write persistent, local-first memory across sessions and projects, with semantic search, global guidelines, and optional autonomous task execution.
      -
    • F
      license
      Not graded
      quality
      A
      maintenance
      Provides AI coding agents with a local-first persistent memory layer they can read and write during sessions, storing decisions, preferences, error patterns, and research per project or globally. Enables semantic and keyword search, formatted context recall, and cross-project guideline surfacing without API keys or cloud storage.
      -