Skip to main content

Module source

Module source 

Source
Expand description

Source-tree reads for the MCP server.

Browses and reads the repository’s working tree via git plumbing so that gitignore handling and the tracked-set semantics come for free and stay consistent with the git-context tools. The “working tree” is defined as tracked files plus untracked-but-not-ignored files; gitignored paths (build artifacts, secrets) are excluded throughout.

read_file is confined to the repository root: the requested path is resolved under the root, canonicalised, and verified to still lie within it, so ../absolute/symlink escapes are refused before any file outside the root is read (the same guard as super::docs::read_doc). It additionally refuses gitignored paths via git check-ignore.

Degradation contract (design D4): a non-git directory or a search with no matches yields an empty result, never a transport error.

Structs§

CodeMatch
One match returned by search_code.
ReadOutcome
Outcome of a read_file call: either the file’s working-tree content, or a refusal/absence carrying a human-readable reason.

Functions§

list_files
Lists the repository’s working-tree files (tracked plus untracked-but-not-ignored), optionally scoped to subpath.
read_file
Reads one file from the local working tree, confined to the repository root and refusing gitignored paths.
search_code
Searches file contents across the repository’s working tree (tracked plus untracked-but-not-ignored), optionally scoped to subpath.