enhx-memory
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
enhx-memory
A persistent, project-scoped memory layer for AI coding agents. Exposes a Model Context Protocol (MCP) server with 45 tools for capturing, searching, deduplicating, relating, and maintaining memory records across long-running coding sessions.
Enterprise-grade by default. The server is 100% automatic β
π Auto-session: opens a session against the cwd (or
INITIAL_PROJECT_PATH) at boot. You never need to callstart_session.π Cwd watcher: polls
process.cwd()and auto-rebinds to a new project when the agent changes directories (worktree, monorepo, etc).π§Ή Auto-curate on session boot: scans the project roots listed in
AUTO_CURATE_ROOTS(README, CHANGELOG, plan files, decisions, agents, package.json) and runs the extractors to persist typed memories (command,error,decision,reference). Idempotent; only re-runs when an mtime changes.π₯ Auto-ingest: user prompts that flow through the MCP transport are persisted as memories with the
auto_ingesttag, debounced per project. Three independent ingest paths (transport frame, per-tool args wrapper, POSIXSIGUSR1debug signal) share a single debounce map, so a payload that arrives twice lands once.π Auto-recall: every project-scoped tool call returns an
auto_recalledarray of the most relevant pinned / type-weighted / recency-decayed memories β the agent never has to remember to callrecall_memories.π§ Memory Manager enforces dedup, near-duplicate merging, project conventions, and importance scoring.
This is the TypeScript rewrite of the original Python/FastMCP
enhx-memory v0.1.0. The two servers share the same SQLite schema
(migrations/0001_initial.sql is byte-identical), so existing databases
work without modification.
Install
A. npx (recommended β zero install)
npx enhx-memoryB. Global npm
npm install -g enhx-memory
enhx-memoryC. Single binary
Download a binary for your platform from the GitHub release page. The binary bundles Node + the server + the migrations.
Related MCP server: Archivist MCP
What's new in 1.1.0
Six phases of content-aware work landed between 1.0.0 and 1.1.0. If you already have a 1.0.x database, the schema is unchanged β just upgrade.
Phase 3 β Content ingest. Four new tools (
ingest_file,ingest_files,extract_commands,extract_errors) and aFileIngesterthat respectsFILE_INGEST_MAX_BYTESand a binary sniff gate.Phase 4 β Auto-curate on session boot. When a session opens,
AutoSessionManagerrunscurate_sessionagainst the configured roots. The synthesized session brief is pinned as a memory, so the nextopen_session_briefreturns it instantly.Phase 5 β Robust transport ingest hook. Every
server.tool(...)call is wrapped so free-text args are inspected for ingestible content. Also wired a POSIXSIGUSR1handler that reads stdin and ingests it β a power-user escape hatch for dumping debug payloads into memory without going through the MCP client.Phase 6 β Recaller v2.
recall_memoriesnow applies type weights (RECALL_TYPE_WEIGHTS) and a per-day recency decay (RECALL_RECENCY_DECAY) on top of the FTS5 score. Pinned memories always come first.Phase 7 β
open_session_brief+export_project_doc. Two new tools that surface the pinned session brief + top-5 recall, and that compose a single Markdown document summarising the active project (capped toFILE_INGEST_MAX_BYTES).
The full test count went from 208 β 323.
MCP client configuration
Claude Desktop / Cursor / Cline
Common β the three knobs most people tweak: log verbosity, how many memories get auto-attached per tool call (the recall cap), and whether the auto-cleanup scheduler runs. Everything else falls back to its default.
{
"mcpServers": {
"enhx-memory": {
"command": "npx",
"args": ["-y", "enhx-memory"],
"env": {
"DATA_DIR": "/path/to/your/data",
"LOG_LEVEL": "INFO",
"AUTO_RECALL_LIMIT": "5",
"ENABLE_AUTO_CLEANUP": "true"
}
}
}
}Note: there is no
MAX_MEMORY_ITEMSβ the closest knob isAUTO_RECALL_LIMIT, which caps how many memories are auto-attached to every tool result. To bound total storage, useENABLE_AUTO_CLEANUPwithCLEANUP_INTERVAL_HOURSandSOFT_DELETE_GRACE_DAYS(below).
Fully-configured β every variable the server reads from env, with
defaults inline. Drop or change the ones you want to override; everything
else is optional.
{
"mcpServers": {
"enhx-memory": {
"command": "npx",
"args": ["-y", "enhx-memory"],
"env": {
"DATA_DIR": "/path/to/your/data",
"DB_FILENAME": "enhx_memory.db",
"LOG_LEVEL": "INFO",
"DEDUP_POLICY": "reject",
"DEDUP_THRESHOLD": "0.8",
"ENABLE_AUTO_CLEANUP": "true",
"CLEANUP_INTERVAL_HOURS": "24",
"SOFT_DELETE_GRACE_DAYS": "7",
"ENABLE_AUTO_SESSION": "true",
"INITIAL_PROJECT_NAME": "",
"INITIAL_PROJECT_PATH": "",
"INITIAL_CLIENT": "auto",
"ENABLE_AUTO_INGEST": "true",
"AUTO_INGEST_DEBOUNCE_SECONDS": "30",
"AUTO_INGEST_MIN_LENGTH": "20",
"ENABLE_AUTO_RECALL": "true",
"AUTO_RECALL_LIMIT": "5",
"AUTO_RECALL_MIN_SCORE": "0",
"AUTO_DETECT_CONVENTIONS": "true",
"ENABLE_CWD_WATCHER": "true",
"CWD_CHECK_INTERVAL_SECONDS": "5",
"ENABLE_FILE_INGEST": "true",
"FILE_INGEST_MAX_BYTES": "262144",
"FILE_INGEST_BINARY_SNIFF": "true",
"AUTO_CURATE_SESSION": "true",
"AUTO_CURATE_ROOTS": "README.md,CHANGELOG.md,plan*.md,plan/*.md,decisions.md,agents.md,package.json,.github/agents.md",
"CURATE_PIN_BRIEF": "true",
"RECALL_TYPE_WEIGHTS": "error:.5,decision:.3,pattern:.25,code:.1,reference:.05,note:0,conversation:0",
"RECALL_RECENCY_DECAY": "0.95"
}
}
}
}Globally-installed npm (the env block is optional β only override what you
need):
{
"mcpServers": {
"enhx-memory": {
"command": "enhx-memory",
"env": {
"LOG_LEVEL": "INFO",
"AUTO_RECALL_LIMIT": "5",
"ENABLE_AUTO_CLEANUP": "true"
}
}
}
}Single binary (same β env block optional):
{
"mcpServers": {
"enhx-memory": {
"command": "/usr/local/bin/enhx-memory",
"env": {
"LOG_LEVEL": "INFO",
"AUTO_RECALL_LIMIT": "5",
"ENABLE_AUTO_CLEANUP": "true"
}
}
}
}CLI flags
Flag | Behavior |
| Print the data directory path and exit |
| Print the install path |
| Wipe the database and logs (refuses without marker file) |
| Remove the install + data dir |
| Print the |
| Print version |
| Print help |
Without flags, the server starts on stdio.
Environment variables
Variable | Default | Description |
|
| Where the DB and logs live |
|
| Database filename |
|
|
|
|
|
|
|
| Jaccard similarity cutoff for near-duplicates |
|
| Run the cleanup scheduler |
|
| Cleanup cycle period |
|
| Days to keep soft-deleted rows before purging |
|
| Open a session at boot against cwd / |
| (none) | Force a specific project name when auto-sessions boot |
| (cwd) | Force a specific project root path when auto-sessions boot |
|
| Client name recorded on the auto-opened session |
|
| Persist user prompts as memories (auto-debounced) |
|
| Debounce window per content hash |
|
| Minimum text length to ingest |
|
| Attach |
|
| Max memories attached per tool call |
|
| Minimum score for non-pinned recall hits |
|
| Detect project conventions on |
|
| Auto-rebind to a new project when |
|
| Polling interval for the cwd watcher |
|
| Enable the |
|
| Hard size cap (bytes) for an ingested file |
|
| Reject binary files before they hit the ingester |
|
| Run |
| 8 glob patterns | Comma-separated glob list of files to curate automatically |
|
| Pin the synthesized session brief as a memory |
| see below |
|
|
| Per-day retention factor in the recency-decay formula |
Note:
ENABLE_AUTO_INGEST,ENABLE_AUTO_RECALL, andENABLE_AUTO_SESSIONall default totrueso the server runs as a fully automatic memory layer out of the box. Set any of them tofalseto opt out of that specific behavior.
The 45 tools
Lifecycle (5)
start_sessionβ open a session against a project (auto-creates if needed). When called with no arguments, delegates toAutoSessionManagerand returns anauto_recalledarray of relevant memories. Sessions opened via the auto-curate hook also attach a freshly-pinned session brief (seeopen_session_brief).get_project_summaryβ counts + recent memories for the active project, plusauto_recalled.list_projectsβ all known projects.notify_project_changeβ explicit signal that the agent has switched projects (e.g. into a git worktree, multi-repo monorepo, or any case the cwd watcher can't see). Takes{cwd?, project_name?, root_path?, reason?}; rebinds the active project, opens a fresh session, and returns the new active project + anauto_recalledarray.get_active_projectβ return the currently active project and session (auto-recovers a session if none is active).
Conventions (4)
detect_project_typeβ sniff files at a root pathdetect_and_save_project_conventionsβ persist conventions on the project rowremember_project_patternβ save a project-specific pattern as a memoryget_project_conventionsβ return saved conventions
Auto-ingest (2)
set_auto_ingestβ toggle + configure the auto-ingest middlewareget_auto_ingest_statusβ current config + counters
Recall & ingest (2)
recall_memoriesβ free-text recall. Type-weighted + recency-decayed (Recall v2): pinned memories always come first, then FTS hits scored byRECALL_TYPE_WEIGHTSandRECALL_RECENCY_DECAY. ReturnsRecalledMemory[]with score and reason.add_user_messageβ convenience tool for the agent to persist every user prompt as aconversation-type memory taggeduser_prompt. Auto-recall is also attached.
Memories (8)
Every project-scoped tool here returns an auto_recalled array of relevant
memories, so the agent never needs to issue a separate recall_memories
call.
add_memoryβ insert with optional type/tags/importance/file pathsget_memoryβ fetch a single row (bumps access count)list_memoriesβ paginated list with filterssearch_memoriesβ FTS5 + LIKE searchupdate_memoryβ patch fields on an existing memorydelete_memoryβ soft-delete (preserved until cleanup)count_memoriesβ fast count with filtersbulk_add_memoriesβ insert many in one call
Dedup (3)
find_duplicatesβ scan project for near-duplicatesmerge_memoriesβ combine two memories (rewires relations, hard-deletes source)set_dedup_policyβreject/merge/warn/off+ threshold
Relations (5)
add_relationβ directed edge between two memoriesremove_relationβ drop edges (optionally filtered by type)get_relationsβ incoming + outgoing edges for a memoryget_related_memoriesβ BFS up to N hopslist_relation_typesβ distinct types currently used
Tasks (4)
create_taskβ new task in the active projectlist_tasksβ paginated with status/priority filtersupdate_task_statusβpending/in_progress/done/cancelleddelete_taskβ remove by id
Cleanup (3)
cleanup_old_dataβ purge soft-deleted rows + VACUUM/ANALYZEoptimize_memoriesβ drop orphans + canonicalize JSONset_cleanup_policyβ adjust interval / grace / enable
System (3)
health_checkβ DB, FTS, active project, scheduler, auto-ingest statusget_database_statsβ table row counts + sizeget_performance_statsβ per-tool call counts, latencies, error rates
Content ingest (4)
Tools for slurping project files into typed memories. Designed to be called by an agent that wants to "remember" what a plan, an error log, or a decisions file says without re-reading it on every turn.
ingest_fileβ read a single file (binary sniff + size cap), run the extractors, persist typed memories. Idempotent via content-hash.ingest_filesβ batch over a list of paths in one call.extract_commandsβ pull shell-command lines out of free text and return them as typedcommandmemories (no DB write).extract_errorsβ pull error / stack-trace blocks out of free text and return them as typederrormemories (no DB write).
Session & export (2)
open_session_briefβ return the pinned session brief for the active project plus recent memory sections and the top 5 v2-recall hits. Cheap to call; meant to be the first thing the agent reads when it wakes up in a new session.export_project_docβ compose a single Markdown document summarising the active project (header, brief, conventions, recent memories, pending tasks, recent errors, frequent commands, recent decisions). Capped toFILE_INGEST_MAX_BYTES. Useful as anAGENTS.mdsource.
Development
git clone https://github.com/enhx/enhx-memory.git
cd enhx-memory
npm install
npm run typecheck # tsc --noEmit
npm run lint # eslint
npm test # vitest run (323 tests)
npm run build # tsc β dist/
npm start # node bin/enhx-memory.mjs (uses dist/)
npm run dev # tsx src/index.ts (no build needed)Test coverage is configured to fail under 80 % line coverage (vitest --coverage).
Architecture
src/
index.ts # entry β boots DB, AppContext, McpServer, transport
config.ts # ServerConfig (zod-validated, env-driven)
logging.ts # pino + rotating file
context.ts # AppContext (DI bag)
perf/tracker.ts # per-tool latency tracking
errors.ts # ToolError / DatabaseError / ValidationError
version.ts # reads version from package.json at runtime
util/ # csv, json, signals, time
db/ # DatabaseManager + per-table CRUD (better-sqlite3)
dedup/ # normalize + MinHash + Jaccard
domain/ # MemoryManager, RelationsManager, TasksManager,
# ProjectConventionLearner, AutoSessionManager,
# AutoIngestMiddleware, CleanupScheduler,
# FileIngester, MemoryCurator, Recall v2,
# extractors (commands/errors/decisions/refs)
tools/ # 45 MCP tools across 13 register files
# (lifecycle, conventions, auto-ingest, recall,
# memories, dedup, relations, tasks, cleanup,
# system, ingest, session-brief, export-project)
# + transport wrapper + helpers
migrations/ # 0001_initial.sql (verbatim from Python v0.1.0)
bin/enhx-memory.mjs # CLI launcher
tests/ # vitest suite (323 tests across helpers, db,
# domain, dedup, unit, integration, tools)The full rewrite plan is in TS_REWRITE_PLAN.md.
License
MIT
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelogβ¦
This server cannot be deployed
Maintenance
Related MCP Connectors
Persistent memory and knowledge management for AI agents with semantic search and 50+ tools.
Persistent memory for AI agents: save, search and connect context across tools and sessions.
Memory for AI agent teams across tools, sessions, repositories, and teammates.
Shared memory for coding agents. Stop re-explaining your codebase every session.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceProvides AI coding assistants with persistent project memory to retain architectural decisions, code patterns, and domain knowledge across sessions. It stores data locally in a SQLite database, allowing agents to remember, recall, and manage project-specific context using full-text search.3 npmApache 2.0
- AlicenseNot gradedqualityDmaintenanceA local-first memory layer for coding agents to persist and retrieve project decisions, architecture context, and rules across multiple development sessions. It utilizes a three-tier memory model and hybrid retrieval to provide agents with durable, searchable context and a WebUI for human review.4MIT
- AlicenseCqualityBmaintenanceProvides persistent, local-first memory with knowledge graph and hybrid search for AI coding agents, reducing token usage by storing decisions, patterns, and codebase context.2976 PyPI10MIT
- AlicenseNot gradedqualityDmaintenanceProvides long-term memory for AI coding agents, enabling them to remember, search, and organize information across sessions and platforms like Claude Code, ChatGPT, and Cursor.8MIT