knowledge-mcp
Provides tools for searching, listing, reading, previewing diffs, and editing Markdown notes in a local knowledge vault, with scope restrictions and path validation.
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., "@knowledge-mcp Search personal notes for 'question' and show paths, line numbers, and snippets."
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.
knowledge-mcp
通过 MCP 检索 Markdown 笔记、定位原文并预览修改。
合成示例库的真实 MCP 输出;图中只展示 diff 的变更行,未写入文件。
快速开始
uvx --from git+https://github.com/bmdy6/knowledge-mcp knowledge-mcp --vault <路径>将 <路径> 换成已有知识库的绝对路径。先试用可下载 main 的 ZIP,解压后选择 examples/vault;这是合成示例,无需 clone。
连接客户端后说:“在 personal 中搜索 question,返回路径、行号和片段。”需要 Python 3.10+、uv 和首次下载所需的网络。
Related MCP server: livewiki
客户端配置
试用时,把下载包里的 examples/vault 复制到 /tmp/knowledge-mcp-demo。下面三份配置均使用该目录;长期使用请换成自己的绝对路径,重启客户端以载入配置。
uvx 必须在客户端的 PATH 中可用;首次下载可稍慢。
Claude Code
保存为项目的 .mcp.json:
{
"mcpServers": {
"knowledge": {
"command": "uvx",
"args": [
"--from",
"git+https://github.com/bmdy6/knowledge-mcp",
"knowledge-mcp",
"--vault",
"/tmp/knowledge-mcp-demo"
]
}
}
}Codex
加入 ~/.codex/config.toml:
[mcp_servers.knowledge]
command = "uvx"
args = ["--from", "git+https://github.com/bmdy6/knowledge-mcp", "knowledge-mcp", "--vault", "/tmp/knowledge-mcp-demo"]
startup_timeout_sec = 60Cursor
保存为项目的 .cursor/mcp.json:
{
"mcpServers": {
"knowledge": {
"command": "uvx",
"args": [
"--from",
"git+https://github.com/bmdy6/knowledge-mcp",
"knowledge-mcp",
"--vault",
"/tmp/knowledge-mcp-demo"
]
}
}
}接入后先读 knowledge://guide。客户端设置与路径说明见接入文档。
你能得到什么
搜索结果带文件路径、行号和原文片段,方便回到来源核实。
show_diff只预览修改;写入时expected_text必须在当前文件中唯一匹配。每次访问都选定 scope,路径校验将文档操作限制在知识库内。
工作流程
在
personal或company中搜索,再用read_range读取原文。传入原文片段和替换文本,用
show_diff审阅变化。确认后调用
apply_change,回读并校验;Git 提交由维护者处理。
工具
权限 | 工具 |
只读 |
|
写入 |
|
参数见 MCP 契约。新建文档固定为 review;删除、合并和移动也会改动文件。
搜索遇到损坏或不可读笔记时仍返回健康命中,并在列表末尾追加 {warning, partial: true, skipped}。调用方应先区分 warning 诊断和普通命中,不能把它当作有 path、行号的结果;零命中时也可能只是部分搜索。
选项
选项 | 用途 |
| 指定已有目录;参数优先,未配置就退出。 |
| 显式选择 |
| 默认关闭;显式开启才读取归档。 |
常见问题与限制
知识库如何组织? personal/、company/ 各放 Markdown 笔记和概览 README.md,可选 archive/。Frontmatter 的 title、type、status、scope、日期等字段见内容模型。
写入有什么保护? expected_text 是局部文本条件,须在当前文件恰好出现一次;先看 diff 再提交修改。绝对路径、.. 和跨 scope 文档路径会被拒绝,归档不可直接写入;scope 是文档边界,不能替代操作系统权限。详见写入安全。
同一 vault 的 MCP 写入在 macOS/Linux/Windows 上使用跨进程锁,等待超过 10 秒会报告繁忙。根目录会保留 .knowledge-mcp.lock,运行时不要删除,可加入知识库自己的 .gitignore。锁不能协调外部编辑器或同步器,网络文件系统也未验证;操作这些工具时应暂停 MCP 写入。
支持语义检索吗? 目前只有关键词检索(中文二元组 + BM25),没有向量检索,也不需要 embedding 服务。内容和检索结果仍需人工核实。
参与贡献
先提 Issue 说明问题;本地安装开发依赖后运行 uv run pytest -q。CI 覆盖 Ubuntu、macOS、Windows 和 Python 3.10、3.13。
许可证
MIT。
Available Tools
10 toolsapply_changeBDestructive
Apply one local text replacement after checking the current version.
replaces lists existing documents absorbed into this one by the edit
(for example a concept card folded into a topic article). They are deleted
only after the patch is written, and the patched body must still hold at
least 70% of their combined length.
Inputs: path (required), scope (required), replacement (required), expected_text (required), +1 more. Returns: object
create_documentA
Create one Markdown document; it always starts as review.
Before creating, search for an existing document on the same topic and
extend it with apply_change instead; new files are for new topics only.
document_type:
article: one topic, merged from all sources, kept up to date in place;reference: notes on one external source (link + key excerpts, never the full original);research: a research conclusion worth keeping (not deferred/P2 notes);guide: repeatable steps;decision: a choice and its reasons;task(company): one task per file, content must contain## 任务描述## 解决思考## 解决方法## 结果## 链接;createdis the task date.
No status argument is accepted: a caller (including another agent) must
not be able to create content that already claims to be human-confirmed.
Confirming an existing document goes through apply_change.
created/updated are only for importing existing documents that must
keep their original dates; new content leaves them unset.
replaces: when merging several notes into one topic article, list the
old document paths here. They are deleted after the new file is written,
their sources may be re-listed in sources, and the merged body must
keep at least 70% of their combined length (drop duplicates, not ideas).
Inputs: path (required), scope (required), title (required), content (required), +7 more. Returns: object
delete_documentADestructiveIdempotent
Delete one Markdown document.
successor names the document that absorbed this one's content; when
given, the deletion is refused unless the successor body holds at least 70%
of the deleted body. Use it for approved cleanup (superseded notes, cards
that were folded into an article), and omit it only for content a human has
explicitly agreed to drop.
Inputs: path (required), scope (required), successor. Returns: object
list_documentsCRead-onlyIdempotent
List Markdown paths within an explicitly selected scope.
Inputs: scope (required), prefix, include_archive. Returns: result
move_documentADestructive
Move or rename one document within its scope; content is unchanged.
Use it to place a file under its topic directory or drop a legacy filename prefix. The target must not exist; emptied old folders are removed.
Inputs: path (required), scope (required), new_path (required). Returns: object
readCRead-onlyIdempotent
Read one Markdown document from the selected scope.
Inputs: path (required), scope (required), include_archive. Returns: result
read_rangeCRead-onlyIdempotent
Read a 1-based inclusive line range from a Markdown document.
Inputs: path (required), scope (required), end_line (required), start_line (required), +1 more. Returns: object
searchCRead-onlyIdempotent
Return matches; a final warning record marks skipped, invalid notes.
Match records have path/line/snippet fields. A diagnostic record instead has warning, partial=true and skipped (relative paths and error codes).
Inputs: query (required), scope (required), limit, include_archive. Returns: result
show_diffCRead-onlyIdempotent
Preview a unique, version-checked local text replacement.
Inputs: path (required), scope (required), replacement (required), expected_text (required). Returns: object
validate_vaultCRead-onlyIdempotent
Validate Markdown metadata and scope boundaries without writing.
Inputs: scope, include_archive. Returns: result
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 10 tools
Each tool targets a distinct operation on the Markdown vault: preview (show_diff) vs. mutation (apply_change), path listing (list_documents) vs. content matching (search), and document lifecycle actions are all clearly separated. The only mild overlap is read vs. read_range, but the descriptions make the boundary explicit (whole document vs. 1-based inclusive line range).
The set follows a verb-first convention (list_documents, validate_vault, apply_change, create_document, delete_document, move_document, show_diff), with only the bare verbs 'search' and 'read' deviating. All names are snake_case, so the pattern is predictable and readable.
Ten tools is well within the ideal range and every tool earns its place: preview, search, list, read, range-read, validate, and the four mutation operations. Nothing looks redundant or bolted on for a scoped knowledge-vault server.
The surface covers the full document lifecycle (create/read/list/search/update/delete/move) plus validation and safe-edit preview, which is strong for a Markdown vault. Minor gaps remain: no way to inspect links/backlinks or frontmatter/tags directly, and no bulk metadata query, which are common needs in a linked knowledge base.
Maintenance
Related MCP Connectors
Search, read, and safely update Markdown notes in your connected Phasoric knowledge vaults.
Encrypted Markdown notes and team knowledge base. Search, read and write notes in vaults you allow.
Personal context for every AI: search, read, and write back to your private Markdown library.
Search, read and edit your team's docs-as-code documentation, synced with Git.
Related MCP Servers
- AlicenseNot gradedqualityCmaintenanceEnables AI coding agents to search and retrieve cited line-level context from versioned knowledge bundles, as well as list workspaces and publish or pull immutable Markdown bundles.Apache 2.0
- AlicenseNot gradedqualityBmaintenanceReads, searches, and safely writes a repository wiki of Markdown pages anchored to real code. Every write is verified against the codebase and rolled back on failure, and stale pages are detected deterministically rather than guessed.1MIT
- AlicenseAqualityCmaintenanceEnables AI coding agents to consult a project's Git-versioned Markdown knowledge base over local stdio — checking knowledge health, listing the catalog, searching topics, and reading guides before acting. Access stays read-only, so project guidance, decisions, and lessons learned remain shared with human teammates and traceable beside the code.41MIT
- AlicenseNot gradedqualityBmaintenanceEnables AI agents to search, read, create, patch, lint, and synchronize a shared Markdown+git knowledge base across multiple machines and sessions, with confidence metadata and protocol resources.1MIT