LeanKG

LeanKG

LeanKG: Stop Burning Tokens. Start Coding Lean.

Category
访问服务器

README

<p align="center"> <img src="https://www.leankg.com/icon.svg" alt="LeanKG" width="80" height="80"> </p>

LeanKG

License: MIT Rust crates.io

Lightweight Knowledge Graph for AI-Assisted Development

LeanKG is a local-first knowledge graph that gives AI coding tools accurate codebase context. It indexes your code, builds dependency graphs, and exposes an MCP server so tools like Cursor, OpenCode, and Claude Code can query the knowledge graph directly. No cloud services, no external databases.

Visualize your knowledge graph with force-directed layout, WebGL rendering, and community clustering.

LeanKG Graph Visualization LeanKG Obsidian

See docs/web-ui.md for more features.


Live Demo

Try LeanKG without installing: https://leankg.onrender.com

leankg web --port 9000

Installation

One-Line Install (Recommended)

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

Supported targets:

Target AI Tool Auto-Installed
opencode OpenCode AI Binary + MCP + Plugin + Skill + AGENTS.md
cursor Cursor AI Binary + MCP + Skill + AGENTS.md + Session Hook
claude Claude Code Binary + MCP + Plugin + Skill + CLAUDE.md + Session Hook
gemini Gemini CLI Binary + MCP + Skill + GEMINI.md
kilo Kilo Code Binary + MCP + Skill + AGENTS.md
antigravity Google Antigravity Binary + MCP + Skill + GEMINI.md

Examples:

curl -fsSL https://raw.githubusercontent.com/FreePeak/LeanKG/main/scripts/install.sh | bash -s -- cursor
curl -fsSL https://raw.githubusercontent.com/FreePeak/LeanKG/main/scripts/install.sh | bash -s -- claude

Install via Cargo or Build from Source

cargo install leankg && leankg --version
git clone https://github.com/FreePeak/LeanKG.git && cd LeanKG && cargo build --release

Quick Start

leankg init                              # Initialize LeanKG in your project
leankg index ./src                        # Index your codebase
leankg watch ./src                        # Auto-index on file changes
leankg impact src/main.rs --depth 3       # Calculate blast radius
leankg status                             # Check index status
leankg metrics                            # View token savings
leankg web                                # Start Web UI at http://localhost:8080

See docs/cli-reference.md for all commands.


How LeanKG Helps

graph LR
    subgraph "Without LeanKG"
        A1[AI Tool] -->|Scans entire codebase| B1[10,000+ tokens]
        B1 --> A1
    end

    subgraph "With LeanKG"
        A2[AI Tool] -->|13-42 tokens| C[LeanKG Graph]
        C -->|Targeted subgraph| A2
    end

Without LeanKG: AI scans entire codebase (~10,000+ tokens). With LeanKG: AI queries knowledge graph for targeted context (13-42 tokens). 98% token saving for impact analysis.


Highlights

  • Auto-Init -- Install script configures MCP, rules, skills, and hooks automatically
  • Auto-Trigger -- Session hooks inject LeanKG context into every AI tool session
  • Token Concise -- 13-42 tokens per query vs 10,000+ for full codebase scan
  • Token Saving -- Up to 98% token reduction for impact analysis
  • Impact Radius -- Compute blast radius before making changes
  • Dependency Graph -- Build call graphs with IMPORTS, CALLS, TESTED_BY edges
  • MCP Server -- Expose graph via MCP protocol for AI tool integration
  • Multi-Language -- Index Go, TypeScript, Python, Rust, Java, Kotlin with tree-sitter

See docs/architecture.md for system design and data model details.


Supported AI Tools

Tool Auto-Setup Session Hook Plugin
Cursor Yes session-start -
Claude Code Yes session-start Yes
OpenCode Yes - Yes
Kilo Code Yes - -
Gemini CLI Yes - -
Google Antigravity Yes - -
Codex Yes - -

Note: Cursor requires per-project installation. The AI features work on a per-workspace basis, so LeanKG should be installed in each project directory where you want AI context injection.

See docs/agentic-instructions.md for detailed setup and auto-trigger behavior.


Context Metrics

Track token savings to understand LeanKG's efficiency.

leankg metrics --json              # View with JSON output
leankg metrics --since 7d           # Filter by time
leankg metrics --tool search_code   # Filter by tool

See docs/metrics.md for schema and examples.


Update

# Check current version
leankg version

# Update LeanKG binary via install script
curl -fsSL https://raw.githubusercontent.com/FreePeak/LeanKG/main/scripts/install.sh | bash -s -- update

Documentation

Doc Description
docs/cli-reference.md All CLI commands
docs/mcp-tools.md MCP tools reference
docs/agentic-instructions.md AI tool setup & auto-trigger
docs/architecture.md System design, data model
docs/web-ui.md Web UI features
docs/metrics.md Metrics schema & examples
docs/benchmark.md Performance benchmarks
docs/roadmap.md Feature planning
docs/tech-stack.md Tech stack & structure

Requirements

  • Rust 1.70+
  • macOS or Linux

License

MIT


Star History

<a href="https://www.star-history.com/?repos=FreePeak%2FLeanKG&type=date&legend=top-left"> <picture> <source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/chart?repos=FreePeak/LeanKG&type=date&theme=dark&legend=top-left" /> <source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/chart?repos=FreePeak/LeanKG&type=date&legend=top-left" /> <img alt="Star History Chart" src="https://api.star-history.com/chart?repos=FreePeak/LeanKG&type=date&legend=top-left" /> </picture> </a>

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选