GEO
赞助商内容

Memora如何为AI代理提供持久记忆和跨会话管理?

2026/4/20
Memora如何为AI代理提供持久记忆和跨会话管理?

AI Summary (BLUF)

Memora is a lightweight MCP server that provides AI agents with persistent memory storage, knowledge graph visualization, semantic search, and cross-session context management through SQLite, cloud sync, and vector embeddings.

原文翻译: Memora是一个轻量级MCP服务器,通过SQLite、云同步和向量嵌入技术,为AI代理提供持久记忆存储、知识图谱可视化、语义搜索和跨会话上下文管理。

"You never truly know the value of a moment until it becomes a memory."

“直到某个瞬间成为记忆,你才真正明白它的价值。”

为你的 AI 代理赋予持久记忆
一个轻量级的 MCP 服务器,用于语义记忆存储、知识图谱构建、对话回忆和跨会话上下文管理。

Give your AI agents persistent memory
A lightweight MCP server for semantic memory storage, knowledge graphs, conversational recall, and cross-session context.

Version
License
Mentioned in Awesome Claude Code

Memora Demo
Memora Demo

功能 · 安装 · 使用 · 配置 · 实时图谱服务器 · 云图谱 · 与记忆对话 · 语义搜索 · 文档存储 · LLM 去重 · 记忆链接 · Neovim 集成

Features · Install · Usage · Configuration · Live Graph Server · Cloud Graph · Chat with Memories · Semantic Search · Document Storage · LLM Deduplication · Memory Linking · Neovim Integration

功能

Features

核心存储

Core Storage

  • 💾 持久化存储 - 基于 SQLite,支持可选的云同步 (S3, R2, D1)
    • 💾 Persistent Storage - SQLite with optional cloud sync (S3, R2, D1)
  • 📂 层级化组织 - 章节/小节结构,支持自动层级分配
    • 📂 Hierarchical Organization - Section/subsection structure with auto-hierarchy assignment
  • 📦 导入/导出 - 支持备份、恢复及合并策略
    • 📦 Export/Import - Backup and restore with merge strategies

搜索与智能

Search & Intelligence

  • 🔍 语义搜索 - 向量嵌入 (TF-IDF, sentence-transformers, OpenAI)
    • 🔍 Semantic Search - Vector embeddings (TF-IDF, sentence-transformers, OpenAI)
  • 🎯 高级查询 - 全文、日期范围、标签筛选 (AND/OR/NOT)、混合搜索
    • 🎯 Advanced Queries - Full-text, date ranges, tag filters (AND/OR/NOT), hybrid search
  • 🔀 交叉引用 - 基于相似度自动链接相关记忆
    • 🔀 Cross-references - Auto-linked related memories based on similarity
  • 🤖 LLM 去重 - 利用 AI 驱动的比较来查找和合并重复项
    • 🤖 LLM Deduplication - Find and merge duplicates with AI-powered comparison
  • 🔗 记忆链接 - 类型化边、重要性提升和集群检测
    • 🔗 Memory Linking - Typed edges, importance boosting, and cluster detection

文档存储

Document Storage

  • 📄 结构化文档 - 将 Markdown 文档存储为可搜索的片段树 (声明、计划项、引用、风险)
    • 📄 Structured Documents - Store markdown documents as searchable fragment trees (claims, plan items, references, risks)
  • 🔒 片段完整性 - 防止文档片段被意外删除/合并/吸收
    • 🔒 Fragment Integrity - Guards against accidental delete/merge/absorb of document fragments
  • 🔍 细粒度搜索 - 单个声明和发现可进行语义搜索,同时完整文档仍可作为整体检索
    • 🔍 Granular Search - Individual claims and findings are semantically searchable while the full document remains retrievable as a unit

工具与可视化

Tools & Visualization

  • ⚡ 记忆自动化 - 用于待办事项、问题和章节的结构化工具
    • ⚡ Memory Automation - Structured tools for TODOs, issues, and sections
  • 🕸️ 知识图谱 - 交互式可视化,支持 Mermaid 渲染和集群叠加
    • 🕸️ Knowledge Graph - Interactive visualization with Mermaid rendering and cluster overlays
  • 🌐 实时图谱服务器 - 内置 HTTP 服务器,支持云托管选项 (D1/Pages)
    • 🌐 Live Graph Server - Built-in HTTP server with cloud-hosted option (D1/Pages)
  • 💬 与记忆对话 - 基于 RAG 的聊天面板,支持 LLM 工具调用,通过流式聊天进行搜索、创建、更新和删除记忆
    • 💬 Chat with Memories - RAG-powered chat panel with LLM tool calling to search, create, update, and delete memories via streaming chat
  • 📡 事件通知 - 基于轮询的代理间通信系统
    • 📡 Event Notifications - Poll-based system for inter-agent communication
  • 📊 统计与分析 - 标签使用情况、趋势和连接洞察
    • 📊 Statistics & Analytics - Tag usage, trends, and connection insights
  • 🧠 记忆洞察 - 活动摘要、陈旧检测、整合建议和 LLM 驱动的模式分析
    • 🧠 Memory Insights - Activity summary, stale detection, consolidation suggestions, and LLM-powered pattern analysis
  • 📜 操作历史 - 跟踪所有记忆操作 (创建、更新、删除、合并、提升、链接),并提供分组时间线视图
    • 📜 Action History - Track all memory operations (create, update, delete, merge, boost, link) with grouped timeline view

安装

Install

pip install git+https://github.com/agentic-box/memora.git

默认包含云存储 (S3/R2) 和 OpenAI 向量嵌入支持。

Includes cloud storage (S3/R2) and OpenAI embeddings out of the box.

# 可选:本地向量嵌入 (离线,PyTorch 约 2GB)
pip install "memora[local]" @ git+https://github.com/agentic-box/memora.git
# Optional: local embeddings (offline, ~2GB for PyTorch)
pip install "memora[local]" @ git+https://github.com/agentic-box/memora.git

使用

Usage

使用详情
Usage Details

服务器在 Claude Code 中配置后会自动运行。手动调用方式如下:

The server runs automatically when configured in Claude Code. Manual invocation:

# 默认 (MCP 的 stdio 模式)
memora-server

# 启用图谱可视化服务器
memora-server --graph-port 8765

# HTTP 传输 (stdio 的替代方案)
memora-server --transport streamable-http --host 127.0.0.1 --port 8080
# Default (stdio mode for MCP)
memora-server

# With graph visualization server
memora-server --graph-port 8765

# HTTP transport (alternative to stdio)
memora-server --transport streamable-http --host 127.0.0.1 --port 8080

配置

Configuration

配置详情
Configuration Details

Claude Code

Claude Code

添加到项目根目录的 .mcp.json 文件中:

Add to .mcp.json in your project root:

本地数据库:

Local DB:

{
  "mcpServers": {
    "memora": {
      "command": "memora-server",
      "args": [],
      "env": {
        "MEMORA_DB_PATH": "~/.local/share/memora/memories.db",
        "MEMORA_ALLOW_ANY_TAG": "1",
        "MEMORA_GRAPH_PORT": "8765"
      }
    }
  }
}

云数据库 (Cloudflare D1) - 推荐:

Cloud DB (Cloudflare D1) - Recommended:

{
  "mcpServers": {
    "memora": {
      "command": "memora-server",
      "args": ["--no-graph"],
      "env": {
        "MEMORA_STORAGE_URI": "d1://<account-id>/<database-id>",
        "CLOUDFLARE_API_TOKEN": "<your-api-token>",
        "MEMORA_ALLOW_ANY_TAG": "1"
      }
    }
  }
}

使用 D1 时,请使用 --no-graph 禁用本地可视化服务器。转而使用 Cloudflare Pages URL 上托管的图谱 (参见 云图谱)。

With D1, use --no-graph to disable the local visualization server. Instead, use the hosted graph at your Cloudflare Pages URL (see Cloud Graph).

云数据库 (S3/R2) - 同步模式:

Cloud DB (S3/R2) - Sync mode:

{
  "mcpServers": {
    "memora": {
      "command": "memora-server",
      "args": [],
      "env": {
        "AWS_PROFILE": "memora",
        "AWS_ENDPOINT_URL": "https://<account-id>.r2.cloudflarestorage.com",
        "MEMORA_STORAGE_URI": "s3://memories/memories.db",
        "MEMORA_CLOUD_ENCRYPT": "true",
        "MEMORA_ALLOW_ANY_TAG": "1",
        "MEMORA_GRAPH_PORT": "8765"
      }
    }
  }
}

Codex CLI

Codex CLI

添加到 ~/.codex/config.toml

Add to ~/.codex/config.toml:

[mcp_servers.memora]
  command = "memora-server"  # 或完整路径: /path/to/bin/memora-server
  args = ["--no-graph"]
  env = {
    AWS_PROFILE = "memora",
    AWS_ENDPOINT_URL = "https://<account-id>.r2.cloudflarestorage.com",
    MEMORA_STORAGE_URI = "s3://memories/memories.db",
    MEMORA_CLOUD_ENCRYPT = "true",
    MEMORA_ALLOW_ANY_TAG = "1",
  }
[mcp_servers.memora]
  command = "memora-server"  # or full path: /path/to/bin/memora-server
  args = ["--no-graph"]
  env = {
    AWS_PROFILE = "memora",
    AWS_ENDPOINT_URL = "https://<account-id>.r2.cloudflarestorage.com",
    MEMORA_STORAGE_URI = "s3://memories/memories.db",
    MEMORA_CLOUD_ENCRYPT = "true",
    MEMORA_ALLOW_ANY_TAG = "1",
  }

环境变量

Environment Variables

环境变量详情
Environment Variables Details
变量 描述
MEMORA_DB_PATH 本地 SQLite 数据库路径 (默认: ~/.local/share/memora/memories.db)
MEMORA_STORAGE_URI 存储 URI: d1://<account>/<db-id> (D1) 或 s3://bucket/memories.db (S3/R2)
CLOUDFLARE_API_TOKEN 用于访问 D1 数据库的 API 令牌 (使用 d1:// URI 时必需)
MEMORA_CLOUD_ENCRYPT 上传到云端前加密数据库 (true/false)
MEMORA_CLOUD_COMPRESS 上传到云端前压缩数据库 (true/false)
MEMORA_CACHE_DIR 云同步数据库的本地缓存目录
MEMORA_ALLOW_ANY_TAG 允许任何标签,无需验证白名单 (设为 1 启用)
MEMORA_TAG_FILE 包含允许标签的文件路径 (每行一个)
MEMORA_TAGS 逗号分隔的允许标签列表
MEMORA_GRAPH_PORT 知识图谱可视化服务器的端口 (默认: 8765)
MEMORA_EMBEDDING_MODEL 向量嵌入后端: openai (默认), sentence-transformers, 或 tfidf
SENTENCE_TRANSFORMERS_MODEL sentence-transformers 使用的模型 (默认: all-MiniLM-L6-v2)
OPENAI_API_KEY 用于 OpenAI 向量嵌入和 LLM 去重的 API 密钥
OPENAI_BASE_URL OpenAI 兼容 API 的基础 URL (OpenRouter, Azure 等)
OPENAI_EMBEDDING_MODEL OpenAI 向量嵌入模型 (默认: text-embedding-3-small)
MEMORA_LLM_ENABLED 启用 LLM 驱动的去重比较 (true/false, 默认: true)
MEMORA_LLM_MODEL 用于去重比较的模型 (默认: gpt-4o-mini)
CHAT_MODEL 聊天面板使用的模型 (默认: deepseek/deepseek-chat, 回退到 MEMORA_LLM_MODEL)
AWS_PROFILE 来自 ~/.aws/credentials 的 AWS 凭证配置文件 (对 R2 有用)
AWS_ENDPOINT_URL 用于 R2/MinIO 的 S3 兼容端点
R2_PUBLIC_DOMAIN R2 图片 URL 的公共域名
Variable Description
MEMORA_DB_PATH Local SQLite database path (default: ~/.local/share/memora/memories.db)
MEMORA_STORAGE_URI Storage URI: d1://<account>/<db-id> (D1) or s3://bucket/memories.db (S3/R2)
CLOUDFLARE_API_TOKEN API token for D1 database access (required for d1:// URI)
MEMORA_CLOUD_ENCRYPT

常见问题(FAQ)

Memora如何帮助AI代理实现跨会话的记忆管理?

Memora通过SQLite提供持久化存储,并支持云同步(如S3、R2),确保AI代理在不同会话间能访问和维持连贯的上下文与记忆。

Memora的知识图谱可视化功能具体能做什么?

它提供交互式知识图谱可视化,支持Mermaid渲染和集群叠加,并内置实时图谱服务器,方便用户直观查看和管理记忆间的关联。

Memora的语义搜索基于什么技术?效果如何?

基于向量嵌入技术(如TF-IDF、sentence-transformers),结合高级查询(全文、日期、标签筛选),实现精准的语义搜索和记忆交叉引用。

← 返回文章列表
分享到:微博

版权与免责声明:本文仅用于信息分享与交流,不构成任何形式的法律、投资、医疗或其他专业建议,也不构成对任何结果的承诺或保证。

文中提及的商标、品牌、Logo、产品名称及相关图片/素材,其权利归各自合法权利人所有。本站内容可能基于公开资料整理,亦可能使用 AI 辅助生成或润色;我们尽力确保准确与合规,但不保证完整性、时效性与适用性,请读者自行甄别并以官方信息为准。

若本文内容或素材涉嫌侵权、隐私不当或存在错误,请相关权利人/当事人联系本站,我们将及时核实并采取删除、修正或下架等处理措施。 也请勿在评论或联系信息中提交身份证号、手机号、住址等个人敏感信息。

您可能感兴趣