MCP Catalogs
HomeLeanKG screenshot

LeanKG

by FreePeak·188·Score 50

LeanKG is a local-first knowledge graph that indexes codebases and exposes them via MCP for AI-assisted development with significant token savings.

developer-toolsai-llmknowledge-graph
18
Forks
3
Open issues
this month
Last commit
2d ago
Indexed

Overview

LeanKG is a Rust-based local knowledge graph designed to provide AI coding tools with accurate codebase context. It indexes code files, builds dependency graphs, and exposes an MCP server that allows AI tools like Cursor, OpenCode, and Claude Code to query the knowledge graph directly. The system offers features such as impact radius calculation, dependency graph visualization, token optimization, and multi-language support. Unlike cloud-based solutions, LeanKG operates locally without external database dependencies, addressing the high token consumption problem when AI tools process full codebase context.

Try asking AI

After installing, here are 7 things you can ask your AI assistant:

you:AI-assisted code analysis with reduced token consumption by targeting specific code subgraphs
you:Impact radius calculation before making code changes
you:Code dependency visualization and community detection in large codebases
you:Annotation-based code search and traceability
you:What AI tools does LeanKG support?
you:How does LeanKG reduce token consumption?
you:Is LeanKG cloud-based?

When to choose this

Choose LeanKG when you need a local, self-hosted knowledge graph to improve AI coding tools' accuracy with codebase context without cloud dependencies.

When NOT to choose this

Don't choose LeanKG if you need cloud-based collaboration features or require write access to the knowledge graph, as it's primarily a read-only system.

Tools this server exposes

12 tools extracted from the README
  • 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

Comparable tools

sourcegraphcodegraphsemgrepswimm

Installation

Installation

One-Line Install (Recommended)

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

Supported targets include: cursor, claude, opencode, kilo, antigravity, gemini, codex

Install via Cargo

cargo install leankg && leankg --version

Claude Code Integration

# Install with Claude Code hooks
leankg setup
# Restart Claude Code or run:
/reload-plugins

Configuration

LeanKG creates MCP configuration during setup. For manual setup, see docs/mcp-tools.md for MCP server configuration.

FAQ

What AI tools does LeanKG support?
LeanKG supports Cursor, Claude Code, OpenCode, Kilo Code, Gemini CLI, Google Antigravity, and Codex with varying levels of integration including auto-setup, session hooks, and plugins.
How does LeanKG reduce token consumption?
Instead of processing full codebase context, LeanKG builds a knowledge graph that allows AI tools to query targeted subgraphs, reducing context tokens from 15,000-45,000 to focused relevant code.
Is LeanKG cloud-based?
No, LeanKG is a local-first solution that operates entirely on your machine without cloud services or external database dependencies.

Compare LeanKG with

GitHub →

Last updated · Auto-generated from public README + GitHub signals.