cd
Change the current working directory in a virtual filesystem workspace to navigate and organize files efficiently.
Instructions
Change current working directory.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes |
Implementation Reference
- src/chuk_mcp_vfs/vfs_tools.py:288-308 (handler)The main handler function for the 'cd' tool that changes the current working directory in the virtual filesystem.async def cd(self, path: str) -> ChangeDirectoryResponse: """ Change current working directory. Args: path: Directory path Returns: ChangeDirectoryResponse with new cwd """ vfs = self.workspace_manager.get_current_vfs() resolved_path = self.workspace_manager.resolve_path(path) # Verify path exists and is a directory node = await vfs.get_node_info(resolved_path) if not node or not node.is_dir: raise ValueError(f"Not a directory: {resolved_path}") self.workspace_manager.set_current_path(resolved_path) return ChangeDirectoryResponse(success=True, cwd=resolved_path)
- src/chuk_mcp_vfs/server.py:132-135 (registration)Registration of the 'cd' tool in the MCP server using @server.tool decorator, which delegates to VFSTools.cd.async def cd(path: str): """Change current working directory.""" return await vfs_tools.cd(path)
- src/chuk_mcp_vfs/models.py:219-224 (schema)Pydantic model defining the response schema for the 'cd' tool.class ChangeDirectoryResponse(BaseModel): """Response from cd operation""" success: bool cwd: str