Skip to main content
Glama
gabrielmaialva33

MCP Filesystem Server

create_directory

Create or verify directory paths for projects using a single operation. Ensures nested directories exist or are created silently if already present, within allowed directories.

Instructions

Create a new directory or ensure a directory exists. Can create multiple nested directories in one operation. If the directory already exists, this operation will succeed silently. Perfect for setting up directory structures for projects or ensuring required paths exist. Only works within allowed directories.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathYesPath of the directory to create

Implementation Reference

  • The main handler function for the 'create_directory' tool. It parses input arguments using the schema, validates the path against allowed directories, creates the directory (recursively if needed) using fs.mkdir, logs the action, and returns a success message.
    case 'create_directory': {
      const parsed = CreateDirectoryArgsSchema.safeParse(a)
      if (!parsed.success) {
        throw new FileSystemError(`Invalid arguments for ${name}`, 'INVALID_ARGS', undefined, {
          errors: parsed.error.format(),
        })
      }
    
      const validPath = await validatePath(parsed.data.path, config)
      await fs.mkdir(validPath, { recursive: true })
      await logger.debug(`Created directory: ${validPath}`)
    
      endMetric()
      return {
        content: [{ type: 'text', text: `Successfully created directory ${parsed.data.path}` }],
      }
    }
  • Zod schema defining the input structure for the create_directory tool, requiring a single 'path' string parameter.
    const CreateDirectoryArgsSchema = z.object({
      path: z.string().describe('Path of the directory to create'),
    })
  • src/index.ts:271-277 (registration)
    Tool registration in the list_tools handler, defining the name, description, and input schema for the create_directory tool.
    name: 'create_directory',
    description:
      'Create a new directory or ensure a directory exists. Can create multiple ' +
      'nested directories in one operation. If the directory already exists, ' +
      'this operation will succeed silently. Perfect for setting up directory ' +
      'structures for projects or ensuring required paths exist. Only works within allowed directories.',
    inputSchema: zodToJsonSchema(CreateDirectoryArgsSchema) as ToolInput,
Behavior4/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. It effectively describes key behaviors: the tool can create nested directories, succeeds silently if directories already exist, and has access restrictions ('Only works within allowed directories'). It doesn't mention error conditions, permissions needed, or rate limits, but covers the essential mutation behavior well.

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 efficiently structured with four sentences that each add value: states the core function, explains nested creation capability, describes the idempotent behavior, and specifies usage context and constraints. No wasted words, and key information is front-loaded.

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

Completeness4/5

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

For a single-parameter mutation tool with no annotations and no output schema, the description provides good coverage of what the tool does, its idempotent behavior, and access restrictions. It could mention what happens on failure or the return format, but given the simplicity of the operation, it's reasonably complete.

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?

Schema description coverage is 100%, so the schema already documents the single 'path' parameter. The description adds context about what the path represents ('directory to create') and that it can include nested directories, but doesn't provide additional syntax, format details, or examples beyond what the schema implies. Baseline 3 is appropriate when schema does the heavy lifting.

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

Purpose5/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'), distinguishing it from siblings like list_directory or directory_tree. It explicitly mentions creating nested directories and silent success on existing directories, which differentiates it from basic file operations.

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

Usage Guidelines4/5

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

The description provides clear context about when to use this tool ('setting up directory structures for projects or ensuring required paths exist') and mentions constraints ('Only works within allowed directories'). However, it doesn't explicitly state when NOT to use it or name specific alternatives among siblings like bash_execute for similar operations.

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

Related 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/gabrielmaialva33/mcp-filesystem'

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