create_directory
Create nested directories in your MCP Notes system to organize and structure your personal knowledge base efficiently. Specify the relative path for easy setup.
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 handler function that validates the path, ensures it's within the notes directory, and creates the directory using fs.mkdir with recursive: true. Returns 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)Tool definition object for 'create_directory' including the input schema requiring a 'path' string.{ 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/index.ts:360-361 (registration)Switch case in handleToolCall that registers and dispatches the 'create_directory' tool to its handler.case "create_directory": return await handleCreateDirectory(notesPath, args);
- src/tools/filesystem.ts:39-41 (schema)TypeScript interface defining the input arguments for the create_directory handler.interface CreateDirectoryArgs { path: string; }
- src/tools/index.ts:15-15 (registration)Import of the handleCreateDirectory function from filesystem.js for use in tool dispatching.handleCreateDirectory,