MCP Catalogs
首页LeanKG screenshot

LeanKG

by FreePeak·188·综合分 50

LeanKG 是一个轻量级知识图谱,通过索引代码库并通过 MCP 暴露给 AI 开发工具,显著减少 token 消耗。

developer-toolsai-llmknowledge-graph
18
Forks
3
活跃 Issue
本月
最近提交
2 天前
收录于

概述

LeanKG 是一个基于 Rust 的本地知识图谱,专为 AI 编程工具提供准确的代码库上下文。它索引代码文件,构建依赖关系图,并通过 MCP 服务器使 AI 工具(如 Cursor、OpenCode 和 Claude Code)能够直接查询知识图谱。系统提供影响半径计算、依赖关系图可视化、令牌优化和多语言支持等功能。与基于云的解决方案不同,LeanKG 本地运行,无需外部数据库依赖,解决了 AI 工具处理完整代码库上下文时的高 token 消耗问题。

试试问 AI

装完之后,这里有 7 个你可以让 AI 做的事:

:AI 辅助代码分析,通过定位特定代码子图减少 token 消耗
:修改代码前计算影响半径
:大型代码库中的代码依赖关系可视化和社区检测
:基于注释的代码搜索和可追溯性分析
:LeanKG 支持哪些 AI 工具?
:LeanKG 如何减少 token 消耗?
:LeanKG 是基于云的吗?

什么时候选它

当您需要一个本地自托管知识图谱来提高 AI 编程工具在代码库上下文中的准确性,且不希望依赖云服务时,选择 LeanKG。

什么时候不要选它

如果您需要基于云的协作功能或需要写入知识图谱的权限,不要选择 LeanKG,因为它主要是一个只读系统。

此 server 暴露的工具

从 README 抽取出 12 个工具
  • search_code

    Search for code patterns or specific implementations in the knowledge graph

  • find_dependencies

    Find dependencies between code elements and analyze impact radius

  • get_element_info

    Retrieve detailed information about a specific code element

  • detect_clusters

    Identify functional code communities and clusters in the codebase

  • trace_feature

    Trace feature implementation across the codebase

  • annotate_code

    Add annotations to code elements for better context

  • export_graph

    Export the knowledge graph in various formats

  • analyze_quality

    Analyze code quality and find oversized functions

  • get_metrics

    View token savings and context reduction metrics

  • detect_changes

    Detect changes in codebase and classify risk level

  • run_command

    Execute shell commands with RTK compression to save tokens

  • register_repo

    Register a new repository for multi-repo context management

可对比工具

sourcegraphcodegraphsemgrepswimm

安装

安装

一键安装(推荐)

curl -fsSL https://raw.githubusercontent.com/FreePeak/LeanKG/main/scripts/install.sh | bash -s -- <target>

支持的目标包括:cursorclaudeopencodekiloantigravitygeminicodex

通过 Cargo 安装

cargo install leankg && leankg --version

Claude Code 集成

# 安装 Claude Code 钩子
leankg setup
# 重启 Claude Code 或运行:
/reload-plugins

配置

LeanKG 在设置过程中创建 MCP 配置。手动设置请参阅 docs/mcp-tools.md 了解 MCP 服务器配置。

FAQ

LeanKG 支持哪些 AI 工具?
LeanKG 支持 Cursor、Claude Code、OpenCode、Kilo Code、Gemini CLI、Google Antigravity 和 Codex,集成程度包括自动设置、会话钩子和插件。
LeanKG 如何减少 token 消耗?
LeanKG 构建知识图谱,使 AI 工具可以查询特定子图,而不是处理完整代码库上下文,将 token 消耗从 15,000-45,000 减少到相关代码。
LeanKG 是基于云的吗?
不是,LeanKG 是本地优先的解决方案,完全在您的机器上运行,无需云服务或外部数据库依赖。

LeanKG 对比

GitHub →

最后更新于 · 由 README + GitHub 公开数据自动生成。