list_workspace
List files and directories in the configured workspace root. Specify a path to explore subdirectories and set max depth to limit recursion.
Instructions
List files and directories under the configured workspace root.
Tool call template
This tool declares no required parameters. Add optional parameters from the input schema as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {},
"name": "list_workspace"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | No | . | |
| max_depth | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |
Implementation Reference
- The actual handler function for the 'list_workspace' tool. It uses a closure-based registration pattern with @mcp.tool() decorator. Lists files/directories under the workspace root with configurable max_depth, using _resolve_path to validate the path is within the workspace.
def list_workspace(path: str = ".", max_depth: int = 2) -> list[str]: """List files and directories under the configured workspace root.""" root = _resolve_path(path) entries: list[str] = [] max_depth = max(0, max_depth) base_depth = len(root.parts) for item in sorted(root.rglob("*")): depth = len(item.parts) - base_depth if depth > max_depth: continue entries.append(str(item.relative_to(config.workspace_root))) if root.is_dir(): entries.insert(0, str(root.relative_to(config.workspace_root))) return entries - src/friday_mcp_server/tools/__init__.py:10-11 (registration)Registers the workspace module (including list_workspace) by calling workspace.register(mcp, config=config).
workspace.register(mcp, config=config) skills.register(mcp, skill_store=skill_store) - The function signature serves as the schema: 'path: str = "."' and 'max_depth: int = 2' are input parameters; the return type is 'list[str]'.
def list_workspace(path: str = ".", max_depth: int = 2) -> list[str]: - _resolve_path helper function used by list_workspace to resolve and validate that the given path is within the workspace root (or allowed via allow_external_paths).
def _resolve_path(path: str) -> Path: raw_path = Path(path).expanduser() resolved = ( raw_path.resolve() if raw_path.is_absolute() else (config.workspace_root / raw_path).resolve() ) if config.allow_external_paths: return resolved if resolved != config.workspace_root and config.workspace_root not in resolved.parents: raise ValueError( f"Path '{path}' is outside the workspace root {config.workspace_root}." ) return resolved