Skip to main content
Glama

create_directory

Automate directory creation or ensure directory existence in a single operation with Desktop Commander MCP. Supports nested directories and operates within specified allowed paths.

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
NameRequiredDescriptionDefault
pathYes

Implementation Reference

  • MCP tool handler for 'create_directory' that parses args with schema, calls filesystem helper, and returns success message
    case "create_directory": { const parsed = CreateDirectoryArgsSchema.parse(args); await createDirectory(parsed.path); return { content: [{ type: "text", text: `Successfully created directory ${parsed.path}` }], };
  • src/server.ts:149-155 (registration)
    Tool registration in ListTools handler, defining name, description, and input 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), },
  • Zod schema for input validation: requires 'path' string
    export const CreateDirectoryArgsSchema = z.object({ path: z.string(), });
  • Core filesystem function that validates path security and creates directory recursively
    export async function createDirectory(dirPath: string): Promise<void> { const validPath = await validatePath(dirPath); await fs.mkdir(validPath, { recursive: true }); }

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/MrGNSS/ClaudeDesktopCommander'

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