Skip to main content

Module roots

Module roots 

Source

Functions§

best_root_from_uris
Select the best project root from MCP client roots. Only considers paths that are existing directories. Prefers roots with project markers (.git, Cargo.toml, etc.). Falls back to the first valid directory if none have markers — but never accepts a broad/unsafe root (HOME, filesystem root, agent sandbox dirs), which would otherwise contaminate sessions across projects.
derive_project_root_from
The project an MCP session started in cwd binds to. The dashboard binds a folder by the same rule, so both name one project the same way.
derive_project_root_from_cwd
pinned_root
The project root the operator pinned with LEAN_CTX_PROJECT_ROOT.
root_from_env
Detect project root from IDE-specific environment variables.
root_selection_from_uris
best_root_from_uris with the other candidates, so a choice among several roots can be named (AP04-G7).
session_root
The session’s project root from the host env and the server’s working dir.
uri_to_path
Parse a file:// URI to a validated local path string. Rejects non-file URIs, null bytes, .. traversal, and non-directory paths. Returns a canonicalized absolute path.
valid_dir_paths_from_uris
Filter and validate URIs to existing directories only.
workspace_roots_from_env
All valid, safe workspace directories from WORKSPACE_FOLDER_PATHS.
workspace_selection_from_env
Best project root from the IDE-injected WORKSPACE_FOLDER_PATHS env var.