Skip to main content
Glama

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
NameRequiredDescriptionDefault
pathYesDirectory path to create, relative to notes directory

Implementation Reference

  • 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 }; } }
  • 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"] }, }
  • Type definition for the arguments accepted by the create_directory handler.
    interface CreateDirectoryArgs { path: string; }
  • 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);
  • The filesystem tools (including create_directory) are spread into the main getToolDefinitions() array for overall tool registration.
    ...filesystemTools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/mikeysrecipes/mcp-notes'

If you have feedback or need assistance with the MCP directory API, please join our Discord server