Skip to main content

Module code

Module code 

Source
Expand description

MCP tool handlers for the tree-sitter code knowledge graph.

These map parsed code symbols (see crate::code) onto a knowledge graph so the regular search/traversal primitives work on code, and expose code-focused tools: code_index, code_watch, code_outline, code_search, code_get_symbol.

Symbols are stored as entities named {relpath}::{symbol} with type code:<kind>; metadata (file, line range, signature, doc) lives in observations. Edges: defines (file→symbol), calls/references (caller→callee, resolved only when the callee name is unambiguous).

Multiple independent projects are supported by physical partitioning: each code_index/code_watch call takes an optional project identifier (default "default") that selects a dedicated SQLite database, opened via crate::code_registry. Projects therefore never collide and are fully isolated from the main memory graph and from the knowledge-graph tools.

Functions§

handle_code_get_symbol
handle_code_index
handle_code_outline
handle_code_search
handle_code_watch
Start watching a project directory for file changes and re-index on modification. Spawns a background thread that monitors the directory tree with a debounced file-watcher. The initial index runs synchronously before returning.