First off, thank you for considering contributing to LeanKG! It’s people like you who make LeanKG a powerful tool for the AI-assisted development ecosystem.
As a project focused on Lightweight Knowledge Graphs for AI, we value contributions that improve indexing accuracy, reduce token overhead, and expand MCP capabilities.
- Language: Rust (Latest Stable)
- Database: CozoDB (Graph engine)
- Parsers: tree-sitter (for Go, Rust, TS, Python, etc.)
- Protocol: Model Context Protocol (MCP)
Clone the repository and ensure you have the Rust toolchain installed:
git clone https://github.com/FreePeak/LeanKG.git
cd LeanKG
cargo buildWe use a Makefile to simplify common development tasks:
- Run tests:
cargo test - Build release:
cargo build --release - Local MCP Testing: Use the
mcp-stdiocommand to test changes with your local AI tools (Cursor, Claude Code, etc.).
/src: Core logic, graph schema, and indexing engine./npm-package: Wrappers for distribution./examples: Sample codebases used for benchmarking./instructions: Agent-specific instructions (CLAUDE.md,AGENTS.md).
LeanKG uses tree-sitter for parsing. If you want to add a new language:
- Add the corresponding tree-sitter dependency in
Cargo.toml. - Implement the parser logic in
src/indexer/. - Define how code elements (functions, classes, imports) map to the graph schema.
We are constantly expanding the tools available to AI agents. If you have an idea for a new tool (e.g., get_complexity_score or find_dead_code):
- Define the tool in the MCP server module.
- Ensure the output is token-optimized (we aim for high signal-to-noise ratios).
Performance is a core feature. If you contribute a feature, please run the benchmarks in the benchmark/ folder to ensure no significant regression in indexing speed or token usage.
- Check Issues: Look for existing issues or create a new one to discuss your idea.
- Branching: Create a feature branch (
feat/your-featureorfix/your-fix). - Commit Messages: We follow Conventional Commits (e.g.,
feat: add support for Ruby,fix: handle circular dependencies). - Documentation: If you add a new CLI command or MCP tool, update the
README.mdand the relevant agent instruction files in/instructions. - Review: Once submitted, a maintainer will review your code. We prioritize performance, code safety (it is Rust, after all!), and documentation.
Since LeanKG is built for AI agents:
- Feel free to use LeanKG itself while developing!
- If you find that an AI agent (like Claude or Cursor) struggles to understand a part of this repo, please submit a PR to improve our
CLAUDE.mdorAGENTS.mdinstructions.
By contributing, you agree that your contributions will be licensed under the MIT License.
- Keep it Lean: Every byte of data sent via MCP costs tokens. Always look for ways to compress the graph context.
- Stay Local-First: We avoid cloud dependencies. Any new feature should work entirely on the user's local machine.