返回顶部
c

cortex-mem-mcp持久记忆增强

Persistent memory enhancement for AI agents. Store conversations, search memories with semantic retrieval, and recall context across sessions. Use this skill when you need to remember user preferences, past conversations, project context, or any information that should persist beyond the current session. Provides tiered access (abstract/overview/content) for efficient context management.

作者: admin | 来源: ClawHub
源自
ClawHub
版本
V 2.7.0
安全检测
已通过
95
下载量
免费
免费
0
收藏
概述
安装方式
版本历史

cortex-mem-mcp

Cortex Memory MCP 技能

本技能为AI代理提供持久化记忆能力,使其能够跨会话存储、搜索和召回信息,并支持语义检索。

前置条件检查

在配置此技能前,请确认系统中是否已安装 cortex-mem-mcp:

bash

检查 cortex-mem-mcp 是否在 PATH 中


which cortex-mem-mcp || where cortex-mem-mcp # Linux/macOS || Windows

如果命令返回路径,说明二进制文件已安装。若未安装,请继续查看下方安装章节。

安装

方式一:从 crates.io 安装(推荐)

bash
cargo install cortex-mem-mcp

安装完成后,验证安装:

bash
cortex-mem-mcp --version

方式二:从源码构建

bash

克隆仓库


git clone https://github.com/sopaco/cortex-mem.git
cd cortex-mem

构建发布版二进制文件

cargo build --release --bin cortex-mem-mcp

二进制文件位于:

./target/release/cortex-mem-mcp (Linux/macOS)

.\target\release\cortex-mem-mcp.exe (Windows)

方式三:下载预构建二进制文件

从 GitHub 下载最新版本:

  • - GitHub 发布页:https://github.com/sopaco/cortex-mem/releases

选择适合您平台的二进制文件:

  • - cortex-mem-mcp-linux-x8664(Linux x64)
  • cortex-mem-mcp-darwin-arm64(macOS Apple Silicon)
  • cortex-mem-mcp-darwin-x8664(macOS Intel)
  • cortex-mem-mcp-windows-x86_64.exe(Windows x64)

配置

步骤一:创建配置文件

创建 config.toml 文件(例如 ~/.config/cortex-mem/config.toml):

toml
[cortex]

存储记忆的数据目录


data_dir = ~/.cortex-data

[llm]

LLM API 配置


apibaseurl = https://api.openai.com/v1
api_key = your-api-key
model_efficient = gpt-4o-mini
temperature = 0.1
max_tokens = 65536

[embedding]

嵌入配置


apibaseurl = https://api.openai.com/v1
api_key = your-embedding-api-key
model_name = text-embedding-3-small
batch_size = 10
timeout_secs = 30

[qdrant]

向量数据库配置


url = http://localhost:6333
collectionname = cortexmemories
embedding_dim = 1536
timeout_secs = 30

步骤二:启动 Qdrant(向量数据库)

bash

使用 Docker


docker run -d -p 6333:6333 qdrant/qdrant

验证 Qdrant 是否运行

curl http://localhost:6333

步骤三:配置 MCP 客户端

配置您的 MCP 客户端(例如 Claude Desktop、Cursor 等)以使用 cortex-mem-mcp。

Claude Desktop

编辑配置文件:

  • - macOS:~/Library/Application Support/Claude/claudedesktopconfig.json
  • Windows:%APPDATA%\Claude\claudedesktopconfig.json
  • Linux:~/.config/Claude/claudedesktopconfig.json

添加以下配置:

json
{
mcpServers: {
cortex-memory: {
command: cortex-mem-mcp,
args: [
--config, /path/to/config.toml,
--tenant, default
],
env: {
RUST_LOG: info
}
}
}
}

如果从源码构建,请使用二进制文件的完整路径:

json
{
mcpServers: {
cortex-memory: {
command: /path/to/cortex-mem/target/release/cortex-mem-mcp,
args: [
--config, /path/to/config.toml,
--tenant, default
]
}
}
}

Cursor IDE

添加到您的 Cursor MCP 设置中:

json
{
mcpServers: {
cortex-memory: {
command: cortex-mem-mcp,
args: [--config, /path/to/config.toml]
}
}
}

步骤四:重启 MCP 客户端

配置完成后,重启 Claude Desktop 或您的 MCP 客户端以加载新服务器。

步骤五:验证安装

手动测试 MCP 服务器:

bash

使用调试日志运行


RUST_LOG=debug cortex-mem-mcp --config /path/to/config.toml --tenant default

命令行参数

参数默认值描述
--config / -cconfig.toml配置文件路径
--tenant
default | 用于记忆隔离的租户 ID | | --auto-trigger-threshold | 10 | 自动触发记忆提取的消息数量阈值 | | --auto-trigger-interval | 300 | 自动触发执行之间的最小秒数 | | --auto-trigger-inactivity | 120 | 触发提取的非活动超时时间 | | --no-auto-trigger | false | 完全禁用自动触发功能 |

环境变量

变量描述
CORTEXDATADIR覆盖数据目录路径
RUST_LOG
日志级别(debug、info、warn、error) |

何时使用此技能

在以下场景中使用此技能:

  • - 记住用户偏好 - 存储和召回用户特定的设置、偏好和上下文
  • 持久化对话上下文 - 保留过去对话中的重要信息以便访问
  • 构建项目知识 - 随时间积累和检索项目特定信息
  • 追踪用户与代理的交互 - 维护交互历史以实现更好的个性化
  • 语义搜索记忆 - 使用自然语言查询查找相关信息

可用工具

存储工具

store

将消息添加到特定会话的记忆中。

json
{
content: 用户在所有应用中偏好深色模式,
thread_id: project-alpha,
role: user
}

  • - content:要存储的消息内容
  • thread_id:可选的会话/线程标识符(默认为 default)
  • role:消息角色 - user、assistant 或 system

commit

提交累积的对话内容并触发记忆提取。

json
{
thread_id: project-alpha
}

这将触发:

  • - 记忆提取(会话 → 用户/代理记忆)
  • L0/L1 层生成
  • 向量索引

搜索工具

search

使用 L0/L1/L2 分层检索进行分层语义搜索。

json
{
query: 用户对 UI 的偏好,
scope: project-alpha,
limit: 10,
min_score: 0.5,
return_layers: [L0, L1]
}

recall

召回带有完整上下文的记忆(L0 片段 + L2 内容)。

json
{
query: 我们讨论了关于认证的什么内容,
scope: project-alpha,
limit: 5
}

导航工具

ls

列出目录内容以浏览记忆空间。

json
{
uri: cortex://session,
recursive: true,
include_abstracts: true
}

常用 URI:

  • - cortex://session - 列出所有会话
  • cortex://user - 列出用户级记忆
  • cortex://user/preferences - 用户偏好记忆

explore

智能探索记忆空间,结合搜索和浏览功能。

json
{
query: 认证实现细节,
start_uri: cortex://session,
return_layers: [L0]
}

分层访问工具

记忆按层级组织以实现高效的上下文管理:

层级大小用途
L0~100 tokens快速相关性检查(摘要)
L1
~2000 tokens | 理解核心信息(概览) |
| L2 | 完整内容 | 完整的原始内容 |

abstract

获取 L0 摘要层以进行快速相关性检查。

json
{
uri: cortex://session/project-alpha/conversation.md
}

overview

获取

标签

skill ai

通过对话安装

该技能支持在以下平台通过对话安装:

OpenClaw WorkBuddy QClaw Kimi Claude

方式一:安装 SkillHub 和技能

帮我安装 SkillHub 和 cortex-mem-mcp-1775916011 技能

方式二:设置 SkillHub 为优先技能安装源

设置 SkillHub 为我的优先技能安装源,然后帮我安装 cortex-mem-mcp-1775916011 技能

通过命令行安装

skillhub install cortex-mem-mcp-1775916011

下载

⬇ 下载 cortex-mem-mcp v2.7.0(免费)

文件大小: 4.52 KB | 发布时间: 2026-4-12 09:36

v2.7.0 最新 2026-4-12 09:36
- Added detailed documentation in SKILL.md covering usage, available tools, tiered memory access (L0/L1/L2), and best practices.
- Clarified when and how to use each tool, including `store`, `commit`, `search`, `recall`, `ls`, `explore`, `abstract`, `overview`, `content`, `delete`, `layers`, and `index`.
- Explained memory organization using URI schemes and provided practical workflow examples.
- Documented MCP server requirements, configuration, and auto-trigger features for seamless setup and operation.
- Improved guidance on persistent context, user preferences, and project knowledge management for AI agents.

Archiver·手机版·闲社网·闲社论坛·羊毛社区· 多链控股集团有限公司 · 苏ICP备2025199260号-1

Powered by Discuz! X5.0   © 2024-2025 闲社网·线报更新论坛·羊毛分享社区·http://xianshe.com

p2p_official_large
返回顶部