knot
knot is a read-only MCP server that lets an AI agent semantically search, trace dependencies in, and navigate indexed code repositories (vector + graph databases).
Search code by meaning (
search_hybrid_context): hybrid semantic + structural search across one, several, or all indexed repos, with filters for path, entity kinds, and detail level.Find reverse dependencies (
find_callers): see who calls, extends, implements, or references an entity — useful for impact analysis, dead-code detection, override/dispatch discovery, and overload resolution.Inspect file anatomy (
explore_file): list classes, methods, interfaces, constants, and docs in a specific file without reading it whole.Enumerate files (
list_files): list a repo's indexed files with entity counts, scoped by directory prefix or glob.Catalogue HTTP endpoints (
list_endpoints): view Java/Kotlin JAX-RS and Spring MVC routes with their handler methods.Explore cross-repo dependencies (
list_repo_dependencies): forward or reverse transitive dependency graphs via Maven, Gradle, Cargo, npm, and NuGet declarations.List indexed repositories (
list_repositories): see available codebases with build system, language, file, and entity counts, optionally name-filtered.All operations are read-only (no side effects) and accept flexible repo scoping (
name, comma list, orall/*); knot itself indexes many languages including Java, Kotlin, TypeScript, JavaScript, Rust, Python, C/C++, C#, Groovy, HTML/CSS, plus build systems, configs, Kubernetes/Helm, and Markdown docs.
Supports indexing and analysis of Angular web components through HTML parsing, enabling cross-language linking between JavaScript, HTML, and CSS for full-stack SPA analysis.
Provides CSS/SCSS stylesheet indexing with class/ID selector extraction and variable tracking, enabling unified HTML/CSS discovery and cross-language search capabilities.
Supports CommonJS TypeScript file analysis as part of complete TypeScript/TSX/CTS language support for modern JavaScript/TypeScript codebases.
Provides Docker-based deployment options for universal compatibility across platforms, including containerized execution of the indexer, CLI tool, and MCP server.
Supports configuration via .env files for setting repository paths and database credentials during codebase indexing and analysis.
Provides comprehensive JavaScript/Node.js analysis including vanilla JS, Node.js, and module systems (.js, .mjs, .cjs, .jsx) with full cross-language linking capabilities.
Provides complete Kotlin codebase analysis with support for classes, interfaces, objects, companion objects, functions, methods, and properties using tree-sitter-kotlin-ng grammar.
Uses Markdown for documentation and skill files, including .knot-agent.md for teaching LLMs how to use the CLI tool for autonomous code analysis.
Integrates with Neo4j graph database for storing architectural relationships via call graphs, enabling structural navigation and reverse dependency analysis.
Supports Node.js module systems and JavaScript analysis as part of the hybrid web ecosystem with cross-language linking capabilities.
Extracts id and className attributes from JSX/TSX React components for unified HTML/CSS discovery and cross-language analysis in web applications.
Provides complete TypeScript/TSX analysis including modern JavaScript/TypeScript codebases with full cross-language linking and architectural relationship extraction.
knot
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, TypeScript, JavaScript/Node.js, Rust, Python, Groovy, C/C++, C#, HTML, and CSS/SCSS, plus Build Systems (Maven pom.xml, Gradle build.gradle, Jenkins pipeline, Cargo.toml, MSBuild .csproj + Directory.Packages.props), Configuration Files (YAML, JSON, .properties — optional), Kubernetes + Helm (optional), and Cross-Repo Dependency Linking with full cross-language linking.
For recent release notes see CHANGELOG.md.
The indexer automatically builds:
Vector Search Database (Qdrant) — semantic understanding via embeddings
Graph Database (Neo4j) — architectural relationships via call graphs
This dual-database approach powers both:
MCP (Model Context Protocol) Server — Exposes read-only tools (search, callers, explore, list_files, list_endpoints, repos, deps) to any LLM client (Claude, Gemini, ChatGPT, Cursor, etc.)
CLI Tool — Standalone
knotcommand for terminal and scripting environments
Knot in action
CLI — instant reverse dependency lookup
MCP — JSON-RPC protocol for AI agents
🧮 Token Efficiency — Measured, Not Claimed
An LLM agent exploring an unfamiliar codebase pays for every byte it reads. Without an index it greps and then reads whole files; with knot it receives a targeted answer. The difference was measured on three real indexed repositories across nine realistic exploration tasks:
Repo | Lang | Task | knot tokens | Read-the-code tokens | Reduction |
spring-ai | Java | discovery — how does the chat client run the advisor chain? | 677 | 12 262 | 94.5% |
spring-ai | Java | callers — who uses | 3 352 | 43 707 | 92.3% |
spring-ai | Java | explore — structure of | 4 033 | 9 675 | 58.3% |
puppeteer | TypeScript | discovery — how is a CDP session created? | 389 | 4 706 | 91.7% |
puppeteer | TypeScript | callers — who calls | 690 | 42 857 | 98.4% |
puppeteer | TypeScript | explore — structure of the | 5 447 | 27 522 | 80.2% |
knot | Rust | discovery — how are call intents resolved? | 765 | 37 110 | 97.9% |
knot | Rust | callers — who calls | 152 | 18 929 | 99.2% |
knot | Rust | explore — structure of the graph query module | 4 761 | 28 281 | 83.2% |
TOTAL | — | 9 tasks | 20 266 | 225 049 | 91.0% |
≈ 11× fewer tokens for the same nine questions — 205 000 tokens saved, enough to keep a long refactoring session inside a single context window. Measured with knot 1.15.1 on 2026-11-01, on a clean index.
Both sides are measured on the exact bytes an LLM would receive as tool
output, counted with OpenAI's cl100k_base tokenizer (tiktoken):
Task | knot side | Read-the-code side |
|
|
|
|
|
|
|
| full read of the file |
The baseline is deliberately generous, so the measured saving is a lower bound:
greps are restricted to the source files of the language (
-t java,-t ts,-t rust) — no changelogs, no generated docs, nonode_modules;for
discoverythe baseline is given oracle file selection: it reads only the files that answer the question, with zero wasted reads;for
callersit reads at most 5 files, while a rigorous impact analysis would need every file with a textual hit.
Honest caveats: knot's cost scales with the number of results, not with repo
size. callers answers list the references made from production code and
count those made from test code (+N in tests, issue #52). Listing them too
(include_tests, CLI --include-tests) costs 16 422 / 773 / 1 003 tokens for
the three callers rows and brings the total saving to 84.8%:
ToolCallingManager has 394 references, 320 of them in tests, and
format_references_result is called mostly by unit tests. The explore rows
for large files are the least favourable, because signatures plus docstrings
are a large fraction of a well-documented file.
How the answers shrank on the same snapshots (knot tokens, 9 tasks): 59 579 with
knot 1.12.4, 53 806 with 1.14.1 (compact search and explore answers, #50) and
28 373 with 1.15.0 (compact callers answers, #52), all on an index built
incrementally that still held the stale entities of #53; 20 266 with 1.15.1
after a --clean re-index. The callers rows alone went from 29 772 to 4 194
tokens. The clean re-index also changed rows of repositories without stale
entities (re-computed embeddings and edges), by a few hundred tokens.
Repositories measured (as indexed): spring-ai 2 490 files / 27 775 entities
(commit b6b5767), puppeteer 1 286 files / 11 733 entities (08e7b1a),
knot 390 files / 5 956 entities (421b515). Raw measurements are stored in
.perf_metrics/token_savings.json.
pip install tiktoken # optional: falls back to a chars/4 estimate
# edit the `root` paths in scripts/token_savings_tasks.json to match your checkouts
python3 scripts/token_savings_benchmark.py \
--config scripts/token_savings_tasks.json \
--save-json .perf_metrics/token_savings.jsonThe task definitions live in
scripts/token_savings_tasks.json and the
harness in
scripts/token_savings_benchmark.py;
point them at any repository you have indexed to measure your own codebase.
Related MCP server: MCP-RAG
✨ Key Features
🔍 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. Whenever the query resolves to more than one entity sharing the same name (e.g.,find_nearest_entity_by_linein different files), results are automatically grouped by target (### Target: <fqn> at <file>:<line>) showing which specific entity each caller references — including when only one of the homonyms has callers. A genuinely single-target resolution keeps the concise ungrouped form. Supports cross-repository call resolution viaDEPENDS_ONgraph edges. A call whose receiver type is declared in the caller's own repository never binds to a dependency's same-named type, even when the local member is not indexed (macro-generated, derived, annotation-processed): it stays unresolved instead. Likewise, a call on a type no indexed repository declares (JDK, standard library, third-party package:String.valueOf(..), a field typedModelMapper) never binds to a repository method that merely shares the callee's name. In Java and Kotlin, an unqualified type name — a call receiver, a receiver named after its type (config→Config), anextendsor a type reference — resolves through the caller file's imports: a single-type import (or Kotlinasalias) first, then the file's own package, then on-demand imports (com.x.*), so same-named types of different packages are never mixed up; an import of a type no indexed repository declares leaves the call unresolved. For JVM languages (Java/Kotlin/Groovy) it also surfaces method-levelOVERRIDESedges bidirectionally — an Overridden by group listing subtype implementations/overrides and an Overrides group listing the supertype methods a method implements/overrides — plus a Dispatched calls group listing callers that reach the queried method through dynamic dispatch (bound to an override or to the supertype method), so an interface method called only through its implementation (or vice versa) is never reported as unused.explore_file: File anatomy inspection. Quickly see all classes, interfaces, methods, functions, constants, and other entities in a file with signatures and documentation. Attribute-usage markup tokens (html_class,html_id) are summarized in a separate section by default to avoid cluttering code lists; use--include-markup(CLI) orinclude_markup: true(MCP) to list them in full. Structured content returnsmarkup_countandmarkup_referencesalongsideambiguous_path_candidates.list_repo_dependencies(MCP) /knot deps(CLI): Dependency graph visualization. Show which repositories depend on each other, forward and reverse, with transitive resolution.list_files(MCP) /knot files(CLI): Read-only file enumeration with entity counts, deterministically ordered. Accepts an optionalpath— a repo-relative directory prefix matched on a path boundary (src/apinever matchessrc/api-notes.md) or a glob (src/**/*_test.rs). Prefixes and globs alike page the repository file list in pages of 2000 entries with per-page boundary filtering, ensuring no valid candidates are dropped. When output exceeds 2000 matches, a truncation notice is displayed below the table reporting the exact pre-truncation match count when known (or an explicit lower bound when the scan stopped early). JSON output carriestotal_matchesandtotal_is_lower_bound. Pair with the new--path/pathscope onsearch_hybrid_contextto restrict a semantic search to a subtree.list_endpoints(MCP) /knot endpoints(CLI): HTTP endpoint catalogue. Lists the endpoints Java and Kotlin code serves — JAX-RS (class/method@Path+@GET/@POST/…) and Spring MVC (class@RequestMapping+@GetMapping/… or@RequestMapping(method = …)) — as<METHOD> <path>with the handler method each one routes to. Class and method paths are joined, path arrays expand, path-variable patterns are dropped ({id: [0-9]+}→{id}), and string constants resolve whether declared in the same file or in another file of the repository (found through imports and package; Kotlinconst valtemplates included). Filters:method(case-insensitive;ANY, a@RequestMappingwithoutmethod, matches every method) andpath(segment-wise prefix where an endpoint's{variable}segment matches any value, so a concrete URL such as/api/owners/42findsGET /api/owners/{id}). Each endpoint is anhttp_endpointentity linked to its handler by aROUTES_TOedge:find_callerson a handler lists it under HTTP routes (a handler reached only over HTTP is never reported as unused),explore_filegroups a resource's endpoints under HTTP Endpoints, andsearch_hybrid_contextfinds them by route. Paths are relative to the application — the context path (server.servlet.context-path,@ApplicationPath) is not applied to the listed paths. Declarative clients (@FeignClient,@RegisterRestClient,@HttpExchangeinterfaces) are not endpoints, and interfaces generated at build time (OpenAPI generator) are not in the source tree. An unresolved constant stays visible as<expression>.HTTP client linking (Java/Kotlin, heuristic): every routed method of a declarative client — OpenFeign (
@FeignClient), MicroProfile REST Client (@RegisterRestClient), Spring HTTP interface (@GetExchange/@HttpExchange) — and every imperative call —RestTemplate(getForObject,postForEntity,exchange(url, HttpMethod.X, …), …),WebClient/RestClient(.get().uri(…),.method(HttpMethod.X).uri(…)) — becomes anhttp_client_callentity (GET /api/items/{id}, base URL path applied), and after every indexing run anHTTP_CALLSedge links it to the endpoint it hits, across every indexed repository and whatever the indexing order — no build dependency between client and server is needed. Each recomputation is a single transaction serialized across concurrent indexers (cluster nodes sharing Neo4j), so readers never see the edges half replaced and the last run sees every repository. The subgraph query (knot-server's graph API) acceptsHTTP_CALLS.find_callerson a handler or endpoint lists the client calls under HTTP callers (heuristic: client call → endpoint), andexplore_filegroups them under HTTP Client Calls. Base URLs come from the annotation (url,path,baseUri) or the client's configuration (spring.cloud.openfeign.client.config.<name>.url,quarkus.rest-client.<key>.url,<key>/mp-rest/url,${prop:default}placeholders); theapplication*/bootstrap*.yml|.yaml|.propertiesandmicroprofile-config.propertiesfiles are read for this even without--include-config-files(test sources excluded). The Feign service name and the URL host select the servers whosespring.application.name/quarkus.application.namematch; a server's context path (server.servlet.context-path,spring.mvc.servlet.path,quarkus.http.root-path,@ApplicationPath, …) may or may not appear in the client path. Verbs must agree (ANYmatches all),{variable}segments match any value, at least one literal segment must match exactly, and the most literal endpoint wins (/items/{id}over/items/export); when several endpoints match equally well nothing is linked. Imperative calls are recognised textually (put/deleteonly on a receiver declared asRestTemplate/RestOperations), belong to the method containing them, and their URL is evaluated from literals, concatenation, Kotlin templates, constants,@Value("${…}")fields and parameters,URI.create,String.formatandUriComponentsBuilder/uriBuilderpath(…)calls: an unknown leading part (abaseUrlvariable) stands for scheme and host, an unknown later part for a{variable}segment ("/items/" + id→/items/{id}), and a relative URL takes the base of the file's singlebaseUrl(…)/rootUri(…)builder call. Test code is skipped. Not covered yet: Java'sHttpClient, base URLs set in another file (treated as unknown), and a change to a client's configuration alone (re-index with--clean).list_repositories/knot repos: Repository inventory. List every indexed repository along with its entity count, file count, build system, and primary language. Supports optional case-insensitive name filtering via--filter(CLI) orfilterparameter (MCP). Useful for orientation, sanity-checking indexing runs, and discovering which languages and build systems are present in the workspace.
🧩 Reference Resolution
Deterministic edge targets: when a reference matches several candidates at once — a receiver call whose FQN search hits a method name reused across module paths (
pkg.alpha.Widget.rendervspkg.beta.Widget.render), a short class name that suffix-matches several fully-qualified classes (pkg.alpha.ChatModelvspkg.beta.ChatModel), or a VCLincludewhose basename matches several files (alpha/shared.vclvsbeta/shared.vcl) — the edge always lands on the same target. Candidates are ranked by a total order: a target declared in the caller's own file first, then the lexicographically smallest FQN, then the smallest UUID. Recall is unaffected: an edge is created whenever at least one candidate matches, and only the choice of target among genuinely ambiguous candidates is decided. Cyclic re-export aliases collapse to the smallest UUID in the cycle and are fully path-compressed, independently of hash-map iteration order.
🏗️ Multi-Language Support
Java: Full AST extraction with package-aware FQN resolution (e.g.,
com.example.app.UserService), class inheritance (EXTENDS), interface implementation (IMPLEMENTS), annotation tracking, and declared-type receiver resolution for fields (includingthis.field), record components, method/lambda/catch parameters, local, loop and try-with-resources variables, and pattern variables (instanceof Type x,case Type x). Scoping is respected: an inner declaration with the same name shadows the field even when its type is unknown (var, untyped lambda parameters, multi-catch), so the field's type is never applied to a different variable. Calls and method references (expr::method) on interface-typed fields resolve to the interface declaration regardless of variable naming, while hierarchy-aware resolution links inherited interface methods. Calls to overloaded methods bind by argument count within the receiver class and its supertypes (foo.bar(1, 2)→Foo.bar(int, int), varargs and default parameters accepted), never to a same-name/same-arity method of an unrelated class. Arity narrows name-only candidates but never picks a target on its own. Avarlocal takes its type from anewinitializer (var r = new TextRenderer()→TextRenderer, so a third-party type leaves the call unresolved). A receiver whose type stays unknown (var m = factory.create(), untyped lambda parameters) binds by method name alone only to a method whose type is visible from the caller's file — in the caller's package, imported (single-type or on demand), or nested in an imported type; Kotlin applies the same rule (top-level functions must be imported or in the caller's package). Bare calls and languages without imports (Python, JavaScript, Groovy) keep the name-only fallback.Kotlin: Complete support for Kotlin codebases with classes, interfaces, objects, companion objects, functions, methods, and properties. Fully compatible with tree-sitter-kotlin-ng grammar. FQNs carry the file's
package(com.example.app.Config.load, top-level functionscom.example.app.bootstrap), so same-named types in different packages stay distinct forfind_callers,explore_file, search andOVERRIDES. Calls carry their argument count (a trailing lambda counts as one), so calls to overloaded methods bind by arity within the receiver class and its supertypes.C#: Full C# support via
tree-sitter-c-sharp. Extracts classes, interfaces, structs, records (bothrecord classandrecord struct), enums, methods, constructors, properties, fields (withconstdetection), delegates, events, indexers, operators, local functions, and namespaces withCSharp*entity kinds. Namespace-qualified FQNs (MyApp.Services.UserService.GetUserAsync) work across both file-scoped (C# 10+) and block-form namespaces, including nested namespaces and nested types. Thebase_listheuristic splits: Base, IFaceintoEXTENDS/IMPLEMENTSusing theIPascalCaseconvention (structs and interfaces are deterministic), generic arguments are stripped (IRepository<User>→IRepository), XML doc comments (///) become docstrings, and attributes ([Obsolete]) are captured as decorators. Calls through field-typed receivers resolve to the exact implementation method, and C#virtual/overrideplus interface implementation produce method-levelOVERRIDESedges. MSBuild/NuGet:.csprojfiles are parsed for project identity and dependencies (Central Package Management viaDirectory.Packages.propsis supported); C# repos getbuild_system: "nuget"in the Repository node instead of the prior"none".TypeScript/TSX/CTS: Complete support for modern JavaScript/TypeScript codebases, including CommonJS TypeScript files. Calls bind to the overload signature whose arity matches (
bar(a): T; bar(a, b): T); athis:parameter is not counted.this.m()binds to the enclosing class's method or, failing that, to the nearest superclass declaring it. Each class member reports only the decorators written directly before it (@computed,@action,@Get(...)), never those of an earlier member. Athis.xread, write or argument that is not called is a member access: it produces aREFERENCESedge to a field (sofind_callerson a field lists its readers and writers as references, not invocations) and aCALLSedge only to a getter or method (this.total,app.use(this.handler));this.m()stays a callJavaScript/Node.js: Vanilla JS, Node.js, and module systems (
.js,.mjs,.cjs,.jsx). Arity never constrains call resolution in JavaScript, where every parameter is optional. In both JavaScript and TypeScript, aconst/let/vardeclared inside a function, method or arrow body is a local and is not indexed; module-level constants, class fields and local function definitions are. Function locals and parameters passed as call arguments are treated as values rather than callbacks, and receiverless calls obey module visibility (same-file or imported callable), so locals never bind to fields of unrelated modulesHybrid Web Ecosystem: Cross-language linking between JavaScript, HTML, and CSS for full-stack SPA analysis
HTML: Custom elements (Web Components, Angular),
idandclassattribute indexing for cross-language CSS searchJSX/TSX Attributes: Extracts
idandclassNamefrom React components for unified HTML/CSS discoveryCSS/SCSS: Stylesheet indexing with class/ID selector extraction and variable tracking (CSS/SCSS variables, mixins, functions)
Rust: Struct, enum, union, trait, function, method, module extraction with trait implementation tracking (IMPLEMENTS relationships) and macro invocation references. Methods are indexed with the qualified FQN
Type::method(e.g.,KnotMcpHandler::new,WidgetA::new,Logger::new) and qualified calls from top-level functions resolve to the right target by receiver. Method calls throughself, a field path (self.repo.save()) or a call chain (self.builder().finish(),x.iter().map(..).sum()) produce CALLS edges:self.m()binds to the enclosing type by its crate-anchored FQN, and other compound receivers bind only when their last path segment names the type (self.repo→Repo). They never fall back to an unrelated method that merely shares the name, so std calls like.collect()or.as_str()stay unbound. Braced import/use capture —use foo::{Bar, Baz}anduse foo::Bar as Bazproduce explicit REFERENCES edges for all imported names, including traits imported solely to bring methods into scope. All Rust entity FQNs are now anchored at the owning crate and module path (e.g.knot::config::Config,knot::pipeline::parser::languages::rust::qualify_rust_fqns), so two crates that declare a type with the same bare name no longer collide. Files outsidesrc/(tests, benches, examples) receive a__fixture::<path>::<Entity>FQN prefix (e.g.__fixture::tests::testing_files::sample::Config), and files without aCargo.tomlancestor receive__loose::<path>::<Entity>, preventing name collisions with real source entities. CONTAINS relationships useenclosing_class_fqnfor exact disambiguation when multiple entities share the same class name. The on-disk index state file (.knot/index_state.json) carries aversionfield; opening a state file from an older version prints an error with instructions to runknot-indexer --clean.Python: Full Python extraction with class, function, method support, constants, module-level imports,
ValueReferencetracking 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, andself.method()resolution with inherited method walking. Capturesclass_definition,function_definition(including async via optionalasyncmodifier), lambda assignments, and distinguishes methods from functions via parent context detection. Class instantiation (ClassName(...)) is automatically redirected toClassName.__init__sofind_callers ClassName.__init__lists every constructor call site (with fallback to inherited__init__via the extends chain); only class/struct kinds trigger the redirect — functions keep the legacy behavior.Groovy: Full Groovy language support via hybrid tree-sitter + ad-hoc lexical parser. Extracts classes, interfaces, traits, enums, typed/
def/quoted methods (incl. Spock specs), constructors, closures, script-level variables, fields/properties with visibility modifiers, nested classes, and decorators. Tracks package FQN and enclosing class relationships. Multi-line signatures (closure default params), assignment-vs-declaration disambiguation, innermost assignment for nested closures, UUID collision fix for duplicate method names,find_callersaccurately tracks private methods including those in anonymousnew AnActionclosures. Inheritance tracking: emitsEXTENDS/IMPLEMENTSreference intents forclass/interface/trait/enumheaders (single-line and multi-line) sofind_callerssurfaces real nextflow-style hierarchies — qualified parents (e.g.extends nextflow.plugin.BasePlugin) and generic-argument stripping (e.g.extends AbstractRepo<Order, Long> → extends AbstractRepo) are supported, and generic bounds (class Box<T extends Comparable>) are correctly not promoted to inheritance edges. Property accessors: bare property declarations (Path baseDir,boolean cacheable) are now indexed asGroovyProperty, and compiler-generatedgetX/setX/isXaccessors are synthesised as first-class method entities soOVERRIDESedges link Groovy properties to interface getter declarations. Comment-stripping prevents Javadoc continuation lines (* The pipeline script name) from producing phantom entities or corrupting scope tracking. Calls whose only argument is a trailing closure (parts.each { ... },withLock { ... }) are detected with arity one, with or without a receiver. Parenthesized calls carry their argument count (trailing closures included; named arguments, spreads and multi-line argument lists stay uncounted), and a trailing array parameter accepts varargs, so overloads bind by arity. Calls written on a method's declaration line — one-line methods such asString wide(Formatter f) { f.format('x', 80) }, including calls inside a one-line closure — belong to that method; the declaration itself (the method's name, its typed parameters) is never reported as a call. A receiver calla.b(..)is reported once, with its receiver, so a call on an unindexed type never binds to a repository method by its bare name.Build Systems: Maven
pom.xml(dependencies + plugins via roxmltree), Gradlebuild.gradle(deps + plugins + tasks),Jenkinsfilepipeline (stages + steps), CargoCargo.toml(deps + workspace members + features), and MSBuild.csproj/Directory.Packages.propsextraction. MSBuild resolves project identity (<PackageId>→<AssemblyName>→ file stem), emits aBuildDependencyper<PackageReference>(attribute-form and version-less), and resolves Central Package Management versions from the nearestDirectory.Packages.propsancestor. UTF-8 BOMs are tolerated defensively. Identity markeridentity: package_idis carried in the signature when the project has an explicit<PackageId>so the cross-repo resolver prefers published packages over depth-tied unmarked candidates. When several manifests sit at the same depth, the repository identity is picked deterministically (marker, then depth, then relative path), so it no longer changes between indexing runs.Cargo.toml: Rust package manager support with package metadata, features, workspace members, and multi-format dependency parsing (simple, table, git, path).
Configuration Files: YAML (.yml/.yaml), JSON (.json), and Java Properties (.properties) with leaf-key granularity. Special handling for package.json (detected by filename: npm dependencies as BuildDependency, scripts as ConfigProperty, ProjectIdentity even for dependency-free library manifests).
Varnish Cache: Hand-written parsers for
.vcl(configuration),.vtc(test cases), and.vcc(VMOD C source). VCL extracts backends, probes, ACLs, subroutines (custom + built-in withvcl_*names, including aggregator entities for multi-part built-ins),importdirectives (withasaliases andfrompaths),includeedges,unuseddeclarations, VMOD instantiations, andreq.backend_hintassignments. VTC extractsvarnishtest/vtestcases, servers, clients, varnish instances, logexpect blocks, barriers, and-vcl+backendsynthesised backends (withis_test_context). VCC extracts$Module,$Function,$Object,$Method,$Event,$Restrict, ENUMs, and default parameters. References:Calls,Extends,Implements,References(with intentsVclSubCall,VclBackendRef,VclProbeRef,VclAclRef,VclInclude,VclVmodImport,VclUnusedRef,ValueReference); relationships:UsesBackend,UsesProbe,UsesAcl,Includes,ImportsVmod,DeclaredUnused. The Fastly VCL dialect is detected and skipped (returns empty entities).Kubernetes + Helm: K8s manifest parsing (Deployment, Service, ConfigMap, Secret, Ingress, Namespace) with label/annotation tracking and cross-resource references. Helm chart indexing (Chart.yaml metadata, values.yaml key-value pairs, template variable extraction via {{ .Values.X }}).
C/C++: Complete C/C++ support with namespace-aware FQN resolution (
Engine::MyClass::start), class/struct extraction, function/method tracking, macro definition and usage detection (uppercase identifier heuristic), type reference tracking (declarations,newexpressions), and full call graph analysis. Supports.c,.h,.cpp,.hpp,.cc,.cxx,.hh,.hxxextensions via tree-sitter-c and tree-sitter-cpp parsers. Includes intelligent auto-detection for.hheaders to parse them correctly as C or C++ based on their contents.Markdown: Documentation indexing with
MarkdownDocument(one per.md/.markdownfile) andMarkdownSection(one per ATX heading H1–H6). Section bodies — including paragraphs, fenced code blocks, lists, and tables — are captured intoembed_textfor full semantic search over documentation content, not just heading titles. FQNs are hierarchical and file-scoped (e.g.README.md::Setup > Installation > Linux), so same-named headings in different files or under different parents disambiguate cleanly. Section boundaries respect heading depth: a section's body extends until the next heading of equal or higher level, ensuring### Linuxunder## Installationdoes not bleed into a sibling## Configuration. Headings with inline markdown (backticks, em-dash, links, emoji) parse without losing their bodies, and realstart_line/end_linepositions are computed via tree-sitter for each section.
📚 Rich Comment Extraction
Captures docstrings (JavaDoc, JSDoc) preceding declarations
Extracts inline comments within method/function bodies
Respects nesting boundaries (class comments don't capture method comments)
Intelligently aggregates comment blocks
📊 Dual-Database Architecture
Qdrant: Vector search for semantic code understanding
Neo4j: Graph relationships for structural navigation
🚀 High Performance
Parallel Streaming Pipeline: Overlaps CPU-bound embedding with I/O-bound ingestion via MPSC channels
Incremental Indexing: Uses SHA-256 hashes to skip unchanged files
Real-time Watch Mode: Automatically re-indexes changed files in seconds via
--watchEmbed-Text Recall: Every entity's embed text carries its identifier surface — name, FQN and the camel/snake-case-tokenized form of both, plus the tokenized names of what it calls in its body. A function with no doc comment is still findable by the behaviour described in natural language ("authenticate user with email and password" surfaces a doc-less
loginthrough thenormalize_email/verify_credentialsvocabulary in its body). Rust signatures ((email: &str, password: &str)) survive extraction too. Requires one re-index when upgrading from an older index state version (automatic: old states are rejected with instructions).CPU Parallelism: AST extraction via Rayon
Scalable: Configurable batch processing and constant memory footprint (~2GB) regardless of repository size
Performance Benchmarking: Multi-level validation framework
Unit benchmarks: Criterion-based benchmarks for parse, embed, and graph write throughput (
benches/)E2E benchmarks: Full pipeline metrics capture with per-stage timing (
tests/benchmark_e2e.sh)CI regression tracking: Automated baseline comparison against tolerance thresholds (
scripts/compare_perf_metrics.sh)Token efficiency: LLM token cost of knot answers vs reading source files (
scripts/token_savings_benchmark.py) — see Token Efficiency
🛠️ Installation
Prerequisites
Component | Version | Notes |
Docker | 20.10+ | For running Qdrant and Neo4j |
qdrant | 1.x | Vector database (docker) |
neo4j | 5.x | Graph database (docker) |
Option A: Pre-compiled Binaries (macOS & Modern Linux)
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 | shInstall agent-skills for your AI (Optional): Paste this into your LLM agent (Claude Code, OpenCode, Cursor, etc.):
Install the knot agent skills by following the instructions at: https://raw.githubusercontent.com/raultov/knot/master/README.md
The first command installs the knot binary to your PATH. The second (optional) allows your AI assistant to automatically download the agent skill index (.knot-agent.md) and run the installer to extract comprehensive guides for using knot CLI with AI agents and code analysis tools.
System Requirements:
Linux: glibc 2.38+ (Ubuntu 24.04+, Debian 13+, Fedora 39+, Arch)
macOS: Modern versions supported
Windows: Use Docker (Option B)
Option B: Docker (Universal Compatibility)
Docker images provide universal compatibility for any Linux distribution and Windows.
Docker Installation (All Binaries)
Build the image:
docker build -t knot:latest . --network=hostRun 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-indexerRun 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-mcpNote: Uses Debian Trixie (glibc 2.38+) and includes ONNX Runtime for full functionality.
Option C: Install via Cargo
cargo install --git https://github.com/raultov/knotOption D: Build from Source
1. Start infrastructure with Docker:
docker compose up -d2. Clone and build:
git clone https://github.com/raultov/knot
cd knot
cargo build --release3. Configure:
mkdir -p ~/.config/knot
cp .env.example ~/.config/knot/.env
$EDITOR ~/.config/knot/.env # Set KNOT_REPO_PATH and Neo4j credentials4. Index a codebase:
./target/release/knot-indexer5. Query via CLI:
./target/release/knot search "your query"6. Start the MCP server:
./target/release/knot-mcp📖 Usage
🤖 Install Agent Skills (For AI Agents)
Option A: Let an LLM do it
Paste this into any LLM agent (Claude Code, OpenCode, Cursor, etc.):
Install the knot agent skills by following the instructions at: https://raw.githubusercontent.com/raultov/knot/master/README.md
Option B: Terminal (Manual)
curl -sO https://raw.githubusercontent.com/raultov/knot/master/.knot-agent.md && curl -fsSL https://raw.githubusercontent.com/raultov/knot/master/scripts/install-agent-skills.sh | bash📥 Quick Downloads (Binaries)
Download knot binaries (CLI + MCP server):
curl --proto '=https' --tlsv1.2 -LsSf https://github.com/raultov/knot/releases/latest/download/knot-installer.sh | sh📖 Agent-Skills Guides
Comprehensive documentation for using knot tools. The agent skills installer extracts:
search.md — Semantic code discovery guide with examples
callers.md — Reverse dependency lookup with critical usage rules
explore.md — File anatomy inspection guide
deps.md — Repository dependency graph guide
repos.md — Indexed repository inventory
workflows.md — Common patterns and best practices
For quick reference without downloading, see .knot-agent.md.
Using the CLI
The knot CLI provides the same capabilities as the MCP server via command-line commands, making it ideal for:
Terminal-only environments
Bash scripting and automation
CI/CD pipelines
Direct integration with other tools
Three main commands:
knot search — Semantic Code Search
knot search "user authentication" --max-results 10 --repo my-app
knot search "user authentication" --max-results 20 --repo "app-a,app-b" # Union across repos
knot search "user authentication" --max-results 20 --repo all # All indexed repos ('all' or '*')
knot search "user authentication" --kinds definition # Only functions/methods/typesFind code entities by meaning, class names, docstrings, or comments.
Ranking is kind-aware: function/method/class/struct definitions outrank
markdown docs, test files, config properties and build-dependency entities
for natural-language queries, and callers/helpers are shown as context
attached to a definition — never as substitutes. The shared entry point of
the highest-ranked helpers outranks those helpers, and an entity merely
named after a generic verb (find, get, create, build, acquire, …)
does not win on the bare verb unless its container (FQN) corroborates the
query. Use --kinds to narrow the
result types (aliases: definition, callable, class/type/struct, or
exact kinds like rust_function).
knot callers — Reverse Dependency Lookup
knot callers "LoginService" --repo my-app
knot callers "LoginService" --repo "auth-service,billing-service"
knot callers "LoginService" --repo all
knot callers "com.x.Foo.bar(int, int)" # One overload by parameter typesFind all code that references a specific entity (dead code detection, impact analysis, call chains). Whenever the query resolves to more than one target sharing that name, results are automatically grouped by target (### Target: <fqn> at <file>:<line>) with file locations and signatures — including when only one of the homonyms has callers.
Overloads share one FQN in the index, and a trailing parameter list of types addresses a single one: com.x.Foo.bar(int, int) resolves com.x.Foo.bar with the usual tiers, then keeps the overloads whose declared parameter types match — simple type names (List, not java.util.List), generic arguments compared only when written (List matches List<String>), arrays and varargs as [] or ..., and name: Type accepted for Kotlin/TypeScript. When no overload matches, the answer lists the declared ones (No overload of com.x.Foo.bar takes (String). Declared overloads: …). The bare FQN still returns every overload, each labelled by its parameter list (### Target: com.x.Foo.bar(int, int)). Works on existing indexes: no re-index is needed.
Target resolution is code-only by default: documentation, configuration, build-system and Kubernetes/Helm entities (markdown_section, config_property, build_dependency, cargo_package, project_identity, k8s_*, helm_*, …) can never be presented as resolved targets. When the filter removes matches the response discloses them (Non-code matches hidden — N entities …) and names the fix (kinds=all to include them). A fuzzy query like cargo no longer fills the target list with Cargo.toml metadata. Fuzzy matching is also case-insensitive, so hikari finds Hikari-named artifacts. Queries shorter than 4 characters resolve by anchored name prefix rather than substring: knot callers use returns useSearch, useSources, useSaveCv and friends without dragging in every *STATUSES constant that merely contains use. Queries of 4+ characters keep the case-insensitive fuzzy substring fallback. Override the scope with --kinds all / MCP kinds:"all", or pass an explicit allow-list (--kinds callable, --kinds build_dependency).
The buckets cover every edge type the pipeline produces: Calls, Extends, Implements, References, Macro calls (Rust MACRO_CALLS), DOM references (JS → HTML element id), CSS class usage (JS → CSS class), script/stylesheet imports, the VCL edges (uses backend/probe/acl, includes, VMOD imports, declared-unused), HTTP routes (ROUTES_TO: the endpoint serving a handler), HTTP callers (HTTP_CALLS: the HTTP client calls hitting a handler's endpoint, heuristic) plus Overridden by / Overrides / Dispatched calls — so init_vec's macro call sites and app-container's JS manipulators now show up instead of a false "may be unused".
Every answer is self-labeling: the resolution block names each target's repository as (repo: <name>). When every reference belongs to one repository, the Found line names it once; when the scope spans several, every row carries its own (repo: <name>). The Markdown answer is compact (#52): one line per row, with the signature on that line when it is not empty, and a file's <module> row (its import) folded into the file's other rows. References made from test code (test files, Rust #[cfg(test)]) are included in every count but listed only with include_tests: true (CLI --include-tests); each group then ends with +N in tests. The JSON output is unchanged and lists every row, now with an is_test_context field.
# References to `LoginService`
Resolved to 1 target by exact name match:
- `auth::service::LoginService` (class) at `src/service.rs:12` (repo: auth-service)
Found 3 reference(s) across all relationship types (repo: auth-service) — 1 in tests, counted but not listed (`include_tests` lists them):
## Calls (function/method invocations) (3)
- **`signup`** (function) at `src/handlers.rs:88` — `(form: SignupForm)`
- **`login`** (function) at `src/handlers.rs:120` — `(form: LoginForm)`
- +1 in tests (`include_tests` lists them)In the CLI table the Target column is labeled only for genuine cross-repo references (a caller in repo A referencing a target in repo B); the Caller column is always labeled when a repository is known.
knot explore — File Structure Inspection
knot explore "src/services/auth.ts" --repo my-appList all classes, methods, functions in a file with signatures and documentation.
knot deps — Repository Dependency Graph
knot deps my-app --depth 2 # Show forward dependencies (transitive)
knot deps my-app --reverse # Show who depends on this repoVisualize auto-discovered dependencies between indexed repositories with transitive resolution up to 3 levels deep.
knot repos — List Indexed Repositories
knot repos # Table with REPO / BUILD SYSTEM / LANGUAGE / FILES / ENTITIES
knot repos --filter app # Case-insensitive name filter (substring match)
knot repos --output json # Machine-readable list
knot repos --output markdown # GFM table for chat UIsShow the status of every repository currently indexed in the graph database — useful for orientation, sanity-checking that an indexing run completed, and discovering which languages and build systems are present across the workspace. Use --filter to quickly locate a specific repository when working with multiple indexed codebases.
Repository Scope Selection:
Both the CLI --repo/-r flag and MCP repo_name parameter support:
Single repository name:
--repo my-appComma-separated list:
--repo "repo-a,repo-b"(MCP also accepts["repo-a", "repo-b"])Sentinel:
--repo allor--repo "*"(searches every indexed repository)
Note: Multi-repo scope applies a global max_results limit across the union. Increase --max-results (range 1-100, enforced; larger values are clamped and a note is printed — no pagination, narrow with --kinds/--path/--repo or refine the query instead) when searching across multiple repositories.
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.
Indexing a Codebase
Incremental Indexing (Default)
# 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
knot-indexer --watch --repo-path /path/to/your/repo --neo4j-password secretHow it works:
Tracks file content via SHA-256 hashes in
.knot/index_state.jsonStores the downloaded
fastembedmodel in.knot/fastembed_cache/to keep the workspace cleanAutomatically detects: modified, added, and deleted files
Only re-parses and re-embeds changed files; a modified file's previous entities are deleted first, so an entity that moved or was removed never lingers as a duplicate
Preserves graph relationships to unchanged files: edges from unchanged files (or other repositories) into a modified file are re-pointed at its re-indexed entities (same file, FQN, kind and signature); edges into entities that no longer exist are dropped
Processes entities in memory-efficient 512-entity chunks
Performance:
Initial index (3800 files): ~60 minutes on standard hardware
Incremental update (3 files changed): ~5-10 seconds
Memory usage: Constant ~2GB regardless of repository size
Full Re-Index (Clean Mode)
# Force complete re-index (deletes all existing data)
knot-indexer --clean --repo-path /path/to/your/repo --neo4j-password secretUse --clean when:
You want to rebuild the entire index from scratch
You've changed Tree-sitter queries or embedding models
Troubleshooting indexing issues
Upgrade note (v1.5.1): File paths are now persisted as repo-relative paths with POSIX separators (e.g.
src/pipeline/embed.rs). Upgrading from v1.4.x triggers an automatic full re-index on first run — the on-disk.knot/index_state.jsoncarries a version field that the loader rejects when stale, andknot-indexerthen wipes the repo from both databases before rebuilding. No manual steps required. Entity UUIDs become machine-independent in the process: the same repo indexed from different checkout locations now produces identical UUIDs.
Indexing Progress
The indexer emits [Progress] log lines showing real-time completion across
the whole pipeline (parsing, embedding, ingestion, reference resolution).
The percentage is monotonically non-decreasing and reaches 100% only
once the run genuinely terminates.
Upgrade note (v1.6.2): The percentage now spans the entire pipeline via weighted bands. Previously it measured only file reading and saturated at
100%within seconds of starting, then froze for minutes while embedding and ingestion were still running. Seedocs/specs/indexing_progress_accuracy_plan.mdfor the full design.
Example with 5000 files where 1000 have been parsed and 5,000 entities are half-way through ingestion:
[Progress] [my-repo] 50.0% — files 5000/5000, entities 41600/83200, batch #325 (128 entities)Band table
Phase | Band | Driver |
|
| — |
Parsing |
|
|
Embedding + Ingestion |
|
|
|
| fixed (no sub-counters available) |
|
| forced |
| last computed value | frozen |
A final log line confirms completion:
[Progress] [my-repo] 100.0% — files 5000/5000, entities 83200/83200 — parsing and ingestion complete, resolving references...Library API (knot-server integration)
Callers that need to observe progress programmatically can use the ProgressTracker:
use std::sync::Arc;
use knot::pipeline::{ProgressTracker, run_indexing_pipeline_with_progress};
let progress = Arc::new(ProgressTracker::new());
let progress_clone = Arc::clone(&progress);
// Poll snapshot() from another task while the pipeline runs
tokio::spawn(async move {
loop {
let snap = progress_clone.snapshot();
println!(
"{:.1}% — files {}/{}, entities {}/{}",
snap.percent_complete,
snap.parsed_files,
snap.total_files,
snap.entities_ingested,
snap.total_entities
);
if snap.stage == IndexingStage::Completed || snap.stage == IndexingStage::Failed {
break;
}
tokio::time::sleep(std::time::Duration::from_millis(500)).await;
}
});
run_indexing_pipeline_with_progress(&cfg, &vdb, &gdb, &mut state, progress).await?;The snapshot() method is thread-safe (read-only locks + atomic loads) and returns a
IndexingProgress struct that serializes directly to JSON for REST endpoints.
Running E2E Integration Tests
To ensure indexer stability, run the E2E integration test suite:
# Run all language E2E tests (TypeScript, Java, JavaScript, Web, Kotlin, Rust, ...)
./tests/run_all_e2e_fast.sh
# Run only Kotlin E2E tests
./tests/run_kotlin_e2e.sh
# Run only Rust E2E tests
./tests/run_rust_e2e.sh
# Run only C# E2E tests
./tests/run_csharp_e2e.sh
# Run only Varnish E2E tests
./tests/run_varnish_e2e.shSee tests/KOTLIN_E2E_TESTS.md for detailed coverage and troubleshooting.
Using the MCP Server
The MCP server exposes five tools to any compatible AI client (built on rust-mcp-sdk 1.1 implementing MCP protocol 2025-11-25 with full tool annotations):
Embedding the tool surface: library consumers can serve the same five tools
from their own transport (e.g. an HTTP /mcp endpoint) without going through
the stdio server. KnotMcpHandler::tools() returns the canonical tool table
(no state or database connection required), and
KnotMcpHandler::dispatch(params) executes a tools/call without needing an
Arc<dyn McpServer> runtime handle. The stdio ServerHandler methods delegate
to these two entry points, so every surface stays identical by construction.
Tool 1: search_hybrid_context
Find code by meaning or keywords
Query: "How is user authentication implemented?"
Result: All auth-related code, signatures, docstrings, and dependenciesCapabilities:
Semantic search by functionality (vector embeddings)
Global multi-repository search by default (
repo_name: "all")Class/method/function name lookup
Docstring and inline comment search
Architectural pattern discovery
Full dependency context
Search ranking contract (kind-aware re-rank, query-time only):
Definition channel — alongside the plain cosine scan, a second bounded Qdrant pass excluding all non-code kinds guarantees code definitions enter the candidate pool even on documentation-heavy repositories (a prose-saturated cosine window once left the entry-point signal dead). An explicit documentation-scoped search (
kinds=markdown_section, …) never sees the code channel.Recall channels in one pool — cosine hits, the definition channel, the name/token probe (identifiers the query literally names) and the caller-recall bridge (callers of the top semantic roots — seeded from the union of channels, depth 1 + depth 2 in the call graph) all merge into one deduplicated pool before ranking.
Kinds — callables outrank type declarations, which outrank prose and config/build/infra; test paths carry an additional penalty. A neutral kind (
constant, …) whose graph node orchestrates ≥ 2 outgoing CALLS edges earns a boost: a TypeScript MCP tool isexport const x = defineTool({...}), and behavior is not the wiring's kind. Prose/config/test never take structural boosts.Entry-point signal — how many of the top semantic roots a candidate calls, directly or through one helper, attributed to the caller covering a strictly greater root set with the full entry-point signature (≥ 2 distinct roots).
Name-prefix contract is definition-only — a query matching an entity's name keeps leading slots only for definition kinds; prose, config/build and k8s/helm prefix hits are demoted into the pool and ranked on their own cosine (documentation-only topics with no competing definition still surface their best section). Test paths keep their slot but stay penalized inside the re-rank.
Determinism — ties break on
(file_path, start_line, uuid); the CLI (knot search) and the MCP tool share the same core (run_search_hybrid_context).
Live-index verification of the reported recall regression set runs via the
opt-in harness tests/run_rank_recall_live.sh (requires indexed
repositories; skipped otherwise).
Relationship summary per result (same edges as find_callers): each
result is annotated from the graph edges of its own entity (looked up by
UUID, never by bare name), so the summary always agrees with find_callers
on that entity's fully qualified name:
Called by: N — direct
CALLSedges into the entity. Same-named methods in other classes or modules never contribute (a privatecomputeValuein two classes keeps two separate caller sets).Called via dispatch: N — callers reaching the entity only through dynamic dispatch, i.e. the Dispatched calls group of
find_callers(an interface method called only through its implementation showsCalled via dispatch: 1, not phantom direct callers).Calls — the callees, qualified with their owning type or module (
StandardAdjuster.computeValue,GraphDb::connect), deduplicated.Subclasses / Implementers / Type Usage — as before.
Tool 2: find_callers
Find who calls a specific function
Query: "Find callers of getCurrentTimeInSeconds"
Result: All code that invokes this function + file locationsEach caller entry, target group header, and resolved target carries its repository as (repo: <name>), so results remain attributable under multi-repo scopes (repo_name: "all" or a comma list). The raw JSON (--output json) mirrors this with repo_name (referencing entity) and target_repo_name (referenced entity) fields on every row, plus repo_name on each resolution.targets[] entry.
Advanced: Search by Signature
# 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
# Find by C# interface method (surfaces implementations + call sites)
echo '{"method":"tools/call","params":{"name":"find_callers","arguments":{"entity_name":"FindByIdAsync"}}}' | knot-mcpUse Cases:
Dead Code Detection: Zero callers = unused code
Impact Analysis: "What breaks if I modify this?"
Refactoring Safety: Find all references before removing
Override Discovery (JVM + C#): For Java/Kotlin/Groovy/C# methods, results include an Overridden by group (implementations/overrides in subtypes) and an Overrides group (the supertype methods a method implements/overrides). These are backed by real
OVERRIDESedges built at index time and resolved transitively at query time, so querying an interface/superclass method surfaces every implementation, and querying an implementation surfaces the declaration it overrides. Overloads are told apart: an override links only to the same-named declaration whose arity and parameter types match (update(List, boolean)never claims to overrideupdate(List)); type variables match concrete types (put(T)←put(Setting)), the most specific overload wins when several fit, and Groovy default parameters count for every arity they generate. Methods without a readable signature fall back to name-only matching.Dynamic Dispatch (JVM + C#): a Dispatched calls group lists the callers whose
CALLSedge is bound to a method related to the target throughOVERRIDES— calls on the interface when you query the implementation, and calls on a concrete implementation when you query the interface. Each row names the method the call is statically bound to (### Target:/ the table's Target column). Both legs of the traversal are directed, so callers of a sibling implementation never leak in.
Truncation & completeness: the queried name is first resolved to concrete targets, capped at 25 by default (hard ceiling 500). When more targets match, the response states it explicitly and quantified:
> **Truncated** — 112 targets matched; showing the first 25 by FQN.
> **Counts below are partial** — they cover only the 25 of 112 targets shown.
> Re-run with a fully qualified name, or raise `max_targets`, for the complete set.The relationship buckets (Calls, Extends, Implements, References) are
complete for the resolved targets — there is no per-bucket cap — so the partial
counts caveat tells you exactly what to do next: pass a fully qualified name to
disambiguate homonyms, or raise max_targets (MCP parameter, default 25,
maximum 500; CLI --max-targets) to opt into the full impact set.
The same shown-vs-total contract applies to search_hybrid_context: each
relationship summary is one line, and when it lists fewer samples than the
reported count it ends with … +N more instead of implying the sample is the
complete set:
**Called by:** 21 location(s), 4 in tests: handle (same file), checkout in orders.ts, … +15 moreSearch answers are kept compact for LLM agents (issue #50): a sample in the
result's own file reads name (same file), other samples show the file name
only (the full path is one find_callers away); callers and usages in test code
stay in the count but are reported as N in tests and listed only with
include_tests: true (CLI --include-tests); Calls: lists are capped at 8
items plus +N more; signatures print on one line and empty ones (()) are
omitted; documentation keeps its first paragraph without @param/@return
tags; and a result declared in a file already shown says File: same as \`. Pass detail: "brief"(CLI--detail brief) for one line per result — name (kind) — file:line — called by N, calls M— then expand the hit you need withfind_callers, explore_fileor afullsearch. On the reference sample (8 queries over 4 repositories)fullanswers are 28% shorter than in v1.12 andbrief` answers 82% shorter.
Tool 3: explore_file
Understand file structure
Query: "What's in BrowserService.ts?"
Result: All classes, methods, constants, and functions with signatures and docs, plus compact markup summariesTool 4: list_repositories
Discover indexed codebases
Query: "What codebases are indexed?"
Result: Markdown table of all indexed repos with entity/file counts, language, and build systemTool 4b: list_files
Enumerate a repository's files
Query: path = "src/hooks", repo = "my-app"
Result: Ordered table of the files under src/hooks with their entity countssearch_hybrid_context shares the same path parameter to scope results
to that subtree.
Tool 4c: list_endpoints
Catalogue the HTTP endpoints a service serves (Java/Kotlin: JAX-RS, Spring MVC)
Query: method = "GET", path = "/api/owners/42", repo = "my-service"
Result: | GET | /api/owners/{ownerId} | com.shop.web.OwnerController.showOwner | src/.../OwnerController.java:41 | my-service |Tool 5: list_repo_dependencies
Traverse cross-repository dependency graphs
Query: "What repositories depend on auth-lib?"
Result: Repositories declaring build dependencies (pom.xml, build.gradle, Cargo.toml, package.json, NuGet)Indexing either side of a relationship creates the DEPENDS_ON edge:
index a library after its consumers and they are linked retroactively
(reverse sweep); an empty lookup is explained explicitly with a three-way
classification — declared-but-unindexed dependencies are listed by name
(uncapped), but a dependency that resolves to an indexed repository
without an edge yet is reported as a stale graph with a re-index hint
instead of being falsely called "not indexed"; the reverse direction names
consumers that declare the repo without an edge — never a bare
"No dependencies found."
🔗 MCP Client Configuration
Supported Clients
knot works with any MCP-compatible AI client:
✅ Claude Desktop (Anthropic)
✅ Gemini CLI (Google)
✅ ChatGPT CLI / GPT (OpenAI)
✅ Cursor (AI IDE)
✅ Any standard MCP client
Configuration Examples
Claude Desktop
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"
}
}
}
}Gemini CLI
{
"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"
}
}
}
}ChatGPT / GPT CLI
Similar JSON configuration in your client's MCP configuration file.
⚙️ Configuration Reference
All options can be set via CLI flags, environment variables, or a ~/.config/knot/.env file.
Priority (highest to lowest): CLI flags > environment variables > .env file.
Env Variable | CLI Flag | Default | Description |
|
| (required) | Root directory of the repository to index |
|
| (auto-detected) | Repository name for multi-repo isolation (auto-detected from last path component) |
|
|
| Qdrant server URL |
|
|
| Qdrant collection name |
|
|
| Neo4j Bolt URI |
|
|
| Neo4j username |
|
| (required) | Neo4j password |
|
|
| Embedding model ( |
|
| (derived) | Deprecated (hidden): the dimension is derived from the model. A value that agrees warns; one that contradicts aborts. |
|
|
| Entities per batch |
|
|
| Force full re-index (delete all existing data) |
|
| (none) | Path to CA certificate bundle for corporate SSL proxies |
|
|
| Include YAML/JSON/properties/K8s/Helm files in the index |
| (env only) |
| Log level: |
🤖 Embedding Model Selection
knot supports exactly two embedding models, selected via KNOT_EMBED_MODEL or --embed-model. The default is chosen for backward compatibility: a v1.10.0 user upgrading finds zero re-index and zero configuration change — same model, same collection, same dimension.
Model | dim | Default? | Qdrant collection (derived) |
| 384 | yes |
|
| 768 | no |
|
The supported set is closed: the whole model universe for knot is this table (src/pipeline/embed/model.rs), and adding a future model must be a one-row change there. The four models available in v1.10.0 only (BGESmallENV15, MultilingualE5Small, JinaEmbeddingsV2BaseCode, NomicEmbedTextV15) were removed on purpose — setting one aborts startup with an error listing the two accepted names. The vector dimension is derived from the model: KNOT_EMBED_DIM / --embed-dim are hidden and deprecated (a value that agrees emits a deprecation warning; one that contradicts is a hard error because it means you believe a different model is active).
An explicit collection (KNOT_QDRANT_COLLECTION set by CLI, env or .env) always wins; when it is unset, the model's derived collection applies — BGE users could otherwise collide with a fixed-size knot_entities created at 384.
search_hybrid_context re-ranks independently of the model's cosine scale: each candidate pool is normalized before the boosts are applied, so switching model does not require re-tuning the ranker.
Startup guards (model markers)
Every index run records the producing model on the repository's :Repository node. On startup, knot and knot-mcp verify that the configured model matches the collection's real vector dimension and every marked repository:
Dimension mismatch with the collection — aborts with an actionable message (a collection's vector size is fixed at creation).
Every marked repository on another model — aborts, naming both models.
Some repositories on another model — warns and names the repositories that will not appear in semantic search. Scope-limited searches (
search_hybrid_contextwithrepo) specifically return anoteinstead of a silent empty result.Legacy index without markers — the dimension infers the model (
384 ⇒ AllMiniLML6V2,768 ⇒ BGEBaseENV15); a consistent legacy index is never fail-closed and self-heals (writes the marker) on the next index run.
Runbook: opting into BGE-base
# 1. Choose the model (consumers read this too):
export KNOT_EMBED_MODEL=BGEBaseENV15
# 2. Every repository needs a clean re-index; the alternative collection
# knot_entities_bge768 is derived automatically for every run afterwards:
KNOT_REPO_PATH=/path/to/repo KNOT_REPO_NAME=my-repo knot-indexer --clean
# 3. Restart every consumer (knot-mcp servers, knot CLI users).Cost and recall measurements for both models live in docs/measurements/ (model_cost_1_11.md, model_matrix_1_11.md).
🎨 Custom Tree-sitter Queries
The built-in extraction queries (queries/java.scm, queries/typescript.scm, queries/csharp.scm) can be overridden without recompiling:
KNOT_CUSTOM_QUERIES_PATH=/path/to/my/queries ./target/release/knot-indexerPlace java.scm, typescript.scm, and/or csharp.scm in your custom directory. Missing files fall back to built-in defaults.
🔐 Corporate SSL / CA Certificates
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 secretVia CLI flag:
./target/release/knot-indexer \
--custom-ca-certs /etc/ssl/certs/corporate-bundle.pem \
--repo-path /path/to/repo \
--neo4j-password secretVia .env file:
echo "KNOT_CUSTOM_CA_CERTS=/etc/ssl/certs/corporate-bundle.pem" >> ~/.config/knot/.env
./target/release/knot-indexerThis works for all three binaries: knot-indexer, knot-mcp, and knot.
🔄 Workflow Example
Step 1: Index a Java project
./target/release/knot-indexer --repo-path /home/user/my-java-app --neo4j-password secretStep 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-mcpStep 4: Use with Claude Desktop
Claude will list the read-only tool surface in its Tools menu
Ask: "Search for all authentication logic"
Ask: "Find who calls the login method"
Ask: "Explore the structure of UserService.java"
🤖 Auto-Configuring AI Agents
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 ofgrep)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.
🤝 Contributing
Contributions are welcome! Please ensure:
All code passes
cargo clippyandcargo fmtNo new
unsafecode (unsafe_code = "deny"at crate level; one audited exception insrc/utils/mod.rsfor corporate proxy CA bundle injection, documented via#[expect(unsafe_code, reason = "…")])Changes are compatible with Rust 2024 edition
All new functionality includes unit tests
Performance regressions are validated with the benchmark framework before submitting PRs
Development & Code Quality
make check # Run all local quality gates (fmt, clippy, test, dupes)
# Or run gates individually:
cargo clippy --all-targets -- -D warnings # Must pass
cargo fmt -- --check # Must pass
cargo test # Run all unit tests
cargo dupes check # Code duplication checkPerformance Benchmarking
The project includes a three-level benchmarking framework to validate optimizations and detect regressions:
Level 1 — Unit Benchmarks (Criterion):
cargo bench --bench pipeline_bench # Parse + prepare throughput per language
cargo bench --bench graph_upsert_bench # Neo4j UNWIND batching speedup (needs Neo4j)
cargo bench --bench channel_backpressure_bench # Bounded channel overheadLevel 2 — E2E Integration Benchmarks:
# Full pipeline metrics with memory and per-stage timing
./tests/benchmark_e2e.sh --focus rust_e2e --output-dir /tmp/perf_results
# Compare against baseline (fails CI if tolerance exceeded)
scripts/compare_perf_metrics.sh /tmp/perf_results .perf_metrics/baseline.jsonLevel 3 — Token Efficiency Benchmark:
# Measures knot tool output vs grep + file reads on indexed repositories
python3 scripts/token_savings_benchmark.py \
--config scripts/token_savings_tasks.json \
--save-json .perf_metrics/token_savings.jsonUnlike levels 1 and 2 (which measure indexing throughput), this one measures the
consumer side: how many LLM tokens an agent spends to answer a question with
knot versus by reading source files. Requires rg, a built knot binary, the
repositories in the config already indexed, and optionally tiktoken for exact
token counts. See Token Efficiency
for the published results.
Baseline files: .perf_metrics/baseline.json stores the last known good metrics (committed, updated on main/master merges). Tolerance thresholds in .perf_metrics/threshold_tolerances.json control regression gates (±5% time, ±10% memory by default).
CI Integration: The test-performance job in .github/workflows/ci.yml runs after all E2E correctness tests pass, comparing results against baseline and fails the build on regression.
📜 License
This project is licensed under the MIT License. See LICENSE for details.
🚀 Roadmap
For the full release history see CHANGELOG.md.
Upcoming
Long-Term Vision
Go support
IDE plugins (VS Code, IntelliJ, Vim)
Language Server Protocol (LSP) integration
Automated Code Review tool (MCP-based)
Ruby support
💬 Questions?
For issues, feature requests, or discussions, please open a GitHub issue.
Available Tools
7 toolsexplore_fileExplore file anatomyARead-onlyIdempotent
Read-only file anatomy inspection. Use this to list all classes, methods, and properties within a specific source file without reading its entire contents. Provides a structural bird's-eye view of a file, showing entity signatures and docstrings to quickly grasp a module's layout.
Usage: Use AFTER identifying an interesting file via 'search_hybrid_context' to understand its available methods, or before modifying a file. Do NOT use this for searching across multiple files.
Behaviour & Return: Read-only operation. Returns a Markdown-formatted outline of the file's entities, grouped by type (Classes, Methods, Interfaces, Constants, etc.), including line numbers for direct editor navigation. Attribute-usage markup references (html_class, html_id) are summarized in a separate section by default to avoid inflating code lists; set include_markup to true to list them in full. No side effects.
Path handling: file_path should be a repo-relative path (e.g. 'src/services/user.ts'). Absolute paths under your local checkout are also accepted; the tool strips the known local root automatically. The returned file_path is normalized to the same repo-relative form regardless of how it was queried. If the query is ambiguous across multiple repositories, the answer includes an 'ambiguous_path_candidates' list — retry with a longer path or pass repo_name.
Parameter guidance: 'file_path' must be a relative or absolute path to a valid source file. Include 'repo_name' if the file path might be ambiguous across multiple indexed repositories. Set 'include_markup' to true to expand attribute-usage markup tokens.
Supports Java, Kotlin, C#, and TypeScript codebases.
Inputs: file_path (required), repo_name, include_markup.
find_callersFind callers (reverse dependencies)ARead-onlyIdempotent
Read-only reverse dependency lookup. Use this to find all code that references, calls, extends, or implements a specific entity. Answers 'who uses this code?' by querying the graph database. Differs from search tools by providing exact dependency tracking.
Usage: Use for impact analysis before refactoring or to detect dead code. Do NOT use this for semantic feature discovery—use 'search_hybrid_context' instead.
Matching is precedence-based: exact FQN (containing '.' or '::') → FQN suffix (Type.member) → exact name → signature prefix (accept(List) → name prefix (queries under 4 characters) → fuzzy substring (queries of 4+ characters). A trailing parameter list of types addresses one overload: 'Foo.bar(int, int)' resolves 'Foo.bar' through the tiers above and keeps only the overloads whose declared parameter types match (simple type names; generic arguments compared only when written; 'name: Type' accepted); when none matches, the response lists the declared overloads. Overloads sharing an FQN are labelled by their parameter list in the target list and '### Target:' headers. The first tier that matches wins, so an exact name never returns fuzzy noise. Queries shorter than 4 characters resolve by anchored name prefix instead of substring, avoiding substring noise on short strings. Pass a qualified name (Namespace.Type.Member) to disambiguate homonyms. Responses state which tier matched and flag fuzzy results explicitly.
Behaviour & Return: Read-only graph traversal with no side effects. Returns Markdown grouped by relationship type (Calls, Extends, Implements, References, Overridden by, Overrides, Dispatched calls) with exact file paths and line numbers. When every reference and target belongs to one repository, the 'Found N reference(s)' line names it once as (repo: name); otherwise each caller entry and each resolved target states its repository, so rows are attributable when multiple repositories are in scope. For JVM code (Java/Kotlin/Groovy) and C#, 'Overridden by' lists method implementations/overrides in subtypes and 'Overrides' lists the supertype methods a method implements/overrides. 'Dispatched calls' lists callers bound to an override or to a supertype method of the target (dynamic dispatch), each under the method it is statically bound to, so an interface method called only through its implementation is never reported as unused. When the query resolves to more than one entity with that name (homonyms, e.g., 'find_nearest_entity_by_line' in orphans.rs vs rust.rs), results are grouped by target entity showing which specific target each caller references — even when only one of the homonyms has callers. Each caller entry is one line: name, kind, file_path:line_number and, when it is not empty, its signature. When multiple targets exist, each group shows the target's location and signature. References made from test code (test files, Rust #[cfg(test)]) are included in every count but listed only with include_tests=true; each group then ends with '+N in tests'. A file's <module> row (its import) is folded into the other rows of that file.
Entity-kind scope: target resolution is code-only by default — documentation, configuration, build-system and Kubernetes/Helm metadata (markdown_section, config_property, build_dependency, cargo_package, project_identity, k8s_*, helm_*, …) can never be presented as resolved targets. When the filter removed matches, the response says so ('Non-code matches hidden — N entities …'), never silently. Pass kinds='all' (or '*') to disable the filter, or a comma-separated allow-list of exact kinds/aliases ('callable', 'config', 'docs', 'rust_function', 'build_dependency', …) to scope resolution explicitly. The response's resolution.kind_filter field states which scope applied ('code_default', 'any', 'explicit').
Relationship coverage: the buckets cover every edge type the pipeline produces — Calls, Extends, Implements, References, Macro calls (MACRO_CALLS), DOM references (JS → HTML id), CSS class usage (JS → CSS class), script/stylesheet imports, the VCL edges (uses backend/probe/acl, includes, imports vmod, declared-unused) and HTTP routes (ROUTES_TO: the endpoint serving a handler) — plus Overridden by / Overrides / Dispatched calls, and 'HTTP callers (heuristic: client call → endpoint)': the HTTP client calls (OpenFeign, MicroProfile REST Client, Spring @HttpExchange, RestTemplate, WebClient, RestClient; test code excluded) of any indexed repository linked to the target endpoint or handler by HTTP_CALLS — matched by verb, path, service name and context path, never linked when several endpoints match equally well.
Truncation & completeness: the queried name is first resolved to concrete targets (capped at 25 by default). When more targets match than fit the cap, the response states 'Truncated — N targets matched; showing the first M by FQN' and 'Counts below are partial — they cover only the M of N targets shown', so bucket counts are never mistaken for the complete impact set. Raise 'max_targets' (up to 500) to retrieve more targets when the notice reports truncation.
Parameter guidance: 'entity_name' supports exact names or signature fragments (e.g., 'handleRequest' or 'handle(Request'). Include 'repo_name' to filter results to the specific codebase being analyzed.
Supports Java, Kotlin, C#, Rust, and TypeScript codebases.
Inputs: entity_name (required), kinds, repo_name, max_targets, +1 more.
list_endpointsList HTTP endpointsARead-onlyIdempotent
Read-only catalogue of the HTTP endpoints the indexed repositories serve, each with the handler method it routes to. Answers 'which endpoints does this service expose?' and 'which handler serves GET /api/owners/42?'.
Coverage: Java and Kotlin handlers annotated for JAX-RS (class/method @Path + @GET/@POST/@PUT/@DELETE/@PATCH/@HEAD/@OPTIONS) or Spring MVC (class @RequestMapping + @GetMapping/@PostMapping/@PutMapping/@DeleteMapping/@PatchMapping or @RequestMapping(method = ...)). Paths join the class-level and method-level paths, resolve string constants declared in the same file, and drop path-variable patterns ('{id: [0-9]+}' → '{id}'); a part that cannot be resolved is shown as ''. Paths are relative to the application: the context path (server.servlet.context-path, @ApplicationPath) is not applied to the listed paths. 'ANY' marks a @RequestMapping without 'method'. Declarative HTTP clients (@FeignClient, @RegisterRestClient, @HttpExchange interfaces) are not endpoints: their methods, like RestTemplate / WebClient / RestClient call sites, are 'http_client_call' entities, linked to the endpoints they hit.
Usage: Use this for API-surface questions; then run 'find_callers' on the handler FQN for its callers, or on an endpoint name ('GET /api/owners/{id}') for the handler it routes to. Every endpoint is also an 'http_endpoint' entity reachable from 'search_hybrid_context' and 'explore_file', and a handler's 'find_callers' lists the endpoints routing to it under 'HTTP routes' and the client calls hitting them under 'HTTP callers (heuristic)'.
Behaviour & Return: Read-only query with no side effects. Returns a Markdown table with columns: Method, Path, Handler, Location, Repository, ordered by (repository, path, method). At most 1000 rows; the reply states when more matched. When nothing matches, returns 'No HTTP endpoints matched.'.
Parameter guidance: 'method' is optional and case-insensitive ('GET'); 'ANY' endpoints match every method. 'path' is optional and matches segment by segment as a prefix ('/api/owners' matches '/api/owners/{id}' but not '/api/ownership'); an endpoint's '{variable}' segment matches any concrete segment, so a concrete URL path finds its endpoint. 'repo_name' scopes the catalogue.
Inputs: path, method, repo_name.
list_filesList indexed repository filesARead-onlyIdempotent
Read-only listing of the files an indexed repository carries, with entity counts and deterministic order. Answers 'list every file under src/hooks' or 'which files live in src/api/**' without prior path knowledge.
Usage: Use this BEFORE 'search_hybrid_context' when you do not know the codebase layout; then pass the same prefix to the search's optional 'path' parameter to scope results to those files. Do NOT use this to enumerate entities — use 'explore_file' on a file from this listing for its anatomy.
Behaviour & Return: Read-only query with no side effects. Returns a Markdown table with columns: REPOSITORY, FILE, ENTITIES, ordered by (repository, path). When output exceeds 2000 files, the table displays the first 2000 matches alongside a truncation notice stating the exact total when known, or an explicit lower bound when the scan stopped early. When nothing matches the prefix, returns 'No indexed files matched the given path'.
Parameter guidance: 'path' is optional. PREFERRED: a repo-relative directory prefix (e.g. 'src/api') matched on a path boundary, or a glob ('src/**/*_test.rs'). Prefixes and globs page all indexed files in pages with per-page boundary filtering without dropping candidates. Absolute paths under the local checkout are accepted and normalized like 'explore_file'. Omit to list every indexed file (capped; the reply notes truncation).
Parameter guidance: 'repo_name' scopes the listing. Accepts a single repository name or a comma-separated list; include it when several indexed repositories may share path shapes.
Supports all languages indexed by knot.
Inputs: path, repo_name.
list_repo_dependenciesList cross-repository dependenciesARead-onlyIdempotent
Read-only cross-repository dependency graph lookup. Shows which repositories depend on each other via build system declarations (Maven, Gradle, Cargo, npm, NuGet). Answers 'which repos does this repo depend on?' and 'which repos depend on this repo?'.
Usage: Use BEFORE cross-repo analysis to discover which other indexed repos are available for call tracing. Use reverse mode for impact analysis before making breaking changes in shared libraries.
Behaviour & Return: Read-only graph traversal with no side effects. Returns a JSON array of repository names. Empty results mean no DEPENDS_ON relationships exist for that repo. Empty lookups are explained in the response text with a three-way classification: declares-but-resolves-without-edge (stale graph, re-index hint), declares-but-nothing-resolves (not indexed), or nothing declared; the reverse direction names consumers that declare the repo without an edge yet.
Parameter guidance: 'repo_name' is required and must match the name used during indexing. 'max_depth' defaults to 3 (1 = direct only) and applies to both directions — in reverse mode it follows dependents transitively. 'reverse' toggles between forward and reverse dependency lookup.
Supports all build systems indexed by knot: Maven, Gradle, Cargo, npm, NuGet (.csproj + Central Package Management via Directory.Packages.props). C# repos that previously reported build_system: "none" now report "nuget" on re-index; knot-indexer --clean is recommended for immediate effect.
Inputs: repo_name (required), reverse, max_depth.
list_repositoriesList indexed repositoriesARead-onlyIdempotent
Read-only listing of all indexed repositories with optional name filtering. Shows repository metadata including entity count, file count, build system, and primary language. Answers 'what codebases have I indexed?' and 'which repositories match this name?'.
Usage: Use this tool FIRST to discover available codebases before searching or exploring. Once you know the repository name, switch to 'search_hybrid_context' for semantic search, 'find_callers' for reverse dependency lookup, 'explore_file' for file anatomy, or 'list_repo_dependencies' for cross-repo dependency graphs. Do NOT use this tool to search for code entities — use 'search_hybrid_context' instead.
Behaviour & Return: Read-only query with no side effects. Returns a Markdown table with columns: REPO, BUILD SYSTEM, LANGUAGE, FILES, ENTITIES. When no repositories match the filter, returns 'No repositories found.'
Parameter guidance: 'filter' is optional. When provided, only repositories whose name contains the filter string are returned (case-insensitive substring match). Omit to list all indexed repositories.
Supports all languages and build systems indexed by knot.
Inputs: filter.
search_hybrid_contextHybrid semantic + structural searchARead-onlyIdempotent
Read-only semantic and structural code search combining vector embeddings with graph analysis. Use this for initial codebase discovery to find features by their meaning (e.g., 'user authentication'). Locates code based on natural language descriptions instead of exact keywords, returning relevant files, signatures, and documentation.
⚠️ PREREQUISITE: This tool requires an active knot-mcp server with vector database (Qdrant) and graph database (Neo4j) initialized.
Behavior & Return: Performs a read-only dual query against vector DB (for semantic similarity) and graph DB (for architectural relationships). Returns Markdown-formatted results with file paths, line numbers, code snippets, and cross-repository dependencies. No side effects.
Usage: Use as your FIRST step when exploring unfamiliar code or discovering architectural patterns. Do NOT use this to find all usages of a specific function—use the 'find_callers' tool for that instead.
Ranking contract: results are kind-aware — function/method/class/struct definitions outrank markdown docs, test files, config properties and build-dependency entities for natural-language queries; callers and helpers appear as context attached to a definition, never as substitutes. The shared entry point of the highest-ranked helpers outranks those helpers a loose paraphrase surfaces.
Relationship summary: each result's 'Called by' / 'Called via dispatch' counts come from the graph edges of that exact entity — the same edges 'find_callers' reports for its fully qualified name; same-named entities elsewhere never contribute. 'Calls' lists callees qualified with their owning type or module, capped at 8 plus '+N more'. Callers in test code count toward the totals but are shown as 'N in tests' unless 'include_tests' is true; a sample in the result's own file reads 'name (same file)'.
Detail: 'detail: "brief"' renders one line per result (kind, file:line, caller/callee counts) to scan many hits cheaply; expand the one you need with 'find_callers' / 'explore_file' or a default 'full' search.
Generic-verb guard: an entity merely named after a generic verb or noun (find/get/create/build/acquire/borrow/current/…) does not win on that name alone; the full name boost is paid only when the entity's container context (FQN) corroborates a second query token.
Recall contract: entity embeds carry identifier tokens and the tokenized call names of the entity's body, so a paraphrase of what a definition does (even one with no doc comment) still surfaces it. Entities whose identifier shares a word with the query enter the candidate pool by token match alone.
Result bound: 'max_results' is 1-100 (default 5) and is enforced — a larger request is clamped to 100 and the reply says so. There is no pagination: when the bound is not enough, narrow the scope with 'kinds' / 'path' / 'repo_name' or refine the query rather than raising the limit.
Parameter guidance: 'query' should be 2-5 words describing functionality. Increase 'max_results' to 10-20 for broad discovery, keep at 5 for focused search. Include 'repo_name' in your first query to avoid cross-repository pollution.
Supports Java, Kotlin, C#, and TypeScript codebases.
Inputs: query (required), path, kinds, detail, +3 more.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 7 tools
Each tool has a clearly distinct role: semantic discovery, reverse dependency lookup, file anatomy, file listing, endpoint cataloguing, repository dependency analysis, and repository listing. The descriptions explicitly warn against common misuses, such as using search_hybrid_context instead of find_callers, which reduces overlap. There are no tools that appear to do the same thing.
All names use snake_case and are verb-led, with a predictable noun-oriented pattern (list_files, list_endpoints, find_callers, explore_file). Minor deviations include search_hybrid_context using an adjective in the noun phrase and repo/repositories abbreviation inconsistency, but the set remains readable and predictable.
Seven tools is well-scoped for a read-only code intelligence server. Each tool covers a distinct layer of the domain—repository discovery, file navigation, semantic search, dependency tracing, and API surface inspection—without obvious redundancy.
The surface covers core discovery and impact-analysis workflows: repository listing, file listing, file anatomy, semantic search, reverse callers, HTTP endpoints, and cross-repository dependencies. Minor gaps exist around forward call graph retrieval (callees) and fetching full entity bodies, though agents can often work around these using search results or file exploration.
Maintenance
Related MCP Connectors
Codebase intelligence for AI agents — dead code, blast radius, ownership.
Code intelligence platform for AI agents. 20 tools for architecture, security & impact analysis.
Codebase intelligence for AI coding agents: graph, git history, docs, decisions, code health.
18,130Code intelligence for coding agents: semantic, AST, graph, and full-text search. 279+ languages.
Related MCP Servers
- AlicenseBqualityDmaintenanceA complete MCP server for Retrieval-Augmented Generation with file management and vector memory for agents. Supports multiple document formats (PDF, DOCX, TXT, MD, CSV, JSON) with semantic search using Hugging Face embeddings and ChromaDB for efficient vector storage.1110 npm1MIT
- AlicenseNot gradedqualityNot gradedmaintenanceTurns Claude Desktop into a personal document question-answering system using local vector search. Index PDF, TXT, and Markdown documents into collections and get answers based strictly on your documents with zero hallucination.10 npm-
- AlicenseNot gradedqualityDmaintenanceA graph-powered code intelligence engine that indexes codebases into a structural knowledge graph to provide AI agents with deep context on function calls, types, and execution flows. It offers local, zero-dependency tools for hybrid search, impact analysis, and dead code detection across Python, JavaScript, and TypeScript projects.1,036 PyPI816MIT
- FlicenseNot gradedqualityDmaintenanceA minimalist indexing tool that provides AI agents with semantic search and structural AST parsing for deep codebase understanding. It enables autonomous agents to navigate large codebases predictably using vector embeddings and native language server capabilities like definition and reference tracking.-