layer-memory

layer-memory

A local-first, Markdown-native AI agent layered memory system that provides MCP tools for storing, recalling, exporting, and importing memories with types like working, persona, and fact.

Category
Visit Server

README

Layer Memory

本地优先、Markdown 原生的 AI 代理分层记忆系统。基于 Midway.js 的 MCP 服务,SQLite 存储,pnpm monorepo。


项目架构

layer-memory/
├── packages/
│   └── core/                  # 记忆核心库(框架无关)
│       └── src/store/         # 存储层抽象、SQLite 实现、类型定义
├── apps/
│   ├── mcp-server/            # MCP 服务端(Midway.js 4.0)
│   │   └── src/tools/         # 4 个 MCP Tools
├── docs/                       # 文档站(dumi 2.x)
├── skill/                     # AI Agent skill 定义
├── .husky/                    # Git hooks
├── .changeset/                # 版本管理
├── docker-compose.yml
├── Dockerfile
└── pnpm-workspace.yaml

MCP Tools

工具 说明 参数
memory_store 存储一条记忆 key, value, type(可选), tags(可选)
memory_recall 搜索已存储的记忆 query, type(可选), tags(可选), limit(可选)
memory_export 导出所有记忆为 JSON outputPath
memory_import 从 JSON 文件导入记忆 inputPath

记忆类型: working (工作记忆) / persona (人格画像) / fact (事实知识)


快速开始

前置要求

  • Node.js >= 20
  • pnpm 10.x(安装:corepack enable && corepack prepare pnpm@10.15.0 --activate)

安装

git clone https://github.com/Dante926/layer-memory.git
cd layer-memory
pnpm install

本地开发

pnpm dev

服务启动在 http://localhost:3000,MCP endpoint 在 /mcp。

构建

pnpm build

所有包编译到各自 dist/ 目录。

文档站

pnpm docs:dev

Docker 部署

启动服务

docker compose up -d

服务运行在 http://localhost:3000。

数据持久化

记忆数据存储在 Docker volume layer-memory-data 中,容器重启/更新不会丢失。

重新构建

docker compose build
docker compose up -d

连接到 AI Agent

Claude Code

在 ~/.claude/settings.json 中配置 MCP:

{
  "mcpServers": {
    "layer-memory": {
      "type": "url",
      "url": "http://localhost:3000/mcp"
    }
  }
}

Codex / Cursor

在项目的 .cursor/mcp.json 中配置:

{
  "mcpServers": {
    "layer-memory": {
      "type": "url",
      "url": "http://localhost:3000/mcp"
    }
  }
}

使用示例

存储记忆:

调用 memory_store(
  key="架构决策",
  value="选择 Midway.js 4.0 MCP + SQLite",
  type="fact",
  tags="项目:layer-memory"
)

搜索记忆:

调用 memory_recall(query="架构决策", limit=5)

导出备份:

调用 memory_export(outputPath="backup.json")

版本管理

本项目使用 Changeset 管理版本:

pnpm changeset       # 创建变更记录
pnpm version         # 更新版本号
pnpm publish         # 发布

开发

提交规范

使用 Conventional Commits:

  • feat: 新功能
  • fix: 修复
  • chore: 工程化
  • docs: 文档

代码格式化

pnpm format

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured