kg
概览
作者提供的说明(英文原文)
Local knowledge graph memory MCP server for AI assistants.
PopNx MCP 的三大支柱
这三项永远不会合并成一个分数:意见、测量和人气是不同的东西。
- 用户评价i暂无评价评价功能将在后续阶段与账户功能一起开放
- 我们的基础检查i1 项中通过 1 项依据公开信息检查;尚未扫描代码
- 使用情况i非常新★ –
它能帮你做什么
我们还没有为它写通俗的介绍。下面是我们从注册中心读取到的事实。
- 连接方式: –
- 传输方式:
- 分类: 搜索与 AI 记忆
安装
选择你使用的 AI 应用,然后复制设置。
安装之前
- 基础检查:1 项中通过 1 项
- 在你的电脑上运行,拥有你的用户账户的权限(文件、网络、应用)。
- 注册中心没有列出需要填写的密钥。
作者没有在注册中心列出安装信息。请查看下方作者的 README。
它能做什么
它在你的电脑上运行;安装后,工具列表会显示在你的 AI 应用中。
基础检查i
我们检查的是任何人都能看到的信息;我们没有阅读代码。不适用的检查项不计入总数。 · 检查于 2026年11月9日
- ✓ 通过
作者与仓库一致
注册名称已通过 GitHub 账户 nnar1o 验证,该账户拥有此仓库
- … 尚未检查
仍在维护
我们还没有从 GitHub 读取这个仓库
- … 尚未检查
有许可证
我们还没有从 GitHub 读取这个仓库
- – 不适用
端点有响应
它在你的电脑上运行,没有互联网端点
- – 不适用
使用 OAuth 登录
在你的电脑上运行,改用本地设置
- … 尚未检查
工具描述中没有隐藏指令
它在你的电脑上运行;我们只能读取互联网端点的工具列表
与“搜索与 AI 记忆”中的其他服务器比较i
- 星标数多于此分类中其他 5759 个服务器的 0%
- 发布到注册中心的时间比此分类中其他 5759 个服务器的 28% 更新
- 基础检查结果等于或优于此分类中其他 5759 个服务器的 100%
与注册中心里这个分类中所有活跃的服务器比较。只有当发布者拥有该仓库时,星标数才计入。
常见问题
kg 安全吗?
它在 1 项适用的基础检查中通过了 1 项。我们没有阅读代码。在添加密钥或令牌之前,请先看看这个服务器要求哪些权限,并使用只具备所需权限的密钥。
它需要哪些密钥或代码?
注册中心没有列出必需的密钥,不过有些服务器会在首次使用时要求你登录。
它在我的电脑上运行还是在云端?
它在你的电脑上运行。你的 AI 应用会在需要时启动它,数据不会经过作者的服务器(除非它自己调用在线服务)。
它还在维护吗?
GitHub 仓库最后更新于–,最新版本(0.3.0)于3个月前进入注册中心。
哪些应用可以使用它?
支持 MCP 的应用,例如 Claude Desktop、Claude Code、Cursor 和 VS Code。
有什么可以替代它?
同一分类中有:Context7, Codebase Memory, Exa
替代选择
同一分类中其他作者的服务器,按星标数排序。
如何看卡片:↓ 每周下载量i★ GitHub 星标i三大支柱:评价 · 检查 · 使用情况i更新 = 最新版本发布到注册中心的时间i
Codebase Memory
Codebase knowledge graph for AI agents — 162 languages, sub-ms queries, 99% fewer tokens.
Exa
Connect AI agents to Exa for web search, content fetching, and multi-step research.
作者的 README
打开 README
按原文从作者的仓库复制。PopNx MCP 没有审查或背书其内容。HTML、图片和脚本已被移除。链接会离开本站。
kg - local knowledge graph for your AI assistants
Beta - APIs may still change and some bugs are still expected.
kg gives your AI assistant persistent, structured, editable project memory stored locally as a knowledge graph.
Instead of relying only on document chunk retrieval, you can keep architecture, decisions, incidents, rules, dependencies, and workflows in a graph that is readable, reviewable, and Git-friendly.
Use it when you want your assistant to understand an existing project across sessions — not start from zero every time.
Why use it
- Persistent memory — keep project knowledge between conversations
- Structured, not fuzzy — inspect nodes, edges, facts, and gaps directly
- Editable and reviewable — store graphs as
*.kgfiles with readable diffs - Local-first — your project memory stays on your machine in git-friendly format
- Works with MCP clients — connect it as a local stdio MCP server
Why not just RAG
Classic RAG is good for retrieving text chunks from documents.
kg-mcp is better when you want:
- stable project memory instead of repeated retrieval
- explicit facts, relations, and dependencies
- graph updates during real work with the assistant
- something you can inspect, version, diff, and improve over time
Installation
From crates.io
cargo install kg-cli
From script
Recommended install:
curl -sSL https://raw.githubusercontent.com/nnar1o/kg/master/install.sh | sh
You can also download a ready binary from GitHub Releases.
Connect kg-mcp to Your AI Client
Add kg-mcp as a local stdio MCP server.
Example config:
{
"mcpServers": { "kg": { "command": "/absolute/path/to/kg-mcp" } } }
After that:
- restart your AI client,
- confirm the
kgMCP server is available, - start using the prompts below.
Full MCP setup and reference: docs/mcp.md
SCL quickstart
kg understands short, verb-first English commands (SCL — Simple Command Language). The active graph is resolved from your config automatically.
find "compressor defrost"
get concept:refrigerator add concept:smart_fridge --name "Smart Fridge" --description "Connected refrigerator" modify concept:smart_fridge --importance 0.9 remove concept:old_idea connect process:compressor_control TRIGGERS process:auto_defrost disconnect process:compressor_control TRIGGERS process:auto_defrost list nodes stats use fridge help
Core verbs
| Verb | What it does | ||||
|---|---|---|---|---|---|
find | search nodes by text | ||||
get | fetch one node by id | ||||
add --name "Name" | create a node (type inferred from id prefix) | ||||
modify --field value | update node fields | ||||
remove | delete a node | ||||
connect | create an edge (alias: add edge) | ||||
disconnect | delete an edge (alias: remove edge) | ||||
| `list nodes\ | edges\ | types\ | relations\ | graphs` | list graph contents |
stats | show graph statistics | ||||
use | switch active graph | ||||
help [verb] | get help for a verb or all | ||||
| `feedback yes\ | no\ | nil\ | pick ` | give feedback on search results | |
strict | disable defaults for following lines |
IDs
Format: :snake_case — e.g. concept:fridge, bug:door_seal, process:compressor_cycle.
Relations
HAS USES STORED_IN TRIGGERS CREATED_BY AFFECTED_BY AVAILABLE_IN DOCUMENTED_IN DEPENDS_ON TRANSITIONS DECIDED_BY GOVERNED_BY READS_FROM
Tips
- Flags go after positional args. Quote multiword values.
- Separate commands with
;or newlines. Lines starting with#are comments. - Use
useto switch graphs within a script. - Canonical
kg node find ...commands still work as fallback. - Full SCL reference:
docs/scl.md
Generate a Graph
This is the first workflow for a new project: ask the assistant to create or extend a graph from your documentation.
By default, graphs are stored in ~/.kg/graphs as *.kg files.
Minimal prompt:
You are connected to kg-mcp.
Project graph name: payments
Build or extend this graph from the project documentation I provide. Use payments as the graph name for all graph operations.
Only add facts grounded in source material. If an important fact is missing and can be inferred safely from the provided docs, update the graph. If something is ambiguous, ask or record it as a note instead of inventing facts.
Example prompt with documents:
Use kg-mcp to build or extend the `payments` graph from these documents:
- docs/payments/overview.md
- docs/payments/retries.md
- docs/payments/providers.md
Only add facts grounded in the documents. If something is ambiguous, keep it out of the graph or record it as a note. When you finish, summarize what was added, what remains unclear, and what document should be ingested next.
Longer prompt for this workflow: docs/ai-prompt-graph-from-docs.md
For a ready-made repository example, run cargo run --bin repo-example to generate repo-example.kg from this repo.
Automatic graph for a directory
kg can turn an existing folder into a graph automatically. It scans the directory tree, recognizes many common file types, extracts symbols for Rust, Java, JavaScript/TypeScript, Python, and C/C++, and keeps the generated structure separate from the manual graph.
For markdown-like documents, it also creates document (GDOC) and chapter (GSEC) nodes with section content.
It is a fast way to get a useful map of a codebase or workspace without modeling everything by hand. The generated index is local, refreshable, and safe to ignore in git.
Example:
cargo run --bin repo-example
This generates repo-example.kg from this repository as a local demo.
Ask the Assistant About Facts in the Graph
Once the graph exists, the normal workflow is to ask the assistant to inspect it and answer questions from it.
Example prompt:
Use kg-mcp to inspect my existing `payments` graph.
I want to understand:
- how payment authorization works,
- what triggers retries,
- which external providers are involved,
- which datastore reads and writes are part of the flow.
If the graph is missing critical information, say exactly what is missing.
Other useful questions:
- "What rules control retries in the
paymentsgraph?" - "Which systems write to the orders datastore?"
- "What is missing or weak in this graph?"
- "Which nodes and edges explain the authorization flow?"
Add or Update Facts Through the Assistant
You can also ask the assistant to improve the graph while you work.
Example prompt:
Use kg-mcp to review my existing `payments` graph.
Find:
- missing important nodes,
- weak descriptions,
- missing facts,
- suspicious or low-value edges.
Apply safe improvements where possible. Only add facts grounded in the graph, the provided docs, or the current discussion. If something is ambiguous, leave it out or add a note.
When you finish, summarize:
- what was wrong,
- what you changed,
- what still needs manual review.
This works best when your main system prompt or project prompt already tells the assistant which graph belongs to the project.
Minimal project-level prompt:
You are connected to kg-mcp.
Project graph name: payments. Use this graph for relevant reads and updates in this project. If you notice important missing information that is grounded in the available docs or conversation context, update the graph as part of your work. If uncertain, ask or add a note instead of inventing facts.
Tips
Project config (.kg.toml)
kg looks for .kg.toml in the current directory and its parent directories.
Example:
backend = "json" # json backend writes native .kg files by default
graph_dir = ".kg/graphs" graph_dirs = ["../shared-graphs", "../team-graphs"] nudge = 20 user_short_uid = "dev_01"
[graphs] payments = "graphs/payments.kg"
Notes:
backend = "json"is the default and prefers.kgtext graphs.backend = "redb"stores graphs in.dbfiles.graph_dirsets a primary graph directory.graph_dirsadds extra directories scanned bykg listand graph resolution.
Keep Graphs in Git
The default graph directory is ~/.kg/graphs.
You can put that directory under git.
Recommended approach:
- keep the main
*.kggraph files in git, - ignore generated sidecars and local operational files,
- treat backup snapshots and event logs as local machine history unless you explicitly want to version them.
Suggested .gitignore:
*.kglog
*.kgindex *.event.log *.migration.log *.bak *.bck.*.gz
In practice:
*.kgis the main graph file you usually want to review and commit,*.kglogis a local access/feedback log,*.kgindexis a generated local index,*.event.logis a local append-only change timeline,*.bakis the previous on-disk version from the last write,*.bck.*.gzare periodic compressed backup snapshots,*.migration.logis a migration report when older graphs are converted.
*.kg is git-friendly and intentionally structured to make diffs readable and merges easier when several people work on the same graph.
Export a Graph to HTML
To generate an interactive HTML view of a graph:
kg graph payments export-html --output payments.html
You can keep the generated HTML as a shareable visual snapshot of the current graph.
Documentation
docs/mcp.md- MCP setup and tool referencedocs/ai-prompt-graph-from-docs.md- longer prompt for document ingestiondocs/build-graph-from-docs.md- graph-building workflow from docsdocs/troubleshooting.md- common issues
Contact
For questions or feedback: nnar10@proton.me