Skip to main content
Glama
knowledge-mcp

knowledge-mcp

by bmdy6

knowledge-mcp

通过 MCP 检索 Markdown 笔记、定位原文并预览修改。

English

合成示例库的真实 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 = 60

Cursor

保存为项目的 .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,路径校验将文档操作限制在知识库内。

工作流程

  1. 在 personal 或 company 中搜索,再用 read_range 读取原文。

  2. 传入原文片段和替换文本,用 show_diff 审阅变化。

  3. 确认后调用 apply_change,回读并校验;Git 提交由维护者处理。

工具

权限

工具

只读

search、list_documents、read、read_range、show_diff、validate_vault

写入

create_document、apply_change、move_document、delete_document

参数见 MCP 契约。新建文档固定为 review;删除、合并和移动也会改动文件。

搜索遇到损坏或不可读笔记时仍返回健康命中,并在列表末尾追加 {warning, partial: true, skipped}。调用方应先区分 warning 诊断和普通命中,不能把它当作有 path、行号的结果;零命中时也可能只是部分搜索。

选项

选项

用途

--vault / KNOWLEDGE_VAULT

指定已有目录;参数优先,未配置就退出。

scope

显式选择 personal 或 company。

include_archive

默认关闭;显式开启才读取归档。

常见问题与限制

知识库如何组织? 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 tools
apply_changeB
Destructive

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 ## 任务描述 ## 解决思考 ## 解决方法 ## 结果 ## 链接; created is 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_documentA
DestructiveIdempotent

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_documentsC
Read-onlyIdempotent

List Markdown paths within an explicitly selected scope.

Inputs: scope (required), prefix, include_archive. Returns: result

move_documentA
Destructive

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

readC
Read-onlyIdempotent

Read one Markdown document from the selected scope.

Inputs: path (required), scope (required), include_archive. Returns: result

read_rangeC
Read-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

show_diffC
Read-onlyIdempotent

Preview a unique, version-checked local text replacement.

Inputs: path (required), scope (required), replacement (required), expected_text (required). Returns: object

validate_vaultC
Read-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

    B3.2/5.0

    Scored across 10 tools

    Disambiguation4/5

    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).

    Naming Consistency4/5

    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.

    Tool Count5/5

    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.

    Completeness4/5

    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

    ActivityMaintained
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      B
      maintenance
      Reads, 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.
      1
      MIT
    • A
      license
      A
      quality
      C
      maintenance
      Enables 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.
      4
      1
      MIT
    • A
      license
      Not graded
      quality
      B
      maintenance
      Enables 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.
      1
      MIT