create_directory
Creates a new directory and all required parent directories for file organization.
Instructions
Create a directory (and all parent directories).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes | Directory path to create | |
| workspace_root | No | Workspace root directory (optional) |
Implementation Reference
- src/index.ts:485-489 (handler)Handler for the create_directory tool. Resolves the workspace path, then creates the directory (and all parent directories) using mkdir with recursive: true.
case "create_directory": { const dirPath = resolveWorkspacePath(a.path as string, a.workspace_root as string | undefined); await mkdir(dirPath, { recursive: true }); return { content: [{ type: "text", text: `Created: ${dirPath}` }] }; } - src/index.ts:221-232 (schema)Schema definition for create_directory tool: requires a 'path' string, optional 'workspace_root' string, and describes the tool as creating a directory with all parent directories.
{ name: "create_directory", description: "Create a directory (and all parent directories).", inputSchema: { type: "object", properties: { path: { type: "string", description: "Directory path to create" }, workspace_root: { type: "string", description: "Workspace root directory (optional)" }, }, required: ["path"], }, }, - src/index.ts:221-232 (registration)Tool registration in the TOOLS array that is exposed via ListToolsRequestSchema. The tool definition is added to the array of available tools.
{ name: "create_directory", description: "Create a directory (and all parent directories).", inputSchema: { type: "object", properties: { path: { type: "string", description: "Directory path to create" }, workspace_root: { type: "string", description: "Workspace root directory (optional)" }, }, required: ["path"], }, }, - src/index.ts:59-63 (helper)Helper used by create_directory handler to resolve the path argument relative to the workspace root.
function resolveWorkspacePath(filePath: string, workspaceRoot?: string): string { if (filePath.startsWith("/") || /^[A-Za-z]:/.test(filePath)) return filePath; const base = workspaceRoot ?? process.cwd(); return resolve(join(base, filePath)); }