Token导航 LogoToken导航TokenDH.com
Local Memory MCP V2 logo
搜索检索stdio官方级别未说明来源级核验

Local Memory MCP V2

MCP Server

Local Context Memory MCP 是一个为AI代理提供持久、可搜索记忆的生产级系统,支持跨会话记忆、语义搜索和私有本地存储,适用于个人和团队使用。

工具数

0

提示词数

0

GitHub Stars

0

资源数

0
AI记忆本地存储PythonClaudeClaude DesktopClaude

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

作者 / 组织

alphaplapplap

提供方

alphaplapplap

最后核验

2026/5/17 20:21

运行时

Docker

快速接入

先看主来源和安装命令,再打开仓库或文档;下面只保留这个条目的关键接入事实。

命令预览

docker run --rm -i -v ./memory-data:/app/data cunicopia/local-memory-mcp:sqlite

详细介绍

本地上下文存储器MCP

![License: MIT](https://opensource.org/licenses/MIT) ![Python 3.12+](https://www.python.org/downloads/) ![MCP Compatible](https://modelcontextprotocol.io/)\ ](https://www.docker.com/)

曾经想要ChatGPT内存功能,但 在所有LLM中 并存储在 您自己的硬件你有没有讨厌过 限制记忆的数量 ChatGPT可以存储,并且您 无法分割你的记忆 进入不同领域?

这是你的解决方案。

为任何AI助手提供您完全控制的持久、无限的内存。

使用 模型上下文协议(MCP)。可与任何兼容MCP的客户端Claude Desktop配合使用,并为您提供所需的内存功能。

目录

- 可用工具 - 可用资源 - 可用提示

- SQLite+FAISS实现 - PostgreSQL+pgvector实现

- 先决条件 - Ollama设置

- 码头工人

为何这很重要

传统人工智能问题:人工智能助手在对话之间会忘记一切。每次交互都是从头开始的,要求用户反复提供有关其偏好、项目和历史的上下文。

解决方案:本地上下文内存为您的AI提供持久、可搜索的内存,这些内存:

  • 🧠 跨会话记忆 -用户偏好、项目详细信息、对话历史记录
  • 🎯 查找相关上下文 -语义搜索在正确的时间显示正确的记忆
  • 🏢 按域组织 -工作、健康、个人生活的独立上下文(PostgreSQL)
  • 🔒 保持私密 -所有数据都存储在您控制的本地
  • 立即工作 -与Claude Desktop和MCP客户端的兼容性下降

选择您的实施方案

  • SQLite+FAISS:非常适合个人使用、开发和简单部署
  • PostgreSQL+pgvector:通过领域细分和团队协作为生产做好准备

工具和功能

graph LR
    subgraph "Client"
        USER[User]
        CD[Claude Desktop]
    end
    
    subgraph "MCP Server"
        subgraph "Tools"
            SM[store_memory]
            UM[update_memory]
            SRCH[search_memories]
            LMD[list_memory_domains]
        end
        
        subgraph "Resources"
            RES_SQL[memory://query]
            RES_PG[memory://domain/query]
        end
        
        subgraph "Prompts"
            SUM[summarize_memories]
        end
    end
    
    subgraph "Domain Context"
        DC[PostgreSQL Only]
        DC2[Multi-domain isolation:
startup, health, personal]
    end
    
    USER --> CD
    CD -->|MCP Protocol| SM
    CD -->|MCP Protocol| UM
    CD -->|MCP Protocol| SRCH
    CD -->|MCP Protocol| LMD
    CD -->|MCP Protocol| RES_SQL
    CD -->|MCP Protocol| RES_PG
    CD -->|MCP Protocol| SUM
    
    LMD -.->|Available in| DC
    RES_PG -.->|Available in| DC
    DC --> DC2
    
    classDef client fill:#e3f2fd,stroke:#1976d2,stroke-width:2px,color:#0d47a1
    classDef server fill:#f3e5f5,stroke:#7b1fa2,stroke-width:2px,color:#4a148c
    classDef tool fill:#fff3e0,stroke:#f57c00,stroke-width:2px,color:#e65100
    classDef resource fill:#e8f5e8,stroke:#388e3c,stroke-width:2px,color:#1b5e20
    classDef prompt fill:#fce4ec,stroke:#c2185b,stroke-width:2px,color:#880e4f
    classDef domain fill:#f1f8e9,stroke:#689f38,stroke-width:2px,color:#33691e
    
    class USER,CD client
    class SM,UM,SRCH,LMD tool
    class RES_SQL,RES_PG resource
    class SUM prompt
    class DC,DC2 domain

可用工具

store_memory

使用自动语义索引将新信息存储在持久内存中。

  • SQLite: store_memory(content, source?, importance?)
  • PostgreSQL: store_memory(content, domain?, source?, importance?)
  • 例子:

- "User prefers TypeScript over JavaScript for new projects" - "Weekly team meeting every Tuesday at 2 PM PST"

update_memory

在保留搜索索引的同时修改现有内存。

  • SQLite: update_memory(memory_id, content?, importance?)
  • PostgreSQL: update_memory(memory_id, content?, importance?, domain?)
  • 用例:更新过时的信息或更改重要性级别

search_memories

使用语义或关键字搜索查找相关记忆。

  • SQLite: search_memories(query, limit?, use_vector?)
  • PostgreSQL: search_memories(query, domain?, limit?)
  • 例子:

- "What programming languages does the user prefer?" - "Recent project decisions about database choices"

list_memory_domains *(仅限PostgreSQL)*

发现用于有组织上下文切换的可用内存域。

  • 退货: ["default", "work", "health", "personal"]
  • 用例:在不同的内存上下文之间切换

可用资源

memory://query *(SQLite)*

通过URI模式进行快速语义搜索,以实现简单的内存检索。

memory://domain/query *(PostgreSQL)*

孤立内存上下文的域范围语义搜索。

  • 例子:

- memory://work/project deadlines - memory://health/medication schedule

可用提示

summarize_memories

生成检索到的内存集合的智能摘要。

  • 输入:内存对象列表
  • 输出:结构化摘要,突出关键模式和见解
  • 用例:为复杂主题创建上下文摘要

架构

SQLite+FAISS实现(原始)

graph TB
    subgraph "Client Layer"
        CD[Claude Desktop]
        AI[AI Agent]
    end
    
    subgraph "MCP Server Layer"
        SMS[SQLite Memory Server]
    end
    
    subgraph "API Layer" 
        SMA[SQLite Memory API]
        SVA[SQLite Vector API]
        OE[Ollama Embeddings]
        SC[Smart Chunker]
    end
    
    subgraph "Storage Layer"
        SQL[(SQLite Database)]
        FAISS[(FAISS Index)]
    end
    
    subgraph "External Services"
        OL[Ollama API]
        EM[nomic-embed-text]
    end
    
    CD -->|MCP Protocol| SMS
    AI -->|HTTP/JSON-RPC| SMS
    
    SMS --> SMA
    SMA --> SVA
    SVA --> SC
    SVA --> OE
    
    SMA -->|Store Metadata| SQL
    SVA -->|Vector Operations| FAISS
    
    OE -->|Generate Embeddings| OL
    OL --> EM
    
    classDef client fill:#e3f2fd,stroke:#1976d2,stroke-width:2px,color:#0d47a1
    classDef server fill:#f3e5f5,stroke:#7b1fa2,stroke-width:2px,color:#4a148c
    classDef api fill:#fff3e0,stroke:#f57c00,stroke-width:2px,color:#e65100
    classDef storage fill:#e8f5e8,stroke:#388e3c,stroke-width:2px,color:#1b5e20
    classDef external fill:#fce4ec,stroke:#c2185b,stroke-width:2px,color:#880e4f
    
    class CD,AI client
    class SMS server
    class SMA,SVA,OE,SC api
    class SQL,FAISS storage
    class OL,EM external

PostgreSQL+pgvector实现(新)

graph TB
    subgraph "Client Layer"
        CD[Claude Desktop]
        AI[AI Agent]
    end
    
    subgraph "MCP Server Layer"
        PMS[PostgreSQL Memory Server]
    end
    
    subgraph "API Layer"
        PMA[PostgreSQL Memory API]
        OE[Ollama Embeddings]
    end
    
    subgraph "PostgreSQL Database"
        subgraph "Domain Tables"
            DT1[default_memories]
            DT2[startup_memories]
            DT3[health_memories]
        end
        PGV[pgvector Extension]
    end
    
    subgraph "External Services"
        OL[Ollama API]
        EM[nomic-embed-text]
    end
    
    CD -->|MCP Protocol| PMS
    AI -->|HTTP/JSON-RPC| PMS
    
    PMS --> PMA
    PMA --> OE
    PMA -->|SQL + Vector Ops| PGV
    PGV --> DT1
    PGV --> DT2
    PGV --> DT3
    
    OE -->|Generate Embeddings| OL
    OL --> EM
    
    classDef client fill:#e3f2fd,stroke:#1976d2,stroke-width:2px,color:#0d47a1
    classDef server fill:#f3e5f5,stroke:#7b1fa2,stroke-width:2px,color:#4a148c
    classDef api fill:#fff3e0,stroke:#f57c00,stroke-width:2px,color:#e65100
    classDef storage fill:#e8f5e8,stroke:#388e3c,stroke-width:2px,color:#1b5e20
    classDef external fill:#fce4ec,stroke:#c2185b,stroke-width:2px,color:#880e4f
    
    class CD,AI client
    class PMS server
    class PMA,OE api
    class DT1,DT2,DT3,PGV storage
    class OL,EM external

特性

公共特性

  • 语义搜索:使用Ollama嵌入进行智能内存检索
  • 智能分块:自动分解长文本以获得更好的搜索结果
  • MCP标准:完全符合Claude Desktop集成的MCP协议
  • Docker就绪:具有自包含映像的简单容器化部署
  • 后备搜索:矢量搜索不可用时自动回退到文本搜索

SQLite+FAISS特定

  • 本地存储:所有内容都使用SQLite+FAISS文件在本地运行
  • 零设置:不需要数据库服务器
  • 便携的:单个目录包含所有数据

PostgreSQL+pgvector专用

  • 域名分割:单独的内存上下文(启动、健康、个人等)
  • 生产就绪:ACID合规性、并发访问、复制支持
  • 本地矢量操作:高效的相似性搜索,无需单独的索引文件
  • 可扩展的:通过适当的索引处理大型数据集

快速开始

推荐:使用Docker进行最简单的设置! 跳过所有依赖关系管理,在几秒钟内开始运行。

选项1:Docker(推荐)

SQLite版本 (最简单):

# Run immediately - no setup required!
docker run --rm -i -v ./memory-data:/app/data cunicopia/local-memory-mcp:sqlite

PostgreSQL版本 (带域分割):

# Run immediately - includes full PostgreSQL database!
docker run --rm -i -v ./postgres-data:/var/lib/postgresql/data cunicopia/local-memory-mcp:postgres

就是这样!容器是自包含的,可以自动处理所有依赖关系。

先决条件

  • Docker(用于容器化部署)或Python 3.12+(用于本地安装)
  • 奥拉玛与 nomic-embed-text 模型(可选,但建议用于增强语义搜索)

Ollama设置(可选但推荐)

Ollama通过向量嵌入实现了增强的语义搜索。没有它,系统就会退回到基于文本的搜索。

安装:

  • macOS/Windows:从下载安装程序 ollama.com/下载
  • Linux: curl -fsSL https://ollama.com/install.sh | sh

设置:

# Install the embedding model
ollama pull nomic-embed-text:v1.5

# Verify it's running (should show localhost:11434)
curl http://localhost:11434/api/tags

Claude桌面设置

准备好Docker容器(或本地安装)后,通过将以下内容添加到MCP设置中连接到Claude Desktop:

Docker配置(推荐)

{
  "mcpServers": {
    "localMemoryMCP-SQLite": {
      "command": "docker",
      "args": ["run", "--rm", "-i", "-v", "/path/to/your/memory-data:/app/data", "cunicopia/local-memory-mcp:sqlite"]
    },
    
    "localMemoryMCP-PostgreSQL": {
      "command": "docker", 
      "args": ["run", "--rm", "-i", "-v", "/path/to/your/postgres-data:/var/lib/postgresql/data", "cunicopia/local-memory-mcp:postgres"]
    }
  }
}

卷路径: 替换 /path/to/your/memory-data/path/to/your/postgres-data 使用您想要存储记忆的任何目录(例如。, ~/Documents/memory-data, /Users/yourname/my-memories等等)

本地安装配置(备选)

注: 仅在无法使用Docker时使用。需要先手动设置(请参阅 手动安装).

{
  "mcpServers": {
    "localMemoryMCP": {
      "command": "bash",
      "args": ["/path/to/local-memory-mcp/run_sqlite.sh"]
    }
  }
}

例子

SQLite实现

// Store a memory
store_memory(
  "User prefers Python for backend development", 
  "conversation", 
  0.8
)

// Search memories
search_memories("programming preferences", 5, true)

// Get memories via resource
// Access: memory://programming

PostgreSQL实现

// List available domains
list_memory_domains()
// Returns: ["default", "startup", "health"]

// Store memories in different domains
store_memory(
  "Series A funding closed at $10M",
  "startup",  // domain
  "meeting",   // source
  0.9         // importance
)

store_memory(
  "User has peanut allergy",
  "health",
  "medical_record",
  1.0
)

// Search within specific domain
search_memories("funding", "startup", 5)

// Get memories via resource
// Access: memory://startup/funding%20strategy

组件

SQLite实现

  • FastMCP:Python MCP服务器框架
  • SQLite:结构化元数据和文本搜索回退
  • FAISS:矢量相似性搜索
  • 奥拉玛:本地嵌入生成(可选)
  • Smart Chunker:文本处理以实现最佳检索

PostgreSQL实现

  • FastMCP:Python MCP服务器框架
  • PostgreSQL:具有元数据和矢量存储的完整数据库
  • pg向量:PostgreSQL原生向量相似性搜索
  • 奥拉玛:本地嵌入生成(可选)
  • 域表:隔离内存上下文以实现更好的组织

配置

常见环境变量

  • OLLAMA_API_URL:Ollama端点(默认值: http://localhost:11434)
  • OLLAMA_EMBEDDING_MODEL:型号名称(默认值: nomic-embed-text)
  • MCP_SERVER_NAME:MCP的服务器名称(默认值: Local Context Memory)

SQLite特定

  • MCP_DATA_DIR:数据存储路径(默认值: ./data)

PostgreSQL特定

  • POSTGRES_HOST:数据库主机(默认值: localhost)
  • POSTGRES_PORT:数据库端口(默认值: 5432)
  • POSTGRES_DB:数据库名称(默认值: postgres)
  • POSTGRES_USER:数据库用户(默认值: postgres)
  • POSTGRES_PASSWORD:数据库密码(必填)
  • DEFAULT_MEMORY_DOMAIN:内存的默认域(默认值: default)

发展

SQLite版本

pip install -r requirements.sqlite.txt
python src/sqlite_memory_server.py

PostgreSQL版本

pip install -r requirements.pgvector.txt
python src/postgres_memory_server.py

码头工人

Docker支持与自包含的容器完全兼容!SQLite和PostgreSQL版本完全独立运行。

# Run pre-built images directly (recommended)
# SQLite version - replace './data' with your preferred data directory
docker run --rm -i -v ./data:/app/data cunicopia/local-memory-mcp:sqlite

# PostgreSQL version - replace './postgres_data' with your preferred data directory  
docker run --rm -i -v ./postgres_data:/var/lib/postgresql/data cunicopia/local-memory-mcp:postgres

从源构建(可选):

# Only needed if you want to build yourself
docker build -f Dockerfile.sqlite_version -t local-memory-mcp:sqlite_version .
docker build -f Dockerfile.postgres_version -t local-memory-mcp:postgres_version .

手动安装

⚠️ 我们强烈建议使用Docker -它自动处理所有依赖关系。仅当Docker不可用或您有特定要求时,才使用此部分。

SQLite+FAISS(简单,本地)

git clone https://github.com/cunicopia-dev/local-memory-mcp
cd local-memory-mcp
pip install -r requirements.sqlite.txt
python src/sqlite_memory_server.py

PostgreSQL+pgvector(生产,可扩展)

对于基于Debian的系统:

# Install PostgreSQL + pgvector
sudo apt install postgresql postgresql-contrib
sudo apt install postgresql-17-pgvector  # Adjust version as needed

# Change directory to where you downloaded the repo
cd /path/to/local-memory-mcp

# Set up database
# PLEASE NOTE: We create a user and basic password here, please change this if you want to host it locally
psql < sql/create_user.sql
psql -U postgres < sql/setup_database.sql

# Install Python dependencies
pip install -r requirements.pgvector.txt

# Configure connection (edit .env file)
cp .env.example .env

# Run server
python src/postgres_memory_server.py

对于macOS:

# Install PostgreSQL and pgvector (Homebrew-based)
brew install postgresql@17
brew services start postgresql@17

# Link psql and other tools if needed
brew link --force postgresql@17

# Install pgvector extension (PostgreSQL must be running)
# This installs the extension into your local PostgreSQL environment
brew install pgvector

# OPTIONAL: If pgvector doesn't register properly, you can manually build it
# git clone --branch v0.8.0 https://github.com/pgvector/pgvector.git
# cd pgvector
# make && make install

# PLEASE NOTE: We create a user and basic password here, please change this if you want to host it locally
psql < sql/create_user.sql

# Set up database
psql -U postgres -f sql/setup_database.sql

# Install Python dependencies
pip install -r requirements.pgvector.txt

# Configure connection (edit .env file)
cp .env.example .env

# Run server
python src/postgres_memory_server.py

⚠️ 安全警告: 请转到sql/create_user.sql并创建一个更安全的用户和密码,列出的仅用于示例目的!请保护您的数据,并认真对待您的数据安全。

许可证

MIT许可证

演示

查看本地存储系统的运行情况:

示例1

Example 1

示例2

Example 2

目录标签

目录标签

AI记忆本地存储PythonClaude本地部署语义搜索跨会话记忆MCP协议

支持客户端

Claude DesktopClaude

接入字段

传输方式(transport,传输协议)

stdio

鉴权方式(authType,认证方式)

none

运行时(runtime,运行环境)

Docker

工具数量(toolCount,工具数)

0

资源数量(resourceCount,资源数)

0

提示词数量(promptCount,提示词数)

0

权限和风险

stdionone部署方式未说明

接入前请确认传输方式、认证方式和部署位置,并根据实际工具能力限制访问范围。

安装前确认

不要直接授予不必要的文件、网络或账号权限;先核对安装命令和配置内容。

来源信息

继续浏览同类 MCP