server-memory
A local-first, durable knowledge graph MCP server backed by SQLite+FTS5, providing structured memory for AI agents across sessions. Key capabilities:
Entity & Relation Management
Create, delete (soft/hard), and merge entities with types, observations, tags, and metadata
Create and delete typed, weighted relations between entities (e.g.,
depends_on,implements)
Memory Recall & Search
memory_context— lightweight (~200–500 token) recall snapshot with pinned entities and recent activitymemory_context_full— richer bootstrap context (~500–1500 tokens) for deep recallsearch_nodes— BM25-ranked FTS5 full-text search with prefix, phrase, and boolean operators; filterable by tags, entity types, and time rangeread_graph— browse the full graph (compressed or full JSON), optionally filteredopen_nodes— retrieve specific entities by name with optional BFS neighbor expansion
Observations & Versioning
Add observations with
source,confidence,importance, and typedobs_type(fact, decision, api_endpoint, file_path, config, schema, etc.); protected types survive compressionView full observation version history per entity
Activity Logging & Timeline
log_activity— record events (file changes, bugs fixed, decisions, etc.) with entity links, tags, and session metadataquery_timeline— query history by relative time (e.g.,"2h","7d"), ISO ranges, action types, entity name, or session ID
Tag Management
List, create, delete, apply, remove, and clean up tags; supports ephemeral tags with auto-expiry
Import / Export / Backup
Export graph as JSON or JSONL (compatible with
@modelcontextprotocol/server-memory)Import JSON/JSONL, skipping duplicates and invalid relations
Backup SQLite database to a timestamped file
Statistics
View entity/relation/observation counts, tag distribution, DB size, orphan entities, and deleted item counts
Memory Scoping & Deployment
Operate on
workspace(default) orglobalpreference memory; combine results with source labelsRun as a direct stdio server or as a shared localhost HTTP daemon with stdio proxy for multi-client access
Optional embedding-assisted semantic retrieval
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@server-memoryremember that Alice likes programming in Python"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Overview
server-memory is an open-source Model Context Protocol server for durable AI-agent memory. It stores project facts, decisions, observations, relations, preferences, and activity in local SQLite databases, then returns compact, scoped context when an agent needs continuity across sessions.
It is designed for agents that repeatedly work on the same repositories, systems, incidents, or long-running tasks and need to remember what was already learned without replaying an entire conversation or loading the full knowledge graph every turn.
It is intentionally boring where memory should be boring: local storage, explicit tools, inspectable data, bounded output, and predictable failure modes.
Data remains local unless it is explicitly exported. The default transport is stdio. An optional shared HTTP daemon binds to localhost and uses local bearer-token authentication by default.
Related MCP server: tartarus-mcp
Why server-memory
LLM agents commonly lose useful state between sessions. Common workarounds have real costs:
repeating repository discovery and diagnostics
pasting large handoff summaries into every new session
consuming context with stale or irrelevant history
forgetting accepted decisions, constraints, and unresolved work
mixing user preferences with project-specific facts
depending on hosted memory services for data that should stay local
server-memory addresses those problems with durable, queryable memory that can be read selectively instead of replayed wholesale.
The project is intended to improve:
Cross-session continuity: retain facts and decisions after the original conversation ends.
Context efficiency: return compact, relevant snippets instead of the entire stored graph.
Task completion: help agents continue prior work without rediscovering established state.
Reduced repeated work: preserve attempted commands, known failures, file locations, and next steps.
Safer scope separation: keep workspace memory distinct from optional global preference memory.
Local control: use inspectable SQLite databases without requiring external service credentials.
These are design goals, not performance claims. Verified results will be published only after controlled benchmark runs are complete.
How it works
Memory model
The server stores:
Entities: projects, files, modules, services, people, configurations, incidents, and other named objects.
Observations: durable facts, decisions, preferences, paths, dependencies, code snippets, and configuration details.
Relations: typed links between entities.
Tags: project scopes, pinned items, preferences, and workflow labels.
Activity: decisions, changes, fixes, and other events worth carrying into later sessions.
Retrieval path
Routine recall uses memory_context:
Scope the lookup to the active workspace and optional global preference database.
Collect candidates through FTS5, optional embeddings, activity links, and fallback matching.
Rank candidates using exact-name, lexical, semantic, importance, confidence, pinned, activity, access-recency, and staleness signals.
Suppress duplicate or low-value matches.
Return bounded snippets plus conflict and stale-state indicators.
The goal is to return the smallest useful memory slice for the current task, not to place the entire database in model context.
At a glance
Capability | Implementation |
Storage | SQLite with WAL mode and FTS5 search |
Memory model | Entities, observations, relations, tags, and activity |
MCP interface | 20 tools; no MCP resources or prompts |
Routine recall | Compact |
Broader recall |
|
Retrieval | FTS5, ranking signals, fuzzy fallback, and optional embeddings |
Scopes | Workspace memory and optional global preference memory |
Default transport | stdio |
Shared mode | Localhost HTTP daemon with a stdio proxy |
Data paths | Platform-native user data and runtime directories through |
License | MIT |
Design principles
Local-first: core operation requires no hosted database or external service credential.
Selective recall: query relevant memory rather than replaying all stored history.
Bounded context: token budgets and compact formatting limit retrieval output.
Explicit durability: agents choose what to store through MCP tools.
Inspectable state: memory remains readable, exportable, and testable.
Scope safety: destructive operations reject
scope="all".Graceful degradation: lexical retrieval remains available without embeddings.
Architecture
Default stdio mode
┌────────────┐ stdio ┌─────────────────────┐
│ MCP client │ ────────────────────> │ server-memory │
└────────────┘ │ FastMCP server │
├─────────────────────┤
│ Workspace SQLite DB │
│ │
│ Global preferences │
│ DB, when enabled │
└─────────────────────┘Optional shared mode
┌────────────┐ stdio ┌─────────────────────┐
│ MCP client │ ───────────────> │ server-memory-proxy │
└────────────┘ └──────────┬──────────┘
│
│ HTTP
│ 127.0.0.1:8765/mcp
▼
┌─────────────────────┐
│ server-memory-serve │
│ FastMCP daemon │
└─────────────────────┘Use shared mode when multiple local clients should access one database process rather than opening the same database independently.
Requirements
Python 3.10 or newer
SQLite with FTS5 enabled
Git and
pipfor installation from the repository
Check FTS5 support:
python -c "import sqlite3; c=sqlite3.connect(':memory:'); c.execute('CREATE VIRTUAL TABLE t USING fts5(content)'); c.close(); print('FTS5 available')"No hosted CI status is used as proof of compatibility. Validate the package locally on the operating system and Python version where it will run.
Installation
Core installation
python -m pip install "server-memory @ git+https://github.com/MK-986123/server-memory.git"Installation with embeddings
python -m pip install "server-memory[embeddings] @ git+https://github.com/MK-986123/server-memory.git"Embeddings are optional. Core storage and FTS5 retrieval work without them.
Development checkout
git clone https://github.com/MK-986123/server-memory.git
cd server-memory
python -m venv .venv
source .venv/bin/activate
python -m pip install --upgrade pip
python -m pip install -e ".[dev]"On Windows PowerShell:
.venv\Scripts\Activate.ps1Install development and embedding dependencies together:
python -m pip install -e ".[dev,embeddings]"AI coding agents working in this repository should follow AGENTS.md. Contributors should also read CONTRIBUTING.md.
Quick start
Run the stdio server
server-memoryEquivalent module form:
python -m server_memoryUse a dedicated project database
MEMORY_DB_PATH=<PROJECT_ROOT>/memory.db server-memoryUse the equivalent environment-variable syntax for your shell on Windows.
Run the shared localhost daemon
server-memory-serve \
--host 127.0.0.1 \
--port 8765 \
--transport streamable-httpConnect a stdio-only client to the daemon
server-memory-proxy --url http://127.0.0.1:8765/mcpMCP client configuration
Direct stdio server
{
"mcpServers": {
"server-memory": {
"command": "server-memory",
"env": {
"MEMORY_PROJECT": "<PROJECT_NAME>"
}
}
}
}Shared daemon proxy
Start server-memory-serve separately, then configure the MCP client to launch the proxy:
{
"mcpServers": {
"server-memory": {
"command": "server-memory-proxy",
"args": [
"--url",
"http://127.0.0.1:8765/mcp"
]
}
}
}Recommended agent behavior
Use memory only when prior state may materially improve the task.
Call
memory_context(hint="current topic", limit=3-5)when earlier decisions, project facts, preferences, or unresolved work may matter.Skip memory lookup for one-off answers or tasks already fully grounded in the current context.
Store durable facts and decisions, not routine conversation.
Use
log_activityafter meaningful changes, fixes, or decisions.Tag only facts that must remain prominent as
pinned.Use explicit workspace or global scope for destructive operations.
Tool reference
server-memory registers MCP tools only. It does not register resources or prompts.
Scope behavior
Scope | Behavior |
| Operates on the current workspace database and is the default for project memory |
| Operates on the global preference database |
| Combines supported workspace and global results with source labels |
Preference-tagged writes can automatically route to the global database when global preference routing is enabled.
Destructive operations require an explicitworkspace or global scope. They reject scope="all" to prevent accidental cross-database deletion, merging, or tag removal.
Tool | Purpose | Main inputs |
| Compact scoped recall for ordinary agent context |
|
| Larger bootstrap context with pinned and recent items |
|
| Add entities and optional initial observations |
|
| Add observations to existing entities |
|
| Connect existing entities |
|
| Read graph data, compressed by default |
|
| FTS5 search with filters |
|
| Open named entities and optional neighbors |
|
| Record a durable development or session event |
|
| Query activity history |
|
| List, create, delete, apply, remove, or clean tags |
|
| Merge one entity into another |
|
| Export graph as JSON or JSONL |
|
| Import JSON or JSONL graph data |
|
| Return counts and storage statistics |
|
| Copy a SQLite database |
|
| Show observation versions for an entity |
|
| Soft-delete or hard-delete entities |
|
| Delete selected observations |
|
| Delete relations |
|
Write tools modify the selected SQLite database. backup_memory writes a database backup. export_graph may expose sensitive memory content, so review exports before sharing them.
Configuration
Configuration is environment-driven. Empty path overrides in .env.example use platform defaults.
Storage and scope
Variable | Default | Meaning |
| Platform user-data directory, workspace-namespaced when detected | Workspace SQLite database |
| Empty | Default project scope |
|
| Enable the global preference database |
| Platform user-data directory | Global preference database |
|
| Route preference-tagged writes to global memory |
| Unset | Explicit workspace root for default database placement |
| Unset | Explicit workspace identifier for default database placement |
Retrieval and compression
Variable | Default | Meaning |
|
| Compression level from |
|
| Maximum approximate token budget for compressed graph output |
|
| Optional embedding model |
|
| Enable embedding search and backfill when dependencies are available |
|
| Write-path embedding time budget |
|
| Semantic deduplication threshold |
Runtime and shared daemon
Variable | Default | Meaning |
| Unset | Import JSONL on startup |
| Unset | Session identifier for activity logging |
|
| Require bearer authentication for the shared HTTP daemon |
| Platform runtime directory | Local HTTP daemon token file |
Evaluation
The repository includes deterministic retrieval scenarios for memory_context, including exact-name lookup, importance ranking, pinned facts, access recency, activity links, file-path hints, stale-fact demotion, lexical fallback, and duplicate suppression.
Those tests validate expected ranking behavior, but they do not establish real-world improvements in agent completion rate or token use.
A separate controlled protocol is provided in docs/BENCHMARK_PROTOCOL.md. It compares:
fresh sessions with no memory
fresh sessions with a token-matched manual handoff summary
fresh sessions using
server-memory
The protocol measures:
task completion rate
durable-fact recall and contradiction rate
total tokens and tokens to first correct action
repeated work
tool-call efficiency
hit@1, hit@3, and reciprocal rank
memory latency and end-to-end duration
stale-memory, leakage, duplicate, and incorrect-write failures
No performance numbers are claimed in this README yet. Verified results should include raw run records, exact model revisions, repository commits, configurations, task fixtures, evaluator rubrics, acceptance-test logs, and confidence intervals.
Local validation
Hosted GitHub Actions are not currently treated as an active validation source for this repository. Workflow definitions may remain under .github/workflows for future use, but this README does not claim that those jobs are running or passing.
Install development dependencies:
python -m pip install -e ".[dev]"Run the required local checks:
python -m compileall -q src tests scripts
python -m ruff check .
python -m pytest -qRun the full package and supply-chain checks before a release or substantial pull request:
rm -rf dist build
python -m build
python -m twine check dist/*
python scripts/inspect_wheel.py dist
python -m pip_audit
python scripts/smoke_stdio.py server-memory
server-memory-serve --help
server-memory-proxy --helpOn PowerShell, remove build artifacts with:
Remove-Item -Recurse -Force dist, build -ErrorAction SilentlyContinueThe stdio smoke test sends an MCP initialize request to the installed entry point and fails if stdout contains non-protocol output.
When reporting validation, include the exact commands, Python version, operating system, and full failure output. Do not describe a check as passing unless it was actually executed.
See CONTRIBUTING.md for contribution guidance and AGENTS.md for repository-specific agent instructions.
Security and privacy
Memory databases, exports, backups, and activity logs can contain sensitive user data.
The stdio server writes protocol data to stdout. Diagnostics should go to stderr or logs.
The shared HTTP daemon defaults to
127.0.0.1and local bearer-token authentication.The bearer token is generated locally and stored under a platform-native runtime directory unless
MEMORY_AUTH_TOKEN_PATHis set.No external service credentials are required for the core server.
Optional embeddings may load local or cached model files depending on the environment and installed extras.
Review exported graph content before sharing it.
Do not commit live memory databases, token files, or backups.
Report vulnerabilities through GitHub private vulnerability reporting when available. Do not include secrets or private memory exports in public issues.
See SECURITY.md for the project security policy.
Troubleshooting
Symptom | Check |
| Use a Python build linked against SQLite with FTS5 enabled. |
MCP client hangs at startup | Run |
Multiple clients lock the database | Run one |
Proxy returns an authentication failure | Restart the daemon and client so both read the same |
Memory is stored in an unexpected location | Set |
License
Licensed under the MIT License.
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/MK-986123/server-memory'
If you have feedback or need assistance with the MCP directory API, please join our Discord server