TL;DR: Copy-paste one command and you're done.
Run this for your AI tool:
# For Cursor
curl -fsSL https://raw.githubusercontent.com/FreePeak/LeanKG/main/scripts/install.sh | bash -s -- cursor
# For Claude Code
curl -fsSL https://raw.githubusercontent.com/FreePeak/LeanKG/main/scripts/install.sh | bash -s -- claude
# For OpenCode
curl -fsSL https://raw.githubusercontent.com/FreePeak/LeanKG/main/scripts/install.sh | bash -s -- opencodeThat's it. The script does everything: installs binary, configures MCP, sets up hooks.
Already installed via script above? Restart your AI tool and skip to Verify.
1. Find your AI tool's MCP config location:
| Tool | Config File |
|---|---|
| Cursor | ~/.cursor/mcp.json or .cursor/mcp.json in project |
| Claude Code | ~/.claude/settings.json |
| OpenCode | .opencode.json in project |
2. Add this to your config:
{
"mcpServers": {
"leankg": {
"command": "leankg",
"args": ["mcp-stdio", "--watch", "."]
}
}
}3. Restart your AI tool or run /reload
Use this if you want remote access or multiple tools sharing the same LeanKG instance.
leankg mcp-http --port 9699Cursor:
{
"mcpServers": {
"leankg": {
"url": "http://localhost:9699/mcp"
}
}
}Claude Code (~/.claude/settings.json):
{
"mcpServers": {
"leankg": {
"url": "http://localhost:9699/mcp"
}
}
}OpenCode (.opencode.json):
{
"plugins": ["leankg"],
"leankg": {
"transport": "http",
"url": "http://localhost:9699/mcp"
}
}Ask your AI tool:
"What's the status of leankg?"
You should see something like:
initialized: true,
elements: 1234,
relationships: 5678,
If LeanKG uses too much memory, add this to your ~/.zshrc or ~/.bashrc:
export LEANKG_MMAP_SIZE=134217728
export LEANKG_CACHE_MAX_TOKENS=100000Then restart your terminal.
# Kill all LeanKG processes
pkill -9 -f leankg
# Remove config files
rm ~/.cursor/mcp.json
rm ~/.claude/settings.json
rm .opencode.json
rm -rf .leankg| What | Command |
|---|---|
| Start stdio mode | leankg mcp-stdio |
| Start HTTP mode | leankg mcp-http --port 9699 |
| Check status | leankg status |
| Reindex | leankg mcp-index |
| Kill all | pkill -9 -f leankg |
"command not found: leankg"
curl -fsSL https://raw.githubusercontent.com/FreePeak/LeanKG/main/scripts/install.sh | bash -s -- opencode"database is locked"
pkill -9 -f leankg
pkill -9 -f vite
leankg mcp-stdio"connection refused" (HTTP mode)
# Check if server is running
lsof -i :9699
# If not, start it
leankg mcp-http --port 9699If you're an AI agent setting up LeanKG for a user:
# 1. Run the install script
curl -fsSL https://raw.githubusercontent.com/FreePeak/LeanKG/main/scripts/install.sh | bash -s -- opencode
# 2. Initialize in the project
cd <project-path>
leankg init
leankg index ./src
# 3. Tell user to restart their AI toolThe install script automatically:
- Installs the
leankgbinary - Creates MCP config for stdio transport
- Sets up instructions for AI context
- Configures session hooks (Claude Code only)