create_directory
Create new directories in your notes system to organize content, including nested folders in a single operation.
Instructions
Create a new directory in your notes. Can create nested directories in one operation. Path should be relative to your notes directory.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes | Directory path to create, relative to notes directory |
Implementation Reference
- src/tools/filesystem.ts:326-359 (handler)The core handler function for the 'create_directory' tool. It validates the input path, ensures it's within the notes directory for security, creates the directory using fs.mkdir with recursive: true, and returns a success or error message.export async function handleCreateDirectory(notesPath: string, args: CreateDirectoryArgs): Promise<ToolCallResult> { try { // Validate path parameter if (!args.path) { throw new Error("'path' parameter is required"); } const dirPath = path.join(notesPath, args.path); // Ensure the path is within allowed directory if (!dirPath.startsWith(notesPath)) { throw new Error("Access denied - path outside notes directory"); } try { await fs.mkdir(dirPath, { recursive: true }); return { content: [{ type: "text", text: `Successfully created directory: ${args.path}` }] }; } catch (error) { const errorMessage = error instanceof Error ? error.message : String(error); throw new Error(`Error creating directory: ${errorMessage}`); } } catch (error) { const errorMessage = error instanceof Error ? error.message : String(error); return { content: [{ type: "text", text: `Error creating directory: ${errorMessage}` }], isError: true }; } }
- src/tools/filesystem.ts:117-132 (schema)The tool definition including name, description, and input schema for 'create_directory' returned by getFilesystemToolDefinitions().{ name: "create_directory", description: "Create a new directory in your notes. " + "Can create nested directories in one operation. " + "Path should be relative to your notes directory.", inputSchema: { type: "object", properties: { path: { type: "string", description: "Directory path to create, relative to notes directory" } }, required: ["path"] }, }
- src/tools/filesystem.ts:39-41 (schema)Type definition for the arguments accepted by the create_directory handler.interface CreateDirectoryArgs { path: string; }
- src/tools/index.ts:360-361 (registration)Registration in the main tool dispatcher switch statement in handleToolCall, which routes calls to the filesystem handler.case "create_directory": return await handleCreateDirectory(notesPath, args);
- src/tools/index.ts:204-204 (registration)The filesystem tools (including create_directory) are spread into the main getToolDefinitions() array for overall tool registration....filesystemTools