create_directory
Create directories and their parent folders automatically within allowed paths using the Filesystem MCP Server. Ensures path compliance and handles existing directories without errors.
Instructions
Create a directory, including any necessary parent directories.
Args: path (str): Directory path to create (absolute or relative to allowed directories)
Returns: str: Success message with created directory path, or error message if failed
Note: - Path must be within allowed directory roots - Creates parent directories if they don't exist - No error if directory already exists
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes |
Implementation Reference
- main.py:382-402 (handler)The create_directory tool handler: creates directory using pathlib.mkdir with parents=True and exist_ok=True after resolving path with _resolve. Returns success or error message.def create_directory(path: str) -> str: """Create a directory, including any necessary parent directories. Args: path (str): Directory path to create (absolute or relative to allowed directories) Returns: str: Success message with created directory path, or error message if failed Note: - Path must be within allowed directory roots - Creates parent directories if they don't exist - No error if directory already exists """ try: rp = _resolve(path) rp.mkdir(parents=True, exist_ok=True) return f"Ensured directory {rp}" except Exception as e: return _human_error(e, "creating directory")