shared-agent-memory-mcp
A shared, human-auditable long-term memory server for MCP coding agents, backed by Notion or Obsidian with a local search cache.
memory_search: Find saved memories by keyword, semantic, or hybrid search, filtered by project, agent, category, or tag — with optional compact excerpts.memory_recent: List the most recently updated memories to get context on what was learned or saved lately.memory_get: Fetch a single memory's full content by its id.memory_add: Save durable knowledge (preferences, decisions, conventions, bugfixes, context) with metadata like importance, confidence, tags, project scope, idempotency keys, and duplicate checks.memory_update: Correct or evolve an existing memory (title, content, status, tags, metadata) instead of creating duplicates.memory_delete: Archive a memory by default, or permanently delete it withhard=true.
Across tools it supports project/repository scoping (including auto-detecting the current Git repo), agent provenance, category/importance/confidence metadata, and compact vs. full responses.
Shared Agent Memory MCP
A shared, human-auditable long-term memory service for MCP-compatible coding agents (Cline, OpenCode, Claude Code, GitHub Copilot, Hermes, Antigravity, and others).
Supports configurable authoritative primary storage:
Notion primary (default): Notion database holds authoritative memory records, with an optional Obsidian Markdown mirror.
Obsidian primary: Local Markdown files in your Obsidian vault hold authoritative records with zero Notion or network requirements, with an optional Notion remote mirror.
A local SQLite FTS5 index provides fast cached search, with optional local embedding vectors for multilingual semantic and hybrid search.
What works today
Six MCP tools:
memory_search,memory_recent,memory_get,memory_add,memory_update, andmemory_delete.Configurable primary store via
MEMORY_PRIMARY_STORE=notion|obsidian(default:notion).Optional opposite-store mirroring via
MEMORY_SECONDARY_ENABLED=true|false(default:true).Project, agent, category, tag, importance, and provenance metadata.
A CLI for setup, CRUD, export, cache maintenance, diagnostics, conflict inspection, and sync/watch.
Idempotent writes with
idempotencyKeyand local operation journaling.Conflict preservation for manually edited Markdown files during synchronization.
Provider-scoped cache and journal isolation: switching backends automatically treats stale cache entries as invalid.
Storage Modes & Configuration
Set storage engine options in .env or client environment variables:
Setting | Allowed Values | Default | Description |
|
|
| Authoritative source of truth for memories |
|
|
| Mirror writes and sync to the opposite store when configured |
| String ( | - | Required when Notion is primary or active secondary mirror |
| String (32 hex chars) | - | Required when Notion is primary or active secondary mirror |
| String | - | Optional for multi-source Notion databases |
| String (absolute path) | - | Required when Obsidian is primary; optional for mirror |
| String (absolute path) |
| Optional shared SQLite cache path |
Copyable Configuration Examples
1. Notion-Only (No local vault or Git required):
MEMORY_PRIMARY_STORE=notion
MEMORY_SECONDARY_ENABLED=false
NOTION_TOKEN=secret_your_notion_token
NOTION_DATABASE_ID=your_notion_database_id2. Obsidian-Only (Local Markdown only; zero Notion credentials or network calls):
MEMORY_PRIMARY_STORE=obsidian
MEMORY_SECONDARY_ENABLED=false
OBSIDIAN_VAULT_PATH=C:/path/to/your/ObsidianVault3. Notion Primary with Obsidian Mirror (Default dual-write):
MEMORY_PRIMARY_STORE=notion
MEMORY_SECONDARY_ENABLED=true
NOTION_TOKEN=secret_your_notion_token
NOTION_DATABASE_ID=your_notion_database_id
OBSIDIAN_VAULT_PATH=C:/path/to/your/ObsidianVault4. Obsidian Primary with Notion Mirror:
MEMORY_PRIMARY_STORE=obsidian
MEMORY_SECONDARY_ENABLED=true
OBSIDIAN_VAULT_PATH=C:/path/to/your/ObsidianVault
NOTION_TOKEN=secret_your_notion_token
NOTION_DATABASE_ID=your_notion_database_idSearch and sync boundaries
memory_search and CLI search default to keyword mode. A fresh SQLite FTS5 cache matching the current primary store handles eligible active-memory keyword queries; requests with unsupported cache filters or a stale cache query the authoritative store instead. After writes, the cache is invalidated until the next sync or cache rebuild.
Set mode to semantic or hybrid in memory_search, or use CLI search --mode semantic|hybrid, to search a fresh local cache with the multilingual MiniLM model. Semantic mode ranks by embedding similarity; hybrid mode combines those results with FTS5 keyword results. The first such query downloads model files to the local model cache and embeds matching cached records. Later queries reuse persisted record vectors and calculate cosine distance with the installed sqlite-vec extension; a changed title or content is re-embedded. Long memories are split into overlapping 1,200-character chunks, and the best matching chunk determines each memory's semantic rank. Semantic results and hybrid results with a vector match include match.excerpt, match.start, and match.end. Run cache rebuild or sync before using these modes.
MCP memory_search and memory_recent accept response: "compact" to omit full content from their results. Compact results include excerpt: the best matching semantic chunk in search (up to 1,200 Unicode characters), a 240-character window around the matching text for keyword-only search, or the first 240 Unicode characters for recent items. The default response: "full" preserves the complete memory shape.
Synchronization & Conflict Handling
Synchronization direction follows the selected authoritative primary store:
Notion primary:
syncandwatchcopy Notion records to Obsidian.Obsidian primary:
syncandwatchcopy Obsidian records to Notion.
If an Obsidian Markdown file was edited after its last sync in Notion-primary mode, the next sync leaves it intact and writes the latest Notion version to a .conflict.md copy. Use conflicts to list these files and resolve <path> --accept-notion or --keep-obsidian to resolve.
In Obsidian-primary mode, Markdown files in memories/<category>/ are the direct authoritative records; manual edits are read directly by the system upon the next query or cache rebuild.
Secondary failures do not undo a successful primary write. If mirroring fails (e.g. temporary network outage), the primary write succeeds and the failure is reported in mirrorError (and obsidian.error).
Recovery lock sidecars (*.takeover.recovery) are never automatically reclaimed. If a crash leaves one behind and writes or mirroring time out, stop every MCP server, CLI, and watcher writing to that vault, back up the vault, and remove only the abandoned recovery sidecar identified for the blocked lock. Restart the clients afterward. Never remove a lock while any writer is running; preserve memory files, pending-move journals, and mirror mappings.
Safe Store Switching
Switching MEMORY_PRIMARY_STORE between notion and obsidian does not implicitly migrate or merge existing data. The SQLite cache is tagged with source_identity and immediately marks records from the previous backend as stale. Run agent-memory cache rebuild or agent-memory sync after switching to populate the cache from the new primary store.
Related MCP server: obsidian-dev-memory
Requirements
Node.js 22 or newer.
For Notion primary or mirror: A Notion integration token and target database.
For Obsidian primary: An explicit, usable local directory path in
OBSIDIAN_VAULT_PATH(Git is optional).
Quick start
Install from npm
npm install -g @chaerulcp/shared-agent-memory-mcp
# Option A: Notion primary
$env:MEMORY_PRIMARY_STORE = "notion"
$env:NOTION_TOKEN = "secret_your_notion_token"
$env:NOTION_DATABASE_ID = "your_notion_database_id"
# Option B: Obsidian primary (local only)
$env:MEMORY_PRIMARY_STORE = "obsidian"
$env:MEMORY_SECONDARY_ENABLED = "false"
$env:OBSIDIAN_VAULT_PATH = "C:/path/to/your/ObsidianVault"
agent-memory doctorDevelopment from source
git clone https://github.com/Chaerulcp/shared-agent-memory-mcp.git
cd shared-agent-memory-mcp
npm ci
npm run build
Copy-Item .env.example .env
node dist/cli.js doctorThe doctor command checks credentials and storage connectivity according to the configured primary store. doctor --sync also checks the optional vault, watcher, and cache.
CLI examples
agent-memory add --title "Use TypeScript for API" --content "The API uses TypeScript." --agent shared --category decision --project backend-service
agent-memory add --title "Retry-safe memory" --content "A durable fact" --idempotency-key task-2026-09-14-001
agent-memory search "TypeScript API" --project backend-service
agent-memory recent --limit 5
agent-memory get YOUR_MEMORY_ID
agent-memory update YOUR_MEMORY_ID --title "Use TypeScript for backend API"
agent-memory delete YOUR_MEMORY_ID
agent-memory cache rebuild
agent-memory cache search "TypeScript"
agent-memory search "cara memperbaiki mobil" --mode semantic --project backend-service
agent-memory search "TypeScript API" --mode hybrid --project backend-service
agent-memory sync --dry-rundelete archives by default; --hard permanently deletes the record. sync --dry-run reads the primary store without modifying cache, files, Git, or remote Notion.
For all commands and accepted flags, run agent-memory --help or node dist/cli.js --help.
MCP client setup
Configure the MCP server in your client configuration:
Notion Primary Configuration:
{
"command": "notion-memory",
"args": [],
"env": {
"MEMORY_PRIMARY_STORE": "notion",
"NOTION_TOKEN": "${NOTION_TOKEN}",
"NOTION_DATABASE_ID": "${NOTION_DATABASE_ID}"
}
}Obsidian Primary Configuration (Local-Only):
{
"command": "notion-memory",
"args": [],
"env": {
"MEMORY_PRIMARY_STORE": "obsidian",
"MEMORY_SECONDARY_ENABLED": "false",
"OBSIDIAN_VAULT_PATH": "C:/path/to/your/ObsidianVault"
}
}From a source checkout, replace "command": "notion-memory" with "command": "node" and "args": ["C:/path/to/shared-agent-memory-mcp/dist/index.js"].
Setup guides: Claude Code, Codex CLI, OpenCode, Copilot CLI, Cline, Gemini CLI, and other clients.
Validation
npm testThe test suite runs TypeScript build checks and node unit/integration tests covering both Notion and Obsidian storage engines, idempotency, archive lifecycle, cache isolation, and mirror operations.
Contributing and support
See CONTRIBUTING.md, SECURITY.md, and GitHub Issues.
Licensed under the MIT License.
Available Tools
6 toolsmemory_addA
Save a new durable memory into the shared authoritative memory. USE THIS when: the user states a preference, a project decision is made, a convention is established, a non-obvious bug is fixed (root cause + fix), or important project/environment context is learned. Do NOT store secrets, tokens, or throwaway information.
Inputs: agent (required), title (required), content (required), tags, +10 more.
memory_deleteA
Archive a memory (default) or delete permanently (hard=true). Use when a memory is wrong or obsolete.
Inputs: id (required), hard.
memory_getA
Fetch a single memory by its id (full content).
Inputs: id (required).
memory_recentB
List the most recently updated memories from the shared long-term memory. Set response to compact to return excerpts without full content. Use to get context about what was learned/saved lately.
Inputs: agent, limit, project, response, +1 more.
memory_searchA
Search the shared long-term memory (Notion or Obsidian, used by Cline, OpenCode, Claude Code, GitHub Copilot, Hermes). Returns matching memories with id, title, content, agent, category, tags. Semantic and hybrid vector matches also include match.excerpt with Unicode start/end offsets. Set response to compact to omit full content and return an excerpt; use memory_get for full content. USE THIS at the start of a task with relevant keywords, and before making decisions, to reuse saved preferences, conventions, and past decisions.
Inputs: query (required), tag, mode, agent, +5 more.
memory_updateB
Update an existing memory by id. Prefer updating over creating duplicates when knowledge changes or gets corrected.
Inputs: id (required), tags, agent, title, +10 more.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 6 tools
Each tool maps to a distinct retrieval or mutation operation: keyword/semantic search, chronological listing, id-based fetch, create, update, and delete/archive. The boundary between memory_search and memory_recent is clear (query-driven vs time-driven), and descriptions explicitly cross-reference memory_get for full content.
All six tools use the same memory_<verb> pattern (search, get, add, update, delete), making the namespace and action predictable. memory_recent is the only non-verb suffix, but it reads naturally and does not break the pattern.
Six tools is a tight, well-scoped surface for a memory store: retrieval (search/recent/get) plus lifecycle management (add/update/delete). No tool is redundant and nothing obvious is missing at this size.
The full memory lifecycle is covered — discovery (search, recent), read (get), create (add), modify (update), and removal (archive or hard delete). Guidance in the descriptions (prefer update over duplicate, archive default) closes the usual workflow dead ends.
Maintenance
Related MCP Connectors
Private memory for AI agents: save and recall facts across Claude Code, Codex, Cursor and ChatGPT.
Project memory, documentation and controlled secret access for AI coding agents.
Shared memory for coding agents. Stop re-explaining your codebase every session.
Agent-native notes, tasks, dev-docs, vaults, sync & handoffs. MCP + OpenAPI dual surface.
Related MCP Servers
- AlicenseAqualityDmaintenanceEnables AI agents to store and retrieve project context, bugs, decisions, and session logs by reading and appending markdown files in a local Obsidian vault, without requiring any cloud services.6MIT
- AlicenseAqualityBmaintenanceProvides AI coding assistants persistent engineering memory stored as Markdown files in an Obsidian vault, enabling project context retrieval, session capture, decision recording, and memory search without requiring Obsidian to be running.71MIT
- AlicenseAqualityBmaintenanceEnables coding agents to use an Obsidian vault as long-term memory, with search, reading, and writing of notes, plus automatic capture of learnings that are propagated to MOCs, daily notes, and the knowledge index with git commits.954 npmMIT
- AlicenseNot gradedqualityBmaintenanceEnables AI agents to store and retrieve durable memory as markdown notes in an Obsidian vault, with full-text and semantic search, wikilink graph operations, and human-auditable, editable storage.MIT