Skip to main content

Semantic Memory MCP

Persistent, semantic memory for AI coding agents — a single Python file, entirely local.

semantic-memory-mcp is a self-hosted Model Context Protocol server that gives AI coding agents a durable, searchable memory across sessions. It is built as one Python file, stores everything in a single local SQLite database, and needs no cloud service and no API key.

What it is

  • Cross-session memory: notes survive between sessions; the agent searches its own memory at the start of every task instead of relying on the user to re-explain context.
  • Hybrid retrieval: keyword full-text search (SQLite FTS5) and semantic vector search (sqlite-vec) are combined through Reciprocal Rank Fusion — a note can be found by exact wording or by meaning.
  • Multilingual embeddings: quantized ONNX model (Xenova/multilingual-e5-small, ~113 MB) runs locally on CPU. English and German work equally well; no OpenAI key required.
  • Trivially auditable: the whole server is a single readable file (memory_server.py, ~1,100 lines). There is no hidden state beyond the SQLite file.

Tools

Tool Purpose
memory_store Save a note (with tags and source)
memory_search Hybrid search (semantic + full-text), optional token budget
memory_get / memory_recent Read one note by ID / list recent notes
memory_update / memory_delete Edit or remove a note
memory_status Database statistics
memory_zotero_sync Optional: back up memory content into a Zotero library

Why

AI coding agents forget everything between sessions. File-based memory (markdown indexes that get reloaded) is keyword-based: it has no semantic recall and no ranking — a note saved as "embedding model comparison" will not be found when the agent later asks "which embedding did we test?".

This server was built as a working reference implementation and measured, not assumed — see Evaluation.

Evaluation

Retrieval quality was tracked throughout development. Recall@5 — the share of queries where the correct note is among the top 5 hits — rose from 68.4 % to 95.2 % across successive, individually measured optimization steps (chunking, embedding model choice, query rewriting, note consolidation, keyline anchors, and more) over 181 measured queries in five baskets. The full measurement series with a 26-work comparison table is documented here:

The Memory Server in the Lab

Working across parallel sessions

You can run several agent sessions at the same time — they all share one memory. Instead of a single "where did I stop?" slot that parallel sessions would overwrite, each session ends its work with a short checkpoint note in the memory (topic, what was done, what is open, next step), with the writing agent and model recorded in the source field. Asking any window "Where did we stop on X?" then finds the answer — even if the work happened in a different window. The convention is part of the agent rules (memory-mcp-knowledge.md, R17).

Budget hygiene for file-based auto-memory

Many setups run a file-based "auto-memory" next to this server — always-on index files (such as MEMORY.md) with a hard size limit, past which entries are silently dropped, usually the newest ones. The countermeasures that proved themselves in continuous operation (target ~10 % below the limit, measured at every session; information-loss-free shortening first; router lines instead of full indexes; an LLM-free watchdog cron) are codified as rule R18 in memory-mcp-knowledge.md, with the full write-up on the project page.

Installation

Prerequisites: Linux, Python 3.11+ with venv, ~500 MB free disk space (virtual environment plus embedding model). The server is written for Linux, but not limited to it: since everything is one Python file, any AI assistant can read the script and adapt the installation for Windows or macOS.

git clone https://github.com/Michael-Logies/semantic-memory-mcp.git
cd semantic-memory-mcp
bash setup.sh      # creates the venv, installs dependencies, downloads the model
bash verify.sh     # checks the installation, writes a report

The embedding model is downloaded automatically from Hugging Face (huggingface_hub, no account needed).

Alternative: pip install — no clone needed; the package ships a semantic-memory-mcp command, and the embedding model (~113 MB) downloads automatically on first start:

python3 -m venv ~/.venv-memory
~/.venv-memory/bin/pip install semantic-memory-mcp    # from PyPI
# or directly from this repository:
# ~/.venv-memory/bin/pip install git+https://github.com/Michael-Logies/semantic-memory-mcp.git

Then register the server in your AI agent's MCP configuration (example for Qwen Code, ~/.qwen/settings.json):

{
  "mcpServers": {
    "memory": {
      "command": "/home/<user>/.venv-memory/bin/python3",
      "args": ["/path/to/semantic-memory-mcp/memory_server.py"],
      "transport": "stdio"
    }
  }
}

If your client has an mcp add command, registration is a one-liner once the venv exists (with the pip installation, use the packaged ~/.venv-memory/bin/semantic-memory-mcp as the single command instead of python3 …/memory_server.py):

# Qwen Code (note: no `--` separator)
qwen mcp add memory ~/.venv-memory/bin/python3 /path/to/semantic-memory-mcp/memory_server.py

# Claude Code
claude mcp add memory -- ~/.venv-memory/bin/python3 /path/to/semantic-memory-mcp/memory_server.py

# Codex CLI
codex mcp add memory -- ~/.venv-memory/bin/python3 /path/to/semantic-memory-mcp/memory_server.py

The Qwen Code and Claude Code commands were verified against the locally installed CLIs. The Codex line was not tested by us — its syntax was adopted from the documentation of other projects, since we only use Qwen Code ourselves.

See mcp-config.json for a template. usage-notes.md contains practical guidance for working with an agent that has persistent memory (context management, what to store, tagging, parallel sessions); the German version ships as nutzungshinweise.md.

Documentation for your AI agent

Two documents ship with this repository, written for the agent rather than the human (both CC0-licensed):

  • memory-mcp-knowledge.md — the rules and learning protocol for operating the memory server in daily agent work: when to read, when to write, what to store, and how to tag it.
  • zotero-mcp-agent-knowledge.md — hard-won knowledge about connecting Zotero with AI agents via MCP servers: tool comparison (zotero-mcp-server, Zoteus, pyzotero, CLI access), benchmarks, and best practices. Since 31 August 2026, Zoteus is the sole Zotero MCP server in the reference setup; the older ChromaDB-based material is kept as background, not as a recommendation.

The bigger picture

This server is the memory layer of a reproducible AI workstation for students — a complete setup guide (research, learning, literature work on a Linux machine) documented step by step here:

Memory comes in two layers in that setup: this server stores the working memory of day-to-day collaboration with the agent, while scholarly literature lives in a Zotero research database made searchable by meaning through a second MCP server (Zoteus). How the two fit together is described on the project pages:

Status and maintenance

The server has been in daily production use since August 2026 as the memory of a working AI workstation. It is developed and maintained by Michael Logies in close collaboration with AI coding agents — see the project pages above for how it was built and evaluated. The server is provided as-is: bug reports are welcome and handled on a best-effort basis, but there is no formal support.

License

MIT — see LICENSE.

Metadata

Release files for semantic-memory-mcp 1.0.7

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for semantic-memory-mcp 1.0.7
File Size Uploaded Provenance Actions
semantic_memory_mcp-1.0.7.tar.gz 23.0 kB Without provenance Details for semantic_memory_mcp-1.0.7.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for semantic-memory-mcp 1.0.7
File Interpreter ABI Platform Actions
semantic_memory_mcp-1.0.7-py3-none-any.whl Python 3 none any Details for semantic_memory_mcp-1.0.7-py3-none-any.whl

Total release size: 42.7 kB

Release files / semantic_memory_mcp-1.0.7.tar.gz

Download URL semantic_memory_mcp-1.0.7.tar.gz
Size 23.0 kB
Tags Source
SHA-256 checksum
How to use checksums
572eea9654923338d28ac181fd824001d9d23ccf707be2e02e8d07cb2fcb1cba
BLAKE2b-256 checksum
How to use checksums
c624163c620a3092c553fa45107461f8ee9331431be444e7c3723dbb6bc0665f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

Release files / semantic_memory_mcp-1.0.7-py3-none-any.whl

Download URL semantic_memory_mcp-1.0.7-py3-none-any.whl
Size 19.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ae82f7885cf6ca7e5cee4fcc8627d459919d0f8b83274c60ea9343977490618c
BLAKE2b-256 checksum
How to use checksums
07b2cb9aedd1bcc16240dc5099a6c4444f61ad8201298b4592cb321a50e84e98
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

Security for semantic-memory-mcp 1.0.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page