loading…
Search for a command to run...
loading…
Knot is a semantic and structural codebase indexer designed for AI coding agents and developers navigating large projects. It combines vector search and graph t
Knot is a semantic and structural codebase indexer designed for AI coding agents and developers navigating large projects. It combines vector search and graph traversal to find code by meaning, analyze impact via reverse dependencies, and explore file architectures.
License: MIT Rust knot MCP server
knot is a high-performance codebase indexer that extracts structural and semantic information from source code, enabling AI agents to understand, analyze, and navigate large code repositories. Currently supports Java, Kotlin (v0.7.4+), TypeScript, JavaScript/Node.js, Rust (v0.8.x), Python (v0.9.3), HTML, and CSS/SCSS with full cross-language linking, with planned support for Groovy and C/C++.
The indexer automatically builds:
This dual-database approach powers both:
knot command for terminal and scripting environments🔍 Code Intelligence Tools
search_hybrid_context: Semantic + structural search. Find code by meaning, class name, method signature, docstrings, or comments. Returns full context including dependencies.find_callers: Reverse dependency lookup. Identify dead code, perform impact analysis, or understand the full call chain of any function/method. When multiple entities share the same name (e.g., find_nearest_entity_by_line in different files), results are automatically grouped by target showing which specific entity each caller references.explore_file: File anatomy inspection. Quickly see all classes, interfaces, methods, and functions in a file with signatures and documentation.🏗️ Multi-Language Support
.js, .mjs, .cjs, .jsx)id and class attribute indexing for cross-language CSS searchid and className from React components for unified HTML/CSS discoveryvec![], println!(), assert!(), etc.) with intelligent string literal filtering and comprehensive edge case handling. NEW in v0.8.11: O(N) nested macro traversal optimization for large Rust codebases with deeply nested token_tree nodes.ValueReference tracking for keyword arguments, class inheritance (EXTENDS), decorator extraction (@property, @staticmethod, @route(...), @dataclass), generic type hints (List[str], Optional[Dict], *args/**kwargs), Py2/Py3 exception syntax compatibility, and self.method() resolution with inherited method walking. Captures class_definition, function_definition (including async via optional async modifier), lambda assignments, and distinguishes methods from functions via parent context detection.📚 Rich Comment Extraction
📊 Dual-Database Architecture
🚀 High Performance
--watch| Component | Version | Notes |
|---|---|---|
| Docker | 20.10+ | For running Qdrant and Neo4j |
| qdrant | 1.x | Vector database (docker) |
| neo4j | 5.x | Graph database (docker) |
Go to the Releases page and download the native executable for your platform.
Install knot binaries (CLI, MCP server, and indexer):
curl --proto '=https' --tlsv1.2 -LsSf https://github.com/raultov/knot/releases/latest/download/knot-installer.sh | sh
Download agent-skills guides separately (optional):
curl -sO https://raw.githubusercontent.com/raultov/knot/master/.knot-agent.md && curl -fsSL https://raw.githubusercontent.com/raultov/knot/master/.knot-agent-skills.tar.gz | tar -xz
The first command installs the knot binary to your PATH. The second (optional) downloads the agent skill index (.knot-agent.md) and extracts comprehensive guides for using knot CLI with AI agents and code analysis tools.
Linux Requirements:
For older Linux distributions or Windows, see the Lightweight Clients section below or use Docker (Option B).
Docker images provide universal compatibility for any Linux distribution and Windows.
Build the image:
docker build -t knot:latest . --network=host
Run the indexer:
# Use --network host to connect to databases running on your host machine
docker run --rm \
-v /path/to/your/repo:/workspace \
-e KNOT_REPO_PATH=/workspace \
-e KNOT_NEO4J_PASSWORD=your-password \
--network host \
knot:latest \
knot-indexer
Run the CLI tool:
docker run --rm \
-v /path/to/your/repo:/workspace \
-e KNOT_REPO_PATH=/workspace \
-e KNOT_NEO4J_PASSWORD=your-password \
--network host \
knot:latest \
knot search "user login flow"
Run the MCP server:
docker run --rm \
-e KNOT_REPO_PATH=/workspace \
-e KNOT_NEO4J_PASSWORD=your-password \
--network host \
knot:latest \
knot-mcp
Note: Uses Debian Trixie (glibc 2.38+) and includes ONNX Runtime for full functionality.
For older systems (Debian 12 Bookworm, Ubuntu 22.04) or production deployments that only need to query existing indexes without indexing new code:
Build the lightweight image:
docker build -t knot:clients -f Dockerfile.clients . --network=host
Image size: ~100MB (vs ~160MB for full install)
Run the CLI tool (query existing index):
docker run --rm \
--network host \
knot:clients \
knot callers "MyClass"
Run the MCP server:
docker run --rm \
--network host \
knot:clients \
knot-mcp
Available tools in lightweight mode:
knot search (structural only, no semantic search)knot callers (reverse dependency lookup)knot explore (file structure inspection)Note: Uses Debian Bookworm (glibc 2.35+) and excludes ONNX Runtime, making it compatible with older Linux distributions.
cargo install --git https://github.com/raultov/knot
Full Install (All Binaries):
1. Start infrastructure with Docker:
docker compose up -d
2. Clone and build:
git clone https://github.com/raultov/knot
cd knot
cargo build --release
3. Configure:
cp .env.example .env
$EDITOR .env # Set KNOT_REPO_PATH and Neo4j credentials
4. Index a codebase:
./target/release/knot-indexer
5. Query via CLI:
./target/release/knot search "your query"
For older Linux distributions (e.g. Debian 12 Bookworm, Ubuntu 22.04) or production deployments where you only need the CLI and MCP server (not the indexer), compile without the embedding dependencies:
Build lightweight clients:
cargo build --release --no-default-features --features only-clients
This produces only knot and knot-mcp binaries (~8-10 MB each), excluding the 30+ MB of ONNX Runtime dependencies.
Available tools in lightweight mode:
find_callers: Reverse dependency lookup (graph search). Automatically groups results by target when multiple entities share the same name.explore_file: File structure inspectionsearch_hybrid_context: Semantic search (requires embeddings, not available in this mode)Use case: Query an existing Qdrant + Neo4j index that was built elsewhere, without needing the indexer on your machine.
Docker alternative (for lightweight mode):
docker build -t knot:clients-only -f Dockerfile -f - . << 'EOF'
FROM rust:1.90-slim-bookworm AS builder
WORKDIR /build
COPY . .
RUN cargo build --release --no-default-features --features only-clients
FROM debian:bookworm-slim
COPY --from=builder /build/target/release/knot* /usr/local/bin/
CMD ["knot-mcp"]
EOF
6. Start the MCP server:
./target/release/knot-mcp
Download knot binaries (CLI + MCP server):
curl --proto '=https' --tlsv1.2 -LsSf https://github.com/raultov/knot/releases/latest/download/knot-installer.sh | sh
Download agent-skills documentation (index + all guides):
curl -sO https://raw.githubusercontent.com/raultov/knot/master/.knot-agent.md && curl -fsSL https://raw.githubusercontent.com/raultov/knot/master/.knot-agent-skills.tar.gz | tar -xz
Comprehensive documentation for using knot tools. The download above extracts:
For quick reference without downloading, see .knot-agent.md.
The knot CLI provides the same capabilities as the MCP server via command-line commands, making it ideal for:
Three main commands:
knot search — Semantic Code Searchknot search "user authentication" --max-results 10 --repo my-app
Find code entities by meaning, class names, docstrings, or comments.
knot callers — Reverse Dependency Lookupknot callers "LoginService" --repo my-app
Find all code that references a specific entity (dead code detection, impact analysis, call chains). When multiple entities share the same name in different files, results are automatically grouped by target with file locations and signatures.
knot explore — File Structure Inspectionknot explore "src/services/auth.ts" --repo my-app
List all classes, methods, functions in a file with signatures and documentation.
For detailed CLI usage guide, see .knot-agent.md — a machine-readable skill that teaches LLMs how to use knot CLI for autonomous code analysis.
# First run: indexes all files
knot-indexer --repo-path /path/to/your/repo --neo4j-password secret
# Subsequent runs: only re-indexes changed files (fast!)
knot-indexer --repo-path /path/to/your/repo --neo4j-password secret
# NEW: Real-time Watch mode (v0.5.2+)
knot-indexer --watch --repo-path /path/to/your/repo --neo4j-password secret
How it works:
.knot/index_state.jsonPerformance:
# Force complete re-index (deletes all existing data)
knot-indexer --clean --repo-path /path/to/your/repo --neo4j-password secret
Use --clean when:
To ensure indexer stability, run the E2E integration test suite:
# Run all language E2E tests (Java, TS, JS, HTML, CSS, Kotlin, Rust)
./tests/run_e2e.sh
# Run only Kotlin E2E tests
./tests/run_kotlin_e2e.sh
# Run only Rust E2E tests
./tests/run_rust_e2e.sh
See tests/KOTLIN_E2E_TESTS.md for detailed coverage and troubleshooting.
The MCP server exposes three tools to any compatible AI client:
search_hybrid_contextFind code by meaning or keywords
Query: "How is user authentication implemented?"
Result: All auth-related code, signatures, docstrings, and dependencies
Capabilities:
find_callersFind who calls a specific function
Query: "Find callers of getCurrentTimeInSeconds"
Result: All code that invokes this function + file locations
Advanced: Search by Signature (NEW in v0.7.4)
# Find by full signature (Java)
echo '{"method":"tools/call","params":{"name":"find_callers","arguments":{"entity_name":"registerUser(String"}}}' | knot-mcp
# Find by parameter type (Kotlin)
echo '{"method":"tools/call","params":{"name":"find_callers","arguments":{"entity_name":"findById(Int"}}}' | knot-mcp
# Find by type annotation (TypeScript)
echo '{"method":"tools/call","params":{"name":"find_callers","arguments":{"entity_name":"(EventData"}}}' | knot-mcp
Use Cases:
explore_fileUnderstand file structure
Query: "What's in BrowserService.ts?"
Result: All classes, methods, and functions with signatures and docs
Use Cases:
knot works with any MCP-compatible AI client:
Add to claude_desktop_config.json:
{
"mcpServers": {
"knot": {
"command": "/absolute/path/to/knot/target/release/knot-mcp",
"env": {
"KNOT_REPO_PATH": "/path/to/indexed/repo",
"KNOT_QDRANT_URL": "http://localhost:6334",
"KNOT_NEO4J_URI": "bolt://localhost:7687",
"KNOT_NEO4J_USER": "neo4j",
"KNOT_NEO4J_PASSWORD": "your-password"
}
}
}
}
{
"mcpServers": {
"knot": {
"command": "/absolute/path/to/knot/target/release/knot-mcp",
"env": {
"KNOT_REPO_PATH": "/path/to/indexed/repo",
"KNOT_QDRANT_URL": "http://localhost:6334",
"KNOT_NEO4J_URI": "bolt://localhost:7687",
"KNOT_NEO4J_USER": "neo4j",
"KNOT_NEO4J_PASSWORD": "your-password"
}
}
}
}
Similar JSON configuration in your client's MCP configuration file.
All options can be set via environment variables (.env) or CLI flags. Environment variables take precedence.
.env Variable |
CLI Flag | Default | Description |
|---|---|---|---|
KNOT_REPO_PATH |
--repo-path |
(required) | Root directory of the repository to index |
KNOT_REPO_NAME |
--repo-name |
(auto-detected) | Repository name for multi-repo isolation (auto-detected from last path component) |
KNOT_QDRANT_URL |
--qdrant-url |
http://localhost:6334 |
Qdrant server URL |
KNOT_QDRANT_COLLECTION |
--qdrant-collection |
knot_entities |
Qdrant collection name |
KNOT_NEO4J_URI |
--neo4j-uri |
bolt://localhost:7687 |
Neo4j Bolt URI |
KNOT_NEO4J_USER |
--neo4j-user |
neo4j |
Neo4j username |
KNOT_NEO4J_PASSWORD |
--neo4j-password |
(required) | Neo4j password |
KNOT_EMBED_DIM |
--embed-dim |
384 |
Embedding vector dimension |
KNOT_BATCH_SIZE |
--batch-size |
64 |
Entities per batch |
KNOT_CLEAN |
--clean |
false |
Force full re-index (delete all existing data) |
KNOT_CUSTOM_CA_CERTS |
--custom-ca-certs |
(none) | Path to CA certificate bundle for corporate SSL proxies |
RUST_LOG |
(env only) | info |
Log level: trace, debug, info, warn, error |
The built-in extraction queries (queries/java.scm, queries/typescript.scm) can be overridden without recompiling:
KNOT_CUSTOM_QUERIES_PATH=/path/to/my/queries ./target/release/knot-indexer
Place java.scm and/or typescript.scm in your custom directory. Missing files fall back to built-in defaults.
In restricted corporate environments with SSL-inspecting proxies, you may need to provide a custom CA certificate bundle so that knot can download the embedding model from HuggingFace.
Via environment variable:
export KNOT_CUSTOM_CA_CERTS=/etc/ssl/certs/corporate-bundle.pem
./target/release/knot-indexer --repo-path /path/to/repo --neo4j-password secret
Via CLI flag:
./target/release/knot-indexer \
--custom-ca-certs /etc/ssl/certs/corporate-bundle.pem \
--repo-path /path/to/repo \
--neo4j-password secret
Via .env file:
echo "KNOT_CUSTOM_CA_CERTS=/etc/ssl/certs/corporate-bundle.pem" >> .env
./target/release/knot-indexer
This works for all three binaries: knot-indexer, knot-mcp, and knot.
Step 1: Index a Java project
./target/release/knot-indexer --repo-path /home/user/my-java-app --neo4j-password secret
Step 2: Query via CLI (Instant search)
./target/release/knot search "authentication logic"
./target/release/knot callers "UserService.login"
Step 3: Start MCP server (For AI Agents)
./target/release/knot-mcp
Step 4: Use with Claude Desktop
knot includes a universal .prompt file in its root directory that automatically configures modern AI coding agents (Cursor, Cline, opencode, Claude, etc.) to use the knot-mcp tools correctly.
The directive explicitly instructs AI agents to prioritize:
search_hybrid_context — for semantic code discovery (instead of grep)find_callers — for reverse dependency analysis (instead of finding references manually)explore_file — for file structure inspection (instead of reading line-by-line)This ensures that when you ask an AI agent to analyze, refactor, or understand your code, it leverages the full power of the vector and graph databases rather than falling back to context-blind regex searches. The .prompt file is universal and tool-agnostic, working with any LLM client that reads codebase directives.
Contributions are welcome! Please ensure:
cargo clippycargo fmtThis project is licensed under the MIT License. See LICENSE for details.
PythonClass, PythonFunction, PythonMethodclass_definition, function_definition (top-level), lambda assignment capturesidentifier()) and method call (object.method()) resolution, print_statement (Py2) support. CALLS edges in the dependency graph.import os and from django.db import models detection via TypeReference. PythonConstant extraction (UPPER_CASE identifiers). PythonModule synthetic entity for module-level orphans.action=EnumAction patterns via keyword_argument detection. Creates REFERENCES edges for classes/functions used as argument values.EXTENDS relationships from class inheritance (class Dog(Animal)). Decorator CALLS from @staticmethod, @property, @dataclass, @route(...). Decorator names exposed in explore_file output.List[str], Optional[Dict]), *args/**kwargs parameter extraction, Py2/Py3 exception syntax compatibility, 5 additional unit tests, 4 additional E2E tests.is_inside_class_body() parent walk distinguishes methods from functionsnc -z network checks with Neo4j-specific Docker health checks (docker inspect), eliminating Connection reset by peer errors. Added 5s sleep between test suites.-r filter flag was not correctly applied across Python/Rust/Kotlin searches.vec![], println!(), assert!(), format!(), etc.) are now correctly capturedmacro_rules! definitionstype Callback = fn(u32) -> u32)const and static mut declarations with type signaturesdoc_comment nodes in tree-sitter-rust)Callback now rank in top 5 search results when querying by namesrc/pipeline/parser/languages/rust.rs for better maintainability and mirroring existing language module architecture.uuid::Uuid) and unnecessary mut warning in Rust module tests.docs/agent-skills/ for on-demand loading.error for knot CLI (cleaner Markdown output).knot binary..knot-agent.md with signature-based search warnings.less -R -e with auto-exit at end of content--output flag supports table (default), json, and markdown--custom-ca-certs / KNOT_CUSTOM_CA_CERTS for corporate SSL-inspecting proxiestoken_tree nodes.rs files with tree-sitter-rust parser.groovy, .gradle, .jenkinsfile files.c, .cpp, .h, .hpp files.yaml, .tpl)For issues, feature requests, or discussions, please open a GitHub issue.
Добавь это в claude_desktop_config.json и перезапусти Claude Desktop.
{
"mcpServers": {
"knot": {
"command": "npx",
"args": []
}
}
}PRs, issues, code search, CI status
Database, auth and storage
Reference / test server with prompts, resources, and tools.
Secure file operations with configurable access controls.