approve_directory
Grant temporary access to a specific directory for secure command execution within a session, enabling controlled system interaction while maintaining security boundaries.
Instructions
Approve access to a directory for the current session.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| directory | Yes | The directory to approve access to | |
| session_id | Yes | The session ID | |
| remember | No | Whether to remember this approval |
Implementation Reference
- temp/src/cmd_line_mcp/server.py:526-566 (handler)The main handler implementation for the approve_directory tool. It validates the directory and delegates the actual approval logic to the session_manager.
async def approve_directory( directory: str, session_id: str, remember: bool = True ) -> Dict[str, Any]: """ Approve access to a directory for the current session. Args: directory: The directory to approve access to session_id: The session ID remember: Whether to remember this approval for the session Returns: A dictionary with approval status """ # Normalize the directory path normalized_dir = normalize_path(directory) # Check if directory is already whitelisted globally if is_directory_whitelisted(normalized_dir, self.whitelisted_directories): return { "success": True, "message": f"Directory '{normalized_dir}' is already globally whitelisted", "directory": normalized_dir, } # Check if directory is already approved for this session if self.session_manager.has_directory_approval(session_id, normalized_dir): return { "success": True, "message": f"Directory '{normalized_dir}' is already approved for this session", "directory": normalized_dir, } # Approve the directory for this session if remember: self.session_manager.approve_directory(session_id, normalized_dir) return { "success": True, "message": f"Directory '{normalized_dir}' approved for this session", "directory": normalized_dir, }