feishu-kb-mcp
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@feishu-kb-mcp search my wiki for the onboarding checklist"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
feishu-kb-agent
用 DeepSeek(DeepSeek Harness / 任意 MCP 客户端)管理你的个人飞书知识库。 不是「让 AI 随便改文档」,而是把知识库当成一个有规则的系统:写入可审计、重复会被拦、删除必须过人。
一切设计只服务四件事:可检索、可回指、可重建、可增改查。 做不到这四件事的功能,一律不做。
它解决什么问题
飞书知识库有三个硬约束,直接决定了「AI 该怎么操作它」:
约束 | 后果 | 本项目的做法 |
wiki 是严格树,一个节点一个父节点 | 一条内容不能有两个「家」 | 树只管存放与权限;分类靠定位头与地图页 |
平台搜索是黑盒,且不覆盖个人版全部内容 | 检索不可控 | 本地 SQLite FTS5 索引(中文二元组 + 标题加权) |
docx 没有公开的版本 API | 「只追加」无法只靠飞书实现 | 每次写入前把正文镜像存本地台账,可回滚 |
所以这个项目不是把四个 API 包一层,而是补上飞书缺的三样东西:索引、规则、审计。
Related MCP server: ai-wiki-mcp
能力
模型通过 MCP 看到 12 个强类型工具:
工具 | 作用 | 关键约束 |
| 连接、索引、待办状态 | — |
| 全库检索,返回片段与链接 | 标题权重 ×10,中文二元组 |
| 实时读取正文与定位头 | 永远读飞书,不读缓存 |
| 目录树 | 只读,用于「我都记了什么」 |
| 新建页面 | 幂等:同内容/同标题不重复建 |
| 末尾追加 | 只追加,不改原文;重复段落自动跳过 |
| 字面替换 | 唯一会改原文的工具;先存镜像 |
| 改标题 | 旧标题保留为检索别名,链接不变 |
| 移动节点 |
|
| 发起删除提案 | 模型没有删除能力,只能提案 |
| 同步索引 | 增量优先, |
| 体检与结构建议 | 重复页、空页、深度/宽度、目录阈值 |
人用的命令行补齐了模型不该有的能力:init、doctor、login、delete --confirm、restore、export、eval。
3 分钟跑起来
# 1) 安装(任选其一)
uv tool install git+https://github.com/ZornZL/feishu-kb-agent
# 或
pipx install git+https://github.com/ZornZL/feishu-kb-agent# 2) 初始化:填飞书自建应用的 App ID / Secret 和知识库入口页链接
feishu-kb init
# 3) 体检:逐项验证权限,失败会直接告诉你去点哪里
feishu-kb doctor
# 4) 建索引
feishu-kb sync飞书应用怎么建、要开哪些权限、怎么把应用加进知识库:见 飞书配置。
权限通了之后,跑一次真实验收(会创建一页测试页,默认只生成删除提案、不删除):
python scripts/acceptance.py它依次验证:实时连通 → 同步 → 创建 → 立即可检索 → 追加 → 读回 → 定位头 → 删除提案。
想用「自己的飞书账号」而不是应用身份(更接近“每个人用自己的账号登录”):
feishu-kb init --auth-mode user
feishu-kb login接进 DeepSeek Harness
在 ~/.dsh/cordis.patch.yml 里加一条(Windows 把 command 换成 feishu-kb-mcp.exe 的绝对路径):
- insert:
- id: feishu-kb
name: "@deepseek-ai/dsh-mcp-client"
config:
serverName: feishu_kb
transport: stdio
command: feishu-kb-mcp
args: []重启 Harness,工具会以 mcp__feishu_kb__kb_search 这样的名字出现。完整说明与排错见 DSH 接入。
为什么这样设计
写入只追加,不覆盖
飞书没有版本 API,整篇覆盖等于「把历史删了再写一份」:审计断裂、样式丢失、并发时互相踩。
所以 kb_append 是默认写入方式,kb_replace_text 只用于纠错,且写入前会把原文镜像进本地台账(feishu-kb restore 可回滚)。
删除是人的权力,不是模型的能力
模型 kb_propose_delete → 一次性提案号(24h 过期)
↓ 人在本机
feishu-kb delete --confirm <提案号> → 再输入 DELETE → 删除 + 墓碑工具面里没有 delete,不是靠提示词约束模型,而是能力边界。
目录要「长」出来
不按学科建目录,只按用途建;同类页面 ≥5 才建议建,长期 <3 页建议并。
kb_audit 会按阈值给建议,而不是自动搬树——结构调整必须有人拍板。
完整规则判定(哪些吸收、哪些剔除、为什么):规则取舍。 CRUD 的完整契约与失败模式:CRUD 设计。
文档
文档 | 内容 |
建应用、开权限、发布版本、把应用加进知识库 | |
MCP 配置、验证、排错 | |
两份参考文档里哪些规则吸收、哪些剔除 | |
增删改查的契约、幂等、失败模式 | |
分层、数据流、不变量、选型理由 | |
知识库变大后,先改什么、后加什么 |
分享给别人用
这是一人一库的工具,不是多人共用一个知识库的 SaaS:
每个人 clone 后填自己的飞书应用凭据与知识库链接;
配置与索引只存在本机
~/.feishu-kb/,不进 Git;用
user模式时,权限就是这个人自己的,不需要把应用加成知识库成员;不做中央服务器,也就没有「谁的密钥放在服务端」的问题。
项目结构
feishu_kb/
config.py 配置解析(env / .env / ~/.feishu-kb)
client.py 飞书 HTTP 客户端(令牌缓存、重试、错误翻译)
wiki.py 知识空间节点:树、建、改名、移动、删
docx.py 文档块 ↔ Markdown
rules.py 定位头、命名、查重、目录阈值
store.py SQLite 索引 + 修订台账 + 删除提案
service.py 业务操作(供 MCP 与 CLI 共用)
auth.py 飞书账号 OAuth(user_access_token)
mcp_server.py MCP stdio 服务器
cli.py 命令行
tests/ 单元测试 + 假飞书端到端 + MCP 握手
docs/ 飞书配置、DSH 接入、规则取舍、CRUD 设计已知限制
只索引与编辑
docx;表格、思维导图、多维表格只能给链接。图片/附件不进索引(飞书 docx 的 image 块没有可检索文本)。
中文检索用二元组,不做同义词扩展;专有名词全称/缩写要各写一次。
单机单进程假设:没有多人并发写同一页的冲突合并。
飞书接口限流约 100 次/分钟,首次全量同步大库会慢。
Roadmap
引用回指:回答时返回
(node_token, block_id, 片段),支持点击定位关系提议队列:
supports / contradicts / refines先提案后落库kb_audit的趋势报告(周环比)图片 OCR 与图注生成
可选的本地向量召回(SQLite 扩展,零服务)
License
MIT
Available Tools
12 toolskb_appendA
在页面末尾追加内容(不改写原文),自动加时间与原因戳,并记录修订前镜像。
Args: node_token: 目标页面。 markdown: 要追加的 Markdown。 reason: 为什么追加(会写进页面与审计台账)。
Inputs: markdown (required), node_token (required), reason. Returns: result
kb_auditB
体检:重复页、空页、缺失正文、目录过深过宽,以及按阈值给出的结构建议。
Inputs: no named parameters. Returns: result
kb_createA
新建一页并写入正文。默认幂等:内容或标题与已有页重复时不会创建,而是返回原页。
Args: title: 一句话命题,不要用「杂项」「临时」,不要带两位编号(编号只给一级目录)。 markdown: 正文 Markdown;开头会自动补定位头。 parent_node_token: 父节点 token,留空表示放在入口页下。 type: 类型,笔记/来源/地图/项目/元/目录。 directory: 是否创建目录页(会补「收录判据 / 本目录索引 / 最近更新」三段)。 force: 明确知道要并列第二页时才传 true。
Inputs: title (required), type, force, domain, +6 more. Returns: result
kb_moveB
把页面移动到另一个父节点下。node_token 不变,旧链接继续有效。
Inputs: node_token (required), target_parent_node_token (required), reason. Returns: result
kb_outlineA
查看知识库目录树(默认从入口页开始,最多 3 层),用于回答“我都记了什么”。
Args: parent_node_token: 从哪个节点开始,留空表示配置里的入口页。 depth: 展开层数,1–5。
Inputs: depth, parent_node_token. Returns: result
kb_propose_deleteA
发起删除提案(AI 不能直接删除)。返回一次性提案号,必须由人在命令行确认。
Inputs: reason (required), node_token (required). Returns: result
kb_readA
读取一页的实时正文(Markdown)、定位头、路径、修订摘要与链接。
Args: node_token: 知识库节点 token,通常来自 kb_search / kb_outline 的返回。
Inputs: node_token (required). Returns: result
kb_renameB
修改页面标题(标题即命题)。旧标题会保留为检索别名,链接不变。
Inputs: new_title (required), node_token (required), reason. Returns: result
kb_replace_textA
把页面中一段字面文字替换掉(保留样式)。用于纠错、更新过期数值、修正措辞。
这是唯一会改写原文的工具,用之前必须 kb_read 确认 search 片段准确。
Inputs: search (required), replace (required), node_token (required), reason. Returns: result
kb_searchA
在全库检索(标题权重更高),返回命中页面的标题、路径、片段、node_token 与链接。
Args: query: 检索词,用你会写进标题的说法,不要用编号或缩写。 k: 返回条数,1–20,默认 8。
Inputs: query (required), k. Returns: result
kb_statusA
查看连接状态、索引规模、上次同步时间与待确认的删除提案。任何不确定时先调用它。
Args: probe: 是否实时访问一次飞书,验证权限是否仍然有效(默认只读本地,不发请求)。
Inputs: probe. Returns: result
kb_syncA
把飞书知识库同步到本地索引。日常用增量;结构大改或索引怀疑损坏时用 full。
Args: full: 清空本地索引后重建(不影响飞书内容)。 max_nodes: 本次最多同步多少个节点。
Inputs: full, max_nodes. Returns: result
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 12 tools
Each tool targets a distinct resource+action: search vs read vs outline for retrieval, create/append/replace_text/rename/move for different write operations, plus status, sync, audit, and a guarded delete proposal. The descriptions make the boundaries between the write tools (append at end vs literal text replacement) explicit, so an agent can reliably choose.
All tools share a consistent kb_ prefix and snake_case, mostly following a verb_noun pattern (kb_search, kb_read, kb_create, kb_move, kb_propose_delete). Two tools are noun-style (kb_status, kb_outline), a minor deviation from the verb convention but still readable and predictable.
12 tools is well within the ideal 3-15 range and each maps to a clear responsibility: discovery, reading, authoring, restructuring, maintenance, and safe deletion. Nothing appears redundant or bloated for a knowledge-base server.
The surface covers the full lifecycle: search/read/outline for retrieval, create/append/replace/rename/move for updates, guarded delete via proposal, plus sync and audit for maintenance. Minor gaps exist, such as no explicit version-history or batch-read operation, but core workflows are fully supported.
Related MCP Connectors
Shared project wiki for AI agents: read and write pages, next actions, and activity logs over MCP.
Read and write your team's shared, AI-readable wiki from any MCP client.
Hosted markdown project wikis your team's AI assistants read, search, and update over MCP.
System-of-record notebook for AI coding agents: pages, datastores, tasks, skills over MCP.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceMCP server for persistent, compounding markdown wikis maintained by LLMs. Enables incremental knowledge base building with interlinked pages, search, and raw source management.34 npm1MIT
- FlicenseNot gradedqualityDmaintenanceProvides structured search, schema-validated writes, and linting for a markdown knowledge base, enabling agents to operate the wiki over a single streamable-HTTP MCP endpoint.1-
- AlicenseNot gradedqualityCmaintenanceA machine-local, agent-writable knowledge base MCP server that lets coding agents autonomously record and retrieve hard-won operational facts, incidents, and corrections as markdown pages in a git repo, with provenance, talk pages, and search.5 npmMIT
- AlicenseNot gradedqualityBmaintenanceEnables MCP-capable agents to author, query, and maintain a self-hosted wiki through typed tools backed by SQLite, including full-text search, revisions, links, tags, media, and correction work queues. It supports configurable read, author, and admin tool surfaces for creating, updating, deleting, reviving, and section-editing pages.1MIT