create_directory
Automate directory creation or ensure directory existence in a single operation with Desktop Commander MCP. Supports nested directories and operates within specified allowed paths.
Instructions
Create a new directory or ensure a directory exists. Can create multiple nested directories in one operation. Only works within allowed directories.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes |
Implementation Reference
- src/server.ts:287-292 (handler)MCP tool handler for 'create_directory' that parses args with schema, calls filesystem helper, and returns success messagecase "create_directory": { const parsed = CreateDirectoryArgsSchema.parse(args); await createDirectory(parsed.path); return { content: [{ type: "text", text: `Successfully created directory ${parsed.path}` }], };
- src/server.ts:149-155 (registration)Tool registration in ListTools handler, defining name, description, and input schema{ name: "create_directory", description: "Create a new directory or ensure a directory exists. Can create multiple " + "nested directories in one operation. Only works within allowed directories.", inputSchema: zodToJsonSchema(CreateDirectoryArgsSchema), },
- src/tools/schemas.ts:45-47 (schema)Zod schema for input validation: requires 'path' stringexport const CreateDirectoryArgsSchema = z.object({ path: z.string(), });
- src/tools/filesystem.ts:90-93 (helper)Core filesystem function that validates path security and creates directory recursivelyexport async function createDirectory(dirPath: string): Promise<void> { const validPath = await validatePath(dirPath); await fs.mkdir(validPath, { recursive: true }); }