Skip to main content
Glama
MrGNSS

Desktop Commander MCP

create_directory

Create new directories or ensure existing ones are available, including nested structures, within permitted locations on your computer.

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

  • The core handler function that performs the directory creation after path validation. Uses fs.mkdir with recursive option to create nested directories.
    export async function createDirectory(dirPath: string): Promise<void> {
        const validPath = await validatePath(dirPath);
        await fs.mkdir(validPath, { recursive: true });
    }
  • Zod schema defining the input arguments for the create_directory tool: a single 'path' string.
    export const CreateDirectoryArgsSchema = z.object({
      path: z.string(),
    });
  • src/server.ts:149-155 (registration)
    Tool registration in the listTools handler, specifying 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),
    },
  • src/server.ts:287-293 (registration)
    Dispatch handler in CallToolRequest that parses args, calls the createDirectory function, and formats the response.
    case "create_directory": {
      const parsed = CreateDirectoryArgsSchema.parse(args);
      await createDirectory(parsed.path);
      return {
        content: [{ type: "text", text: `Successfully created directory ${parsed.path}` }],
      };
    }
  • Security helper function used by createDirectory to validate and resolve the path, ensuring it's within allowed directories and handling symlinks.
    export async function validatePath(requestedPath: string): Promise<string> {
        const expandedPath = expandHome(requestedPath);
        const absolute = path.isAbsolute(expandedPath)
            ? path.resolve(expandedPath)
            : path.resolve(process.cwd(), expandedPath);
            
        const normalizedRequested = normalizePath(absolute);
    
        // Check if path is within allowed directories
        const isAllowed = allowedDirectories.some(dir => normalizedRequested.startsWith(normalizePath(dir)));
        if (!isAllowed) {
            throw new Error(`Access denied - path outside allowed directories: ${absolute}`);
        }
    
        // Handle symlinks by checking their real path
        try {
            const realPath = await fs.realpath(absolute);
            const normalizedReal = normalizePath(realPath);
            const isRealPathAllowed = allowedDirectories.some(dir => normalizedReal.startsWith(normalizePath(dir)));
            if (!isRealPathAllowed) {
                throw new Error("Access denied - symlink target outside allowed directories");
            }
            return realPath;
        } catch (error) {
            // For new files that don't exist yet, verify parent directory
            const parentDir = path.dirname(absolute);
            try {
                const realParentPath = await fs.realpath(parentDir);
                const normalizedParent = normalizePath(realParentPath);
                const isParentAllowed = allowedDirectories.some(dir => normalizedParent.startsWith(normalizePath(dir)));
                if (!isParentAllowed) {
                    throw new Error("Access denied - parent directory outside allowed directories");
                }
                return absolute;
            } catch {
                throw new Error(`Parent directory does not exist: ${parentDir}`);
            }
        }
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden. It discloses some behavioral traits: it can create nested directories and is restricted to allowed directories. However, it lacks critical details such as permissions required, whether it overwrites existing directories, error handling, or response format, leaving significant gaps for a mutation tool.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is front-loaded with the core purpose and efficiently adds key constraints in two sentences. Each sentence adds value: the first defines the action and capability, the second sets a critical limitation. There is no wasted text, though it could be slightly more structured.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity as a mutation operation with no annotations, no output schema, and low schema coverage, the description is incomplete. It misses details on permissions, error cases, return values, and how it interacts with siblings like 'write_file', making it inadequate for safe and effective use by an agent.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema has 0% description coverage for the single parameter 'path', and the description adds no explicit parameter information. However, it implies the 'path' parameter is used to specify the directory location, including nested structures. This provides minimal semantic value beyond the schema, aligning with the baseline for low coverage.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose with specific verbs ('create' and 'ensure') and resource ('directory'), and distinguishes it from siblings like 'list_directory' or 'move_file'. However, it doesn't explicitly differentiate from 'write_file' which might handle file creation, leaving slight ambiguity.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage for creating or ensuring directories, including nested ones, but provides no explicit guidance on when to use this versus alternatives like 'write_file' for files or 'list_allowed_directories' for checking permissions. The constraint 'only works within allowed directories' hints at prerequisites but lacks detail on alternatives or exclusions.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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