Skip to main content

Module source

Module source 

Source
Expand description

Source-file tooling: read_source / grep / list_source.

Operates on a dynamic source root provider — a closure returning the active list of allowed dirs at the moment of each tool call. GitHub-workspace mode wires this to the active repo’s path; local- workspace mode wires it to the bound root (re-routed on each set_root_dir call); --source-root and --watch modes wire it to a fixed root. An empty list signals “no active source” and the tools return a friendly error.

All path traversal protection is done by canonicalising the resolved path against the allowed dirs before any I/O happens.

Design: stay close to the existing Python mcp_methods semantics (line numbers, header format, “showing N of M matches”, etc.) so a manifest written for the legacy Python server returns visually similar output.

Structs§

GrepOpts
ListOpts
ReadOpts

Functions§

grep
list_source
read_source
Read a file from one of the allowed source dirs.
resolve_dir_under_roots
Resolve a path under the first allowed dir for directory listing. Differs from resolve_under_roots in that it accepts directories, non-existent paths included only after canonicalisation succeeds.
resolve_under_roots
Resolve file_path against the allowed dirs and verify the canonical path lives under at least one of them. Returns None when the file is missing or the path traversal lands outside the sandbox.

Type Aliases§

SourceRootsProvider
Provider returning the current allowed source dirs.