create_directory
Generate or verify the existence of directories with a single command. Supports creating nested directories in one operation, ensuring file system organization within designated 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/tools/filesystem.ts:90-93 (handler)The core handler function that performs path validation and creates the directory using Node.js fs.mkdir with recursive option to handle nested paths.export async function createDirectory(dirPath: string): Promise<void> { const validPath = await validatePath(dirPath); await fs.mkdir(validPath, { recursive: true }); }
- src/tools/schemas.ts:45-47 (schema)Zod schema defining the input shape for the create_directory tool: requires a 'path' string.export const CreateDirectoryArgsSchema = z.object({ path: z.string(), });
- src/server.ts:150-155 (registration)Tool registration in the ListTools response, 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/server.ts:287-292 (registration)Dispatch handler in CallToolRequestSchema that parses input with schema and invokes the createDirectory function.case "create_directory": { const parsed = CreateDirectoryArgsSchema.parse(args); await createDirectory(parsed.path); return { content: [{ type: "text", text: `Successfully created directory ${parsed.path}` }], };