wesktop v0.7.0 /src.wesktop.mcp_tools.filesystem
On this page

Filesystem MCP tools scoped to an agent's worktree: read, write, edit, list, and search files with path traversal guard enforcement.

#src.wesktop.mcp_tools.filesystem

#src.wesktop.mcp_tools.filesystem

Filesystem MCP tools scoped to an agent's worktree: read, write, edit, list, and search files with path traversal guard enforcement.

All paths are relative to the worktree root. Traversal outside the worktree is blocked by _guard_path.

#_guard_path

python
def _guard_path(worktree: Path, relative: str) -> Path

Resolve a relative path and ensure it stays under the worktree.

Raises ValueError on path traversal attempts.

#read_file

python
def read_file(worktree: str, path: str) -> str

Read a file from the worktree. Path is relative to worktree root.

#write_file

python
def write_file(worktree: str, path: str, content: str) -> str

Write content to a file in the worktree. Creates parent dirs as needed.

#edit_file

python
def edit_file(worktree: str, path: str, old_text: str, new_text: str) -> str

Find and replace text in a file. Fails if old_text is not found.

#list_files

python
def list_files(worktree: str, path: str='') -> str

List directory contents under the worktree.

Returns one entry per line: 'd ' for directories, 'f ()' for files.

#search_files

python
def search_files(worktree: str, pattern: str, path: str='') -> str

Search file contents using ripgrep. Returns matching lines with context.