记忆盒子-MCP
克萊因MCP集成,允許用戶保存、搜索和格式化具有語義理解的記憶,提供使用向量嵌入存儲和檢索信息的工具,以進行基於意義的搜索。
服务介绍
此 MCP 服务器提供了与 Memory Box 实例交互的工具,允许您直接从 Cline 和 Claude 桌面版使用语义搜索来保存和搜索记忆。
相关项目
此 MCP 服务器设计用于与 Memory Box 一起工作,这是一个由向量嵌入驱动的语义记忆存储和检索系统。
Memory Box 提供了此 MCP 服务器与其通信的后端 API,使您可以:
- 存储带有向量嵌入的记忆以便进行语义搜索
- 将记忆组织到可自定义的桶中
- 基于意义而非仅关键词搜索记忆
- 获取带有详细上下文的记忆
- 找到语义相关的记忆
- 跟踪记忆处理状态
有关 Memory Box 的更多信息,包括如何设置自己的实例,请访问 Memory Box 网站。
功能
- 保存记忆:将格式化的记忆保存到您的 Memory Box 中,并附带来源信息和元数据
- 搜索记忆:使用语义搜索您的记忆
- 检索记忆:获取所有记忆或特定桶中的记忆
- 查找相关记忆:发现语义相似的记忆
- 检查记忆状态:监控记忆处理状态
- 格式化记忆:根据结构化的系统提示格式化记忆
- 使用统计:查看当前计划、使用指标和资源限制
安装
该服务器已安装并配置好,可以与 Cline 一起使用。请注意,您需要一个正在运行的 Memory Box 实例(无论是自托管还是使用 memorybox.amotivv.ai 上的托管版本)才能使用此 MCP 服务器。
通过 Smithery 安装
要通过 Smithery 自动为 Claude 桌面版安装 Memory Box MCP 服务器:
npx -y @smithery/cli install @amotivv/memory-box-mcp --client claude
完成设置:
-
编辑 Cline MCP 设置文件:
~/Library/Application Support/Code/User/globalStorage/saoudrizwan.claude-dev/settings/cline_mcp_settings.json -
将您的 Memory Box 令牌添加到
MEMORY_BOX_TOKEN环境变量中:"memory-box-mcp": { "command": "node", "args": [ "<path-to-repository>/build/index.js" ], "env": { "MEMORY_BOX_API_URL": "https://memorybox.amotivv.ai", "MEMORY_BOX_TOKEN": "your-token-here", "DEFAULT_BUCKET": "General" }, "disabled": false, "autoApprove": [] } -
可选地,您可以通过更改
DEFAULT_BUCKET的值来自定义默认存储桶。
使用
配置完成后,您可以在 Cline 中使用以下工具:
保存记忆
以正确的格式将记忆保存到 Memory Box:
Use the save_memory tool to save this information about vector databases: "Vector databases like pgvector store and query high-dimensional vectors for semantic search applications."
参数:
text(必需):要保存的记忆内容bucket_id(可选):保存记忆的存储桶(默认:"General")format(可选):是否根据系统提示格式化记忆(默认:true)type(可选):记忆类型(TECHNICAL, DECISION, SOLUTION, CONCEPT, REFERENCE, APPLICATION, FACT),用于格式化(默认:"TECHNICAL")source_type(可选):记忆来源类型(默认:"llm_plugin")reference_data(可选):关于记忆来源和上下文的附加元数据
搜索记忆
使用语义搜索来查找记忆:
Use the search_memories tool to find information about "vector databases"
参数:
query(必需):搜索查询debug(可选):在结果中包含调试信息(默认:false)
获取所有记忆
检索所有记忆:
Use the get_all_memories tool to show me all my saved memories
获取存储桶中的记忆
从特定存储桶中获取记忆:
Use the get_bucket_memories tool to show me memories in the "Learning" bucket
参数:
bucket_id(必需):要从中检索记忆的存储桶
格式化记忆
根据记忆系统提示格式化文本但不保存:
Use the format_memory tool to format this text: "Vector databases like pgvector store and query high-dimensional vectors for semantic search applications."
参数:
text(必需):要格式化的文本type(可选):记忆类型(TECHNICAL, DECISION, SOLUTION, CONCEPT, REFERENCE, APPLICATION, FACT)(默认:"TECHNICAL")
获取相关记忆
找到与特定记忆语义相似的记忆:
Use the get_related_memories tool with memory ID 123
参数:
memory_id(必需):要为其查找相关记忆的记忆 IDmin_similarity(可选):相关记忆的最小相似度阈值(0.0-1.0)(默认:0.7)
检查记忆状态
检查记忆的处理状态:
Use the check_memory_status tool with memory ID 123
参数:
memory_id(必需):要检查状态的记忆 ID
获取使用统计
检索用户使用统计数据和计划信息:
Use the get_usage_stats tool to show me my current plan and usage metrics
此工具返回:
- 当前计划信息(例如,免费、基础、专业、遗留)
- 用户状态和限制执行信息
- 当月使用指标(存储操作、搜索操作、API 调用)
- 带有人类可读格式的数据处理量
- 基于您的计划的资源限制(如果适用)
- 按类型的操作细分
此操作不需要任何参数。
自定义
系统提示自定义
Memory Box MCP 服务器使用系统提示来根据特定指南格式化记忆。您可以自定义此提示以更改记忆的格式。
默认系统提示
默认系统提示包括不同类型的记忆格式化指南:
You are a helpful AI assistant. When storing memories with memory_plugin, follow these enhanced formatting guidelines:
1. STRUCTURE: Format memories based on the type of information:
- TECHNICAL: "YYYY-MM-DD: TECHNICAL - [Brief topic]: [Concise explanation with specific details]"
- DECISION: "YYYY-MM-DD: DECISION - [Brief topic]: [Decision made] because [rationale]. Alternatives considered: [options]."
- SOLUTION: "YYYY-MM-DD: SOLUTION - [Problem summary]: [Implementation details that solved the issue]"
- CONCEPT: "YYYY-MM-DD: CONCEPT - [Topic]: [Clear explanation of the concept with examples]"
- REFERENCE: "YYYY-MM-DD: REFERENCE - [Topic]: [URL, tool name, or resource] for [specific purpose]"
- APPLICATION: "YYYY-MM-DD: APPLICATION - [App name]: [User-friendly description] followed by [technical implementation details]"
2. FORMATTING GUIDELINES:
- CREATE FOCUSED MEMORIES: Each memory should contain a single clear concept or topic
- USE DIVERSE TERMINOLOGY: Include both technical terms AND user-friendly alternatives
- INCLUDE SEARCHABLE KEYWORDS: Begin with common terms a user might search for
- BALANCE DETAIL LEVELS: Include both high-level descriptions and key technical details
- LENGTH: Keep memories between 50-150 words
- ALWAYS include the current date in YYYY-MM-DD format
3. MEMORY STORAGE PARAMETERS:
- Use the "text" parameter for your formatted memory content
- Set "source_type" to "llm_plugin"
- Include appropriate "reference_data" with source information and context
4. REFERENCE DATA STRUCTURE:
- source.platform: Identify your platform (e.g., "claude_desktop", "cline")
- source.type: Always set to "llm_plugin"
- source.version: Optional version information
- context.conversation_id: Include when available to link related conversation memories
- context.message_id: Optional identifier for the specific message
5. SPECIAL FORMATS:
- For user facts, preferences, or personal details: "YYYY-MM-DD: FACT: [User] [specific preference/attribute/information]"
- For reference materials: Include specific details about where to find the information
6. RELATED MEMORIES: After finding memories with search, check if there are related memories using the get_related_memories tool with the memory_id from search results. Present these additional memories to provide the user with more context.
7. RETRIEVAL CONSIDERATION: Before storing an important memory, consider: "What search terms might someone use to find this information later?" and ensure those terms are included.
如何自定义系统提示
要自定义系统提示:
-
编辑 Cline MCP 设置文件:
~/Library/Application Support/Code/User/globalStorage/saoudrizwan.claude-dev/settings/cline_mcp_settings.json -
将您的自定义系统提示添加到
SYSTEM_PROMPT环境变量中:"memory-box-mcp": { "command": "node", "args": [ "<path-to-repository>/build/index.js" ], "env": { "MEMORY_BOX_API_URL": "https://your-memory-box-instance", "MEMORY_BOX_TOKEN": "your-token-here", "DEFAULT_BUCKET": "General", "SYSTEM_PROMPT": "在这里输入您的自定义系统提示..." }, "disabled": false, "autoApprove": [] }在
<path-to-repository>/system-prompt-template.txt提供了一个模板文件,您可以复制并修改它。 -
重启 Cline 以应用更改
系统提示助手
Memory Box MCP 服务器包含一个用于管理系统提示的帮助脚本:
# View the current system prompt
cd <path-to-repository>
npm run prompt-helper -- view
# Reset to the default system prompt
cd <path-to-repository>
npm run prompt-helper -- reset
# Validate a custom system prompt
cd <path-to-repository>
npm run prompt-helper -- validate
其他配置选项
您还可以自定义以下环境变量:
MEMORY_BOX_API_URL:您的 Memory Box 实例的 URLMEMORY_BOX_TOKEN:您的 Memory Box 认证令牌DEFAULT_BUCKET:保存记忆时使用的默认存储桶
故障排除
如果您遇到问题:
- 检查您的 Memory Box 令牌是否正确配置
- 验证您的 Memory Box 实例是否正在运行且可访问
- 检查 Cline 日志中的任何错误消息
开发
要对服务器进行更改:
- 编辑
<path-to-repository>/src/中的源代码 - 重新构建服务器:
cd <path-to-repository> npm run build - 重启 Cline 以应用更改