Knowerage
Knowerage — AI 分析覆盖率管理
本地优先的 MCP 服务器,用于跟踪遗留代码的分析覆盖率和新鲜度。
源码: github.com/MTimma/knowerage
快速开始
要求: Node.js 18 或更高版本 — npx 必须在你的 PATH 中(它随 npm 一起提供,而 npm 包含在 Node 中)。
Related MCP server: Atlas
MCP 服务器配置
在你的 MCP 主机期望定义服务器配置的地方注册 Knowerage(例如,某些客户端使用 .cursor/mcp.json 或 .vscode/mcp.json;其他客户端使用环境变量或 UI——请遵循你所使用主机的文档)。使用相同的服务器条目格式:
{
"mcpServers": {
"knowerage": {
"command": "npx",
"args": ["@mtimma/knowerage"],
"env": {
"KNOWERAGE_WORKSPACE_ROOT": "${workspaceFolder}",
"KNOWERAGE_AUTO_FULL_RECONCILE": "true"
}
}
}
}如果你的主机不展开 ${workspaceFolder} 变量,请将其替换为你的项目根目录。
KNOWERAGE_AUTO_FULL_RECONCILE 是可选的:当未设置、为空或不是真值时,文件监视器默认为关闭。设置为 1、true、yes 或 on(修剪空格,不区分大小写)以启用。当开启时,服务器会监视 knowerage/ 目录,并在短暂的防抖动后,在文件系统发生更改时运行 knowerage_reconcile_all。这与在每次 MCP 工具调用后运行完整对账不同——它仅对 knowerage/ 下的文件更改做出反应。监视器会忽略对 registry.json 的注册表写入,因此保存操作不会导致循环。
如何使用 Knowerage
配置好 MCP 服务器后,你可以用正常的句子与你的助手交流。你不需要记住工具名称。
分析或记录代码
指出你关心的文件、类或行为。例如:
使用 Knowerage 分析
main.java中的逻辑算法工作流。分析 ETL 服务中的数据实体对账和版本控制逻辑。
助手会在 knowerage/analysis/ 下创建或更新 markdown 文件,并在 knowerage/registry.json 中记录覆盖率(见下文的工作原理)。
覆盖率和差距(同一项目,后续聊天或其他智能体)
当你树中已经有分析内容时,你可以询问:
以百分比计算,我们的分析覆盖了多少代码?
这个代码库的哪一部分尚未分析?
Knowerage 会根据注册表和覆盖率辅助工具(例如概览、每个文件的状态和陈旧列表)来回答这些问题,而不是对仓库进行模糊的猜测。
其他方法
通过 npm 安装
npx @mtimma/knowerage或从源码构建
cargo build --release
./target/release/knowerage-mcp工作原理
AI 智能体创建带有 YAML 前置元数据的分析
.md文件,声明源文件和覆盖的代码行范围注册表 (
knowerage/registry.json) 通过 SHA-256 哈希跟踪分析记录以确保新鲜度MCP 工具公开创建、对账、查询和导出操作
智能体说“分析 X” → 自动运行完整工作流(创建 → 对账 → 记录)
注册表文件格式 (knowerage/registry.json)
磁盘上的格式是一个 JSON 对象,其键是分析路径(字符串)。每个值都是一条记录(参见 contracts/contracts.md)。包含两条记录的完整示例如 examples/registry.sample.json 所示。
flowchart TB
subgraph file["knowerage/registry.json"]
O["Top-level JSON object"]
O --> K["Each key: analysis markdown path, e.g. knowerage/analysis/.../topic.md"]
K --> V["Value: one RegistryRecord"]
end
subgraph rec["RegistryRecord fields"]
ap["analysis_path · source_path"]
cr["covered_ranges: [[start,end], ...]"]
h["analysis_hash · source_hash (sha256:… )"]
t["record_created_at · record_updated_at (ISO 8601)"]
st["status: fresh | stale_doc | stale_src | missing_src | dangling_doc"]
end
V --> rec分析 .md 文件的元数据在合同文档(元数据模式)中单独指定,而不是在 registry.json 内部。
MCP 工具
工具 | 用途 |
| 创建/更新分析文档 |
| 解析并验证前置元数据 |
| 对账单条分析记录 |
| 全量重新扫描/重建 |
| 已分析 vs 缺失范围 |
| 列出陈旧/有问题的记录 |
| 完整注册表快照(与 |
| 树状/分组覆盖率 |
| 导出快照 (JSON/YAML/TXT/HTML) |
| 选定分析的分块导出 ( |
项目结构
knowerage/ # Created per-project
├── analysis/ # Analysis markdown files
│ └── **/*.md
└── registry.json # Coverage registry
src/ # Rust MCP server
├── main.rs
├── lib.rs
├── types.rs
├── parser.rs
├── registry.rs
├── mcp.rs
├── security.rs
└── export.rs文档
用户入门 — 设置、配置、典型用法
INSTRUCTIONS.md — MCP 智能体指令
合同 — 模式和 API 合同(注册表 + 前置元数据)
注册表 JSON 示例 —
registry.json内容示例
安全性
所有路径均针对工作区根目录进行验证
拒绝路径遍历 (
..)注册表原子写入(防崩溃)
分析文件或报告中不包含任何机密信息
基于 SHA-256 哈希的新鲜度检查(在 git pull 后依然有效)
许可证
MIT — 版权所有 Martins Timma。
本项目的部分内容由生成式 AI 编码助手编写或优化。设计、安全敏感行为和发布均经过人工审核。
Available Tools
11 toolsknowerage_coverage_overviewA
Batch coverage overview for all source files. Returns per-source coverage percentage, analyzed/missing ranges, range attribution, stale records, and project-wide file/line totals. Uses fresh records only for coverage calculation. Optional extensions filter applies to sources, stale list, and project scan.
Inputs: extensions.
knowerage_create_or_update_docA
PRIMARY tool for persisting legacy/source code analysis: create or update an analysis markdown file under knowerage/analysis/ with YAML frontmatter (source path, covered line ranges, dates). Use this whenever the user asks to analyze, document, or explain a source file and Knowerage is in the tool list—do not use generic file-write tools alone for knowerage analysis paths, or the registry will not stay consistent. Follow with knowerage_reconcile_record on the same analysis_path.
Inputs: analysis_path (required), content (required), covered_lines (required), source_path (required).
knowerage_generate_bundleA
Export selected analysis markdown files into chunked NotebookLM-style bundles under output_dir: writes toc.md + combined.md for part 1, toc_N.md + combined_N.md for further parts when size limits require splitting, plus manifest.json (files, errors, part metadata). Every analysis_paths entry is validated under the workspace (no traversal). Per-file and per-part size limits apply (see contracts).
Inputs: analysis_paths (required), output_dir (required).
knowerage_get_file_statusA
Per-source coverage: total lines, analyzed vs missing ranges, and which analysis paths claim them. Prefer this over guessing from open files when answering 'what is documented for this source?' while Knowerage is enabled.
Inputs: source_path (required).
knowerage_get_treeC
Get a tree view of analysis records grouped by directory
Inputs: group_by, root.
knowerage_list_registryA
Return the full analysis coverage registry in one structured JSON response. USE THIS when you need an inventory of which source files are documented, where the analysis markdown lives, which line ranges are claimed, and freshness (fresh/stale_doc/stale_src/missing_src/dangling_doc). The records object is the same shape as the entire knowerage/registry.json file (sorted keys for stable reading). Call early when planning documentation work, finding gaps, or mapping analysis paths to sources—instead of opening registry.json by hand. Optional filters: analysis_path_prefix narrows by analysis key; statuses limits to given status values (same strings as in each record). After reconcile_record/reconcile_all, call again if you need the latest snapshot.
Inputs: analysis_path_prefix, statuses.
knowerage_list_staleB
List registry records filtered by staleness status
Inputs: statuses.
knowerage_parse_doc_metadataB
Parse YAML frontmatter from an analysis markdown file
Inputs: analysis_path (required).
knowerage_reconcile_allA
Rescan all analysis markdown files matching the glob and rebuild registry entries. Use after git pull, bulk edits, or when the registry may be empty or out of date; prefer reconcile_record when only one file changed.
Inputs: analysis_glob.
knowerage_reconcile_recordA
MANDATORY after every create_or_update_doc (or manual edit) to one analysis file: reconciles that analysis into knowerage/registry.json (hashes, covered_ranges, freshness). Call immediately after writing analysis content so coverage is recorded; skipping this leaves the registry wrong or stale.
Inputs: analysis_path (required).
registry_export_reportB
Export the registry as a report file in json, yaml, txt, or html format
Inputs: format (required), output_path (required).
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 11 tools
Each tool targets a distinct operation: coverage overview per batch, per-source status, registry listing with filters, doc creation/update, reconciliation, bundle generation, tree view, metadata parsing, stale listing, and export. Even overlapping tools like list_registry and list_stale are clearly differentiated by filters and purpose.
All tools use the 'knowerage_' prefix except for 'registry_export_report', which breaks the pattern. Within the prefixed group, naming follows a consistent verb_noun style (e.g., get_file_status, create_or_update_doc, reconcile_record). The one outlier lowers the score.
With 11 tools, the server covers the core operations of a documentation coverage system (CRUD-like, reconciliation, reporting, exploration) without being excessive. Each tool serves a clear purpose and none feel redundant.
The tool surface covers creation/update, reconciliation (single and bulk), listing, coverage overview, bundle generation, metadata parsing, and export. Missing a direct delete tool for docs, but the create_or_update tool may handle updates. Overall, agents can perform most tasks without dead ends.
Related MCP Connectors
MCP Server for an Agent Task Marketplace
MCP server for querying Forkast documentation
Repository knowledge graph MCP server for codebase understanding and debugging.
Related MCP Servers
- AlicenseBqualityNot gradedmaintenanceMCP server for collecting code from files and directories into a single markdown document.28MIT
- AlicenseNot gradedqualityCmaintenanceLocal-first MCP server for querying multi-repo engineering documentation artifacts from a SQLite corpus.5 npmAGPL 3.0
- AlicenseNot gradedqualityCmaintenanceLocal-first MCP server that provides project context, verification gates, and structured tools for coding agents to discover knowledge, run diagnostics, and execute allowlisted commands within a repository.MIT
- FlicenseNot gradedqualityDmaintenanceLocal MCP server that indexes documentation from URLs/files into a vector database, enabling coding agents to search and use up-to-date library and API documentation.1-