Simple Memory Extension MCP Server

Integrations

  • Supports configuration through environment variables for database path, port, HTTP/SSE usage, and log level settings

  • Uses the E5 embedding model from Hugging Face for semantic search capabilities, allowing context items to be found based on meaning rather than just exact key matches

  • Uses npm for package management and provides npm scripts for installation, starting the server, development, and code formatting

简单内存扩展 MCP 服务器

MCP 服务器用于扩展代理的上下文窗口/内存。在编写大型功能或氛围代码,需要存储/调用进度、关键时刻、更改或任何值得记住的内容时非常有用。只需让代理存储记忆并在需要时调用,或者让代理以合适的方式完全管理其内存(例如通过游标规则)。

用法

启动服务器

npm install npm start

可用工具

上下文项目管理

  • store_context_item - 在命名空间中存储带有键的值
  • retrieve_context_item_by_key - 按键获取值
  • delete_context_item - 删除键值对

命名空间管理

  • create_namespace创建新的命名空间
  • delete_namespace - 删除命名空间和所有内容
  • list_namespaces - 列出所有命名空间
  • list_context_item_keys - 列出命名空间中的键

语义搜索

  • retrieve_context_items_by_semantic_search - 按含义查找项目

语义搜索实现

  1. 使用 E5 模型将查询转换为向量
  2. 文本自动拆分成块以便更好地匹配
  3. 计算查询和存储块之间的余弦相似度
  4. 按阈值过滤结果并按相似度排序
  5. 返回具有完整项目值的最佳匹配项

发展

# Dev server npm run dev # Format code npm run format

.env

# Path to SQLite database file DB_PATH=./data/context.db PORT=3000 # Use HTTP SSE or Stdio USE_HTTP_SSE=true # Logging Configuration: debug, info, warn, error LOG_LEVEL=info

语义搜索

该项目包含使用 Hugging Face 的 E5 嵌入模型的语义搜索功能。这使您能够根据上下文项的含义(而非仅仅根据精确的关键字匹配)来查找上下文项。

设置

语义搜索功能需要 Python 依赖项,但运行以下命令时自动安装这些依赖项: npm run start

嵌入模型

我们使用intfloat/multilingual-e5-large-instruct

笔记

大部分都是在写 Vibe 代码的时候开发的,所以别期待太多 :D。不过它确实能用,而且我觉得它很有用。欢迎大家贡献代码或提出改进建议。

-
security - not tested
A
license - permissive license
-
quality - not tested

MCP 服务器通过提供存储、检索和搜索记忆的工具来扩展 AI 代理的上下文窗口,从而允许代理在长时间交互中保持历史记录和上下文。

  1. Usage
    1. Starting the Server
    2. Available Tools
    3. Semantic Search Implementation
  2. Development
    1. .env
      1. Semantic Search
        1. Setup
        2. Embedding Model
        3. Notes
      ID: bk4gsbr3t1