Skip to main content
Glama

create_directory

Create directories at specified paths with optional parent directory creation for organizing files in MCP File Forge's secure environment.

Instructions

Create a directory

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathYesPath to create
recursiveNoCreate parent directories

Implementation Reference

  • The core logic for creating a directory, implemented in `createDirectoryImpl` within `src/tools/write.ts`.
    async function createDirectoryImpl(input: CreateDirectoryInput): Promise<ToolResult> {
      try {
        const absolutePath = path.resolve(input.path);
    
        await fs.mkdir(absolutePath, { recursive: input.recursive });
    
        return {
          content: [
            {
              type: 'text',
              text: JSON.stringify({
                success: true,
                path: absolutePath,
              }),
            },
          ],
        };
      } catch (error) {
        const err = error as NodeJS.ErrnoException;
    
        if (err.code === 'EEXIST') {
          return {
            content: [
              {
                type: 'text',
                text: JSON.stringify({
                  success: true,
                  path: path.resolve(input.path),
                  note: 'Directory already exists',
                }),
              },
            ],
          };
        }
    
        if (err.code === 'EACCES') {
          return {
            isError: true,
            content: [
              {
                type: 'text',
                text: JSON.stringify({
                  code: 'PERMISSION_DENIED',
                  message: `Permission denied: ${input.path}`,
                }),
              },
            ],
          };
        }
    
        return {
          isError: true,
          content: [
            {
              type: 'text',
              text: JSON.stringify({
                code: 'UNKNOWN_ERROR',
                message: `Error creating directory: ${err.message}`,
              }),
            },
          ],
        };
      }
    }
  • Zod schema definition and TypeScript type for `create_directory` tool inputs.
    // Create directory input
    export const CreateDirectoryInputSchema = z.object({
      path: z.string().describe('Path to create'),
      recursive: z.boolean().default(true).describe('Create parent directories'),
    });
    
    export type CreateDirectoryInput = z.infer<typeof CreateDirectoryInputSchema>;
  • Registration of the `create_directory` tool in the MCP server within `registerWriteTools`.
    // create_directory tool
    server.tool(
      'create_directory',
      'Create a directory',
      {
        path: z.string().describe('Path to create'),
        recursive: z.boolean().optional().describe('Create parent directories'),
      },
      async (args) => {
        const input = CreateDirectoryInputSchema.parse(args);
        return await createDirectoryImpl(input);
      }
    );
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 of behavioral disclosure. 'Create a directory' implies a write/mutation operation but reveals nothing about permissions required, whether the operation is idempotent, what happens if the directory already exists, error conditions, or side effects. For a mutation tool with zero annotation coverage, this is a significant gap in behavioral transparency.

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

Conciseness5/5

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

The description is maximally concise with just three words. There's zero waste or unnecessary elaboration. While this conciseness comes at the cost of completeness, as a standalone attribute, the description is perfectly structured and front-loaded.

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?

For a directory creation tool with no annotations and no output schema, the description is inadequate. It doesn't explain what happens on success or failure, doesn't mention permissions or constraints, and provides no context about the filesystem environment. Given the complexity of a write operation and the lack of structured metadata, the description should provide more complete context.

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 description adds no parameter information beyond what the schema already provides. However, with 100% schema description coverage where both parameters ('path' and 'recursive') have clear descriptions in the schema, the baseline score of 3 is appropriate. The description doesn't compensate for gaps because there are none, but it also doesn't add value beyond the structured schema.

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

Purpose2/5

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

The description 'Create a directory' is a tautology that essentially restates the tool name. While it includes a verb ('Create') and resource ('directory'), it lacks specificity about what kind of directory or context. It doesn't distinguish this tool from potential sibling operations like creating files or other directory-related operations beyond the obvious name difference.

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

Usage Guidelines1/5

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

The description provides no guidance on when to use this tool versus alternatives. There's no mention of prerequisites, when this operation is appropriate, or how it relates to sibling tools like 'write_file', 'scaffold_project', or 'read_directory'. The agent receives no contextual usage information.

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/mcp-tool-shop-org/mcp-file-forge'

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