Skip to main content
Glama
jommar
by jommar

memory-mcp

memory-mcp 是一个独立的 MCP 服务器,用于持久化智能体记忆 —— 短期/长期记忆分层、可度量的可靠性以及生命周期维护 —— 以 SQLite(FTS5 + sqlite-vec)为后端,并使用本地 MiniLM 嵌入。无需外部服务,无需 API 密钥。

环境要求

  • Node.js >= 22

  • 该包随附编译后的 JavaScript,因此运行时无需 TypeScript 工具链。

Related MCP server: localmem-mcp

安装

npm install @jommar/memory-mcp

提供两个可执行文件:

命令

用途

memory-mcp-server

MCP 服务器(默认为 stdio,通过 MEMORY_TRANSPORT 使用 HTTP)

memory-mcp

存储维护 CLI(export、import、reindex、stats)

快速开始

stdio(默认)

将 MCP 客户端指向服务器可执行文件:

{
  "mcpServers": {
    "memory": {
      "command": "memory-mcp-server"
    }
  }
}

或直接运行:

memory-mcp-server

使用 npx 时,请显式指定服务器可执行文件(首次使用时会先安装该包):

npx -y -p @jommar/memory-mcp memory-mcp-server

HTTP(仅限 localhost)

MEMORY_TRANSPORT=http memory-mcp-server

HTTP 端点默认绑定到 127.0.0.1:3000,并在同一端点同时提供新版(2026-07-28)和旧版(2025-11-25)协议修订版的协议,因此任何 MCP 客户端都能连接。服务器无状态——无需会话 ID。

首次运行

存储会在 ~/.memory-mcp/memory.db 自动创建。数据库中的嵌入是离线优先的:除非你主动选择,否则不会下载任何模型。

# opt in to the one-time model download (about 23 MB, MiniLM-L6, q8 quantized)
MEMORY_EMBEDDING_OFFLINE=false memory-mcp-server

在模型可用之前,remember 和 recall 仍然可以工作——它们只会退化为关键词搜索。模型就绪后,可使用CLI reindex 回填向量。

配置

所有配置均通过 MEMORY_* 环境变量完成(无配置文件):

变量

默认值

用途

MEMORY_DB_PATH

~/.memory-mcp/memory.db

SQLite 数据库文件

MEMORY_TRANSPORT

stdio

stdio 或 http

MEMORY_HTTP_HOST

127.0.0.1

HTTP绑定主机(仅限 localhost)

MEMORY_HTTP_PORT

3000

HTTP绑定端口

MEMORY_EMBEDDING_OFfLINE

true

设为 false 时一次性下载模型的模型,同时选择下载模型

MEMORY_EMBEDDING_DOWNLOAD_TIMEOUT_MS

300000

模型下载尝试的超时时间

MEMORY_EMBEDDING_CACHE_DIR

~/.memory-mcp/cache

已下载模型的缓存位置

工具

共注册了十个工具:remember、recall、get、update、forget、list、confirm、contradict、promote、consolidate。 有关输入和行为的完整参考,请参阅 docs/tools.md。

remember 支持 interactive 选择:当发现近似重复的条目时,它可以让客户端选择合并或创建(MRTR),并在客户端不支持交互式功能时优雅降级。

维护CLI

memory-mcp export ./out      # write every memory as a markdown frontmatter file
memory-mcp import ./staging  # validate, then import (never overwrites existing keys)
memory-mcp reindex           # rebuild FTS + vector indexes from stored content
memory-mcp stats             # print store counts

文档文档

许可协议

MIT — 请参阅 LICENSE。

Maintenance

ActivityStale
ResponsivenessNo issues

Related MCP Connectors

Related MCP Servers

  • A
    license
    Not graded
    quality
    D
    maintenance
    Provides persistent long-term memory for LLMs via local SQLite storage and semantic search, enabling recall across sessions without external APIs.
    18 npm
    5
    MIT
  • A
    license
    A
    quality
    A
    maintenance
    Gives AI agents persistent, local-first memory using SQLite and on-device embeddings, enabling semantic search and recall across sessions with no cloud calls.
    8
    20 PyPI
    9
    MIT
  • A
    license
    Not graded
    quality
    B
    maintenance
    Enables AI agents to store, search, and manage persistent memories, todos, kanban boards, reminders, and progress trackers in a local SQLite database.
    1
    Apache 2.0
  • A
    license
    Not graded
    quality
    B
    maintenance
    Enables AI agents to manage a local-first, zero-cloud lifelong memory with 33 tools for adding, recalling, searching, consolidating, forgetting memories, traversing knowledge graphs, and checking sync/health status.
    Apache 2.0