local-memory-mcp
A local MCP server that provides semantic memory storage and retrieval for coding and AI agents, enabling durable context across chat sessions.
README
Local Memory MCP Server for Coding/AI Agents
This project is a local MCP (Model Context Protocol) server that exposes a small set of tools:
memory.search– semantic search over stored memoriesmemory.save– store a new memorymemory.supersede– mark an old memory as supersededmemory.delete– permanently remove a memory by idmemory.ping– sanity check / version output
What you can do with this project
- Keep durable coding context across chat sessions (decisions, preferences, gotchas, API contracts).
- Retrieve relevant past context semantically (not only keyword matching).
- Scope memory per project using
WORKSPACE_KEYwhile keeping one shared local database. - Correct memory over time by superseding outdated entries or deleting irrelevant ones.
- Run everything locally (no external vector DB required).
Typical workflow
- User asks a question in chat.
- Agent calls
memory.searchto fetch relevant context. - Agent answers using retrieved memory + current codebase context.
- New durable insight is stored via
memory.save. - Old memory is updated via
memory.supersedeor removed viamemory.delete.
It uses:
- Bun + TypeScript
- Zvec (
@zvec/zvec) as embedded in-process vector database (docs: https://zvec.org/en/docs/) - Ollama
/api/embedwith embeddinggemma for embeddings (docs: https://docs.ollama.com/capabilities/embeddings, model: https://ollama.com/library/embeddinggemma)
Prerequisites
- Bun installed
- Ollama installed and running locally
Pull the embedding model:
ollama pull embeddinggemma
Install
bun install
Run
bun run start
This runs an MCP server over stdio.
Test
bun run test
Current tests include:
tests/embed.test.ts– validates Ollama embedding response parsing and error handlingtests/memory-db.test.ts– validatessave,search,supersede, anddeleteon the Zvec-backed store
Environment variables
MEMORY_DB_PATH(default./data/memory.zvec)OLLAMA_BASE_URL(defaulthttp://localhost:11434)OLLAMA_EMBED_MODEL(defaultembeddinggemma)EMBEDDING_DIM(default768, must match your embedding model)WORKSPACE_KEY(defaultdefault)
VS Code
Workspace setup
This repo includes .vscode/mcp.json that registers this server:
- command:
bun - args:
run start
You can adjust environment variables in that file.
Always-on across all projects
If you want this MCP server available in all workspaces, add it to your User MCP configuration instead of only .vscode/mcp.json:
- Open Command Palette:
MCP: Open User Configuration - Add a server entry that starts this repo from a fixed directory.
Example (Linux):
{
"servers": {
"local-memory-mcp": {
"type": "stdio",
"command": "bun",
"args": ["--cwd", "/path/to/local-memory-mcp", "run", "start"],
"env": {
"MEMORY_DB_PATH": "/path/to/local-memory-mcp/data/memory.zvec",
"OLLAMA_BASE_URL": "http://localhost:11434",
"OLLAMA_EMBED_MODEL": "embeddinggemma",
"EMBEDDING_DIM": "768",
"WORKSPACE_KEY": "${workspaceFolderBasename}"
}
}
}
}
Notes:
- Use an absolute
MEMORY_DB_PATHso all projects use the same database. WORKSPACE_KEY=${workspaceFolderBasename}keeps memories separated per project automatically.- Enable VS Code setting
chat.mcp.autoStart(Experimental) to auto-start/restart MCP servers when needed.
Docs:
- https://code.visualstudio.com/docs/copilot/customization/mcp-servers
Claude Code
Add this server to Claude Code as a local stdio MCP server.
This repository already includes:
.mcp.jsonfor project-scoped Claude MCP configurationCLAUDE.mdfor memory-first agent behavior guidelines
User scope (all projects)
claude mcp add --transport stdio --scope user \
--env MEMORY_DB_PATH=/absolute/path/to/local-memory-mcp/data/memory.zvec \
--env OLLAMA_BASE_URL=http://localhost:11434 \
--env OLLAMA_EMBED_MODEL=embeddinggemma \
--env EMBEDDING_DIM=768 \
--env WORKSPACE_KEY=default \
local-memory-mcp -- bun --cwd /absolute/path/to/local-memory-mcp run start
Project scope (shared in repository)
claude mcp add --transport stdio --scope project \
--env MEMORY_DB_PATH=./data/memory.zvec \
--env OLLAMA_BASE_URL=http://localhost:11434 \
--env OLLAMA_EMBED_MODEL=embeddinggemma \
--env EMBEDDING_DIM=768 \
--env WORKSPACE_KEY=${PWD##*/} \
local-memory-mcp -- bun run start
Project .mcp.json example:
{
"mcpServers": {
"local-memory-mcp": {
"type": "stdio",
"command": "bun",
"args": ["run", "start"],
"env": {
"MEMORY_DB_PATH": "./data/memory.zvec",
"OLLAMA_BASE_URL": "http://localhost:11434",
"OLLAMA_EMBED_MODEL": "embeddinggemma",
"EMBEDDING_DIM": "768",
"WORKSPACE_KEY": "${PWD##*/}"
}
}
}
}
Notes:
--scope projectwrites to.mcp.jsonin the project root.--scope userstores the server in your user Claude configuration.- Keep all Claude flags before the server name, and put
--before the server command.
Useful commands:
claude mcp list
claude mcp get local-memory-mcp
claude mcp remove local-memory-mcp
Docs:
- https://code.claude.com/docs/en/mcp
Tool usage (examples)
Search
{
"tool": "memory.search",
"arguments": {
"query": "What is our policy for multi-session memory?",
"topK": 8,
"workspaceKey": "my-repo"
}
}
Save
{
"tool": "memory.save",
"arguments": {
"workspaceKey": "my-repo",
"type": "decision",
"summary": "We use zvec with Ollama embeddinggemma for long-term memory.",
"text": "Decision: The Copilot/agent memory sidecar stores vectors in zvec and generates embeddings via Ollama /api/embed using embeddinggemma.",
"tags": ["memory", "zvec", "ollama", "embeddinggemma"],
"importance": 0.8
}
}
Delete
{
"tool": "memory.delete",
"arguments": {
"workspaceKey": "my-repo",
"id": 42
}
}
Implementation notes
- The DB uses one Zvec collection with:
- dense vector field
embedding - scalar fields for metadata (
workspaceKey,type,summary, etc.)
- dense vector field
- KNN queries are executed through Zvec
querySyncwith metadata filters.
Tests
Run all tests:
bun run test
Current test coverage:
tests/embed.test.ts- parses successful Ollama
/api/embedresponses intoFloat32Array - verifies error handling when Ollama returns non-2xx responses
- parses successful Ollama
tests/memory-db.test.ts- validates
save+searchbehavior with workspace/type filtering - validates
supersedebehavior (superseded items are excluded from search) - validates
deletebehavior and returned payload semantics
- validates
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。