Skip to main content
Glama
junqiu520

feishu-memory-mcp

by junqiu520

feishu-memory-mcp

飞书驱动的 RAG 记忆库 MCP server。 Agent 长期记忆 + 个人知识库,两者都存飞书多维表格,通过同一套 Model Context Protocol 接口可检索。

CI Python 3.11+ License: MIT

这是什么

feishu-memory-mcp飞书(Lark / Feishu) 当成持久化后端, 给 LLM agent 提供两套隔离但统一的记忆服务:

Scope

用途

谁来写

谁来读

memory

agent 的长期记忆(对话片段、agent 自动 add 的内容、解析后的资料)

agent

全部 agent + 你

knowledge

你的个人知识库(笔记、规范、文档)

(或 lark-ui 录入)

agent 可消费

两库都用飞书多维表格做持久化 + 本地 SQLite + LanceDB 做查询缓存,agent 通过 8 个 MCP 工具读写。

Related MCP server: Lark Base MCP Server

5 分钟跑起来

# 1. 装 Python 包
pip install feishu-memory-mcp

# 2. 装系统依赖(自动检测 Node.js / npm 然后 npm install -g @larksuite/cli)
feishu-memory install-deps

# 3. lark-cli OAuth 授权(会打开浏览器)
lark-cli config init

# 4. 配环境变量
export FEISHU_APP_ID=cli_xxxxxxxxxxxx
export FEISHU_APP_SECRET=...
export MEMORY_BITABLE_APP_TOKEN=bascnxxxxxxxxxxxx
export MEMORY_BITABLE_TABLE_ID=tblxxxxxxxxxxxxxxxx
export KNOWLEDGE_BITABLE_APP_TOKEN=bascnyyyyyyyyyyyy
export KNOWLEDGE_BITABLE_TABLE_ID=tblyyyyyyyyyyyyy

# 5. 验证
feishu-memory doctor   # 6/6 检查过
feishu-memory sync     # 第一次拉飞书 Bitable 数据
feishu-memory serve    # 启动 MCP server(agent 客户端连)

第 4 步需要你在飞书 UI 提前创建 2 个多维表格(每个 16 字段),详细字段表见 docs/deployment.md

给 agent 用:8 个 MCP 工具

把这段加到 agent 客户端的 mcp 配置(Claude Desktop / Cursor / Codex / etc):

{
  "mcpServers": {
    "feishu-memory": {
      "command": "feishu-memory",
      "args": ["serve"],
      "env": { "FEISHU_APP_ID": "...", "...": "..." }
    }
  }
}

启动后 agent 看到这 8 个 tool:

Tool

用途

Scope

memory_add

写一条记忆(agent 自己加,或保存对话)

memory / knowledge

memory_query

检索(4 种 mode:hybrid_rerank / hybrid / bm25 / vector)

memory / knowledge

memory_get

取一条完整内容

memory / knowledge

memory_update

改一条的元数据(标题/标签)

memory / knowledge

memory_delete

删除一条

memory / knowledge

memory_list

列表(带分页 + 排序)

memory / knowledge

memory_count

计数

memory / knowledge

memory_sync

触发与飞书的同步(3 种 mode:incremental / full / rebuild)

memory / knowledge

每个 tool 接受 scope 参数(memory / knowledge)。memory_query 还有 4 种 mode 选:

  • hybrid_rerank(默认):BM25 + 向量 + RRF + 重排

  • hybrid:BM25 + 向量 + RRF(不要重排,更快)

  • bm25_only:纯关键词

  • vector_only:纯语义

详细 tool 文档:docs/tool-reference.md

命令行(CLI 运维)

feishu-memory 是个 single-binary CLI,每个子命令独立:

子命令

作用

init

打印首次安装的环境变量模板

install-deps

检测 Node.js / npm 并装 lark-cli

serve

启动 MCP server(stdio 传输)

doctor

诊断 Node / npm / lark-cli / config / cache 状态

sync

手动触发与飞书的同步

status

看本地 cache 状态(记录数、最后 sync 时间、vector index 大小)

schema

导出 / 验证 Bitable 字段定义 vs spec

migrate

重建本地 cache(model 切换后 / cache 损坏)

version

打印版本号

每个子命令都支持 --help

架构一览

[agent client]  ←stdio/MCP→  [feishu-memory-mcp]  ←subprocess→  [lark-cli]  ←HTTPS→  [飞书]
   • 8 tools      │              │ Service Layer         │              │       • Bitable
   • stdin/stdout│              │ • MemoryService       │              │       • Docx
                 │              │ • SearchService       │              │       • Drive
                 │              │ • SyncService         │              │
                 │              │                       │              │
                 │              ├─ Index Engine         │              │
                 │              │ • EmbeddingEngine     │              │
                 │              │   (bge-m3 / MiniLM)   │              │
                 │              │ • TextChunker         │              │
                 │              │ • Reranker            │              │
                 │              │ • RRFMerger           │              │
                 │              │                       │              │
                 │              └─ Local Storage        │              │
                 │                 • SQLite (FTS5)       │              │
                 │                 • LanceDB (vectors)   │              │
                 │                                                  │
                 └─ Skill file: skill/feishu-memory/SKILL.md

详细架构:docs/architecture.md

Embedding 模型选择

feishu-memory-mcpsentence-transformers 做 embedding。默认用最小最快的 all-MiniLM-L6-v2(80MB / 30秒下载 / 不需要 HF_TOKEN),所以任何机器装上就能跑。生产环境中文/多语种可换更大的:

Model

大小

维度

何时用

sentence-transformers/all-MiniLM-L6-v2 (默认)

80MB

384

无 token 快速启动

BAAI/bge-small-en-v1.5

33MB

384

极简英文

BAAI/bge-m3

2.3GB

1024

中文/多语种推荐

BAAI/bge-large-en-v1.5

1.3GB

1024

纯英文高质量

intfloat/multilingual-e5-base

1GB

768

中英文平衡

切换:.env 里改 EMBEDDING_MODEL 然后重启 + 跑 feishu-memory migrate(不同 model 维度不同)。

加速下载:免费申请 HF_TOKEN https://huggingface.co/settings/tokens,5-10x 加速。

项目特点

  • 飞书是唯一权威源 — 本地 cache 可任意删,feishu-memory migrate 一键从飞书恢复

  • 多 agent 共享同一记忆库source_agent 字段标记来源,不同 agent 共享同一张 Bitable

  • 可重建 vector index — 切换 embedding model 后 migrate 重建 LanceDB

  • 失败容忍 — 飞书写失败不阻塞本地写,下次 sync 自动重试

  • CLI 优先 — 9 个子命令覆盖所有运维场景,不需要查 SQL / 直接读 Bitable

  • 零额外 Node 包lark-cli 是 npm 全局唯一依赖;Python 端纯 lancedb + sentence-transformers + SQLite

  • OS 跨平台 — Windows / macOS / Linux 全部 CI 测过

  • 真实环境验证 — 27 个 commit + 24 个 BUG 修复都是用真实飞书 Bitable 跑出来的

文档索引

开发

git clone https://github.com/junqiu/feishu-memory-mcp
cd feishu-memory-mcp
pip install -e ".[dev]"
pytest                 # 跑全部 unit tests(205 个)
ruff check src tests

CI:push 即跑(Python 3.11/3.12/3.13,Ubuntu latest)。

许可

MIT.

A
license - permissive license
-
quality - not tested
C
maintenance

Maintenance

Maintainers
Response time
Release cycle
Releases (12mo)
Commit activity

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/junqiu520/feishu-memory-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server