create_directory
Create new directories or ensure existing ones are available, including nested structures, within permitted file system locations.
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 main handler function that validates the directory path 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/server.ts:287-292 (handler)The dispatch handler in the main tool request handler that parses input arguments using the schema and calls the specific createDirectory function.case "create_directory": { const parsed = CreateDirectoryArgsSchema.parse(args); await createDirectory(parsed.path); return { content: [{ type: "text", text: `Successfully created directory ${parsed.path}` }], };
- src/tools/schemas.ts:45-47 (schema)Zod schema defining the input arguments for the create_directory tool: a required 'path' string.export const CreateDirectoryArgsSchema = z.object({ path: z.string(), });
- src/server.ts:149-155 (registration)Registers the create_directory tool in the MCP server tools list, providing name, description, and JSON schema derived from Zod 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), },