Skip to main content
Glama
A-Niranjan

MCP Filesystem Server

by A-Niranjan

create_directory

Create new directories or ensure existing ones are available, including nested structures, for setting up project paths and required filesystem locations.

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 for the 'create_directory' tool. Validates input arguments, checks path permissions, creates the directory recursively using fs.mkdir, logs the creation, 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 for create_directory: requires a 'path' string parameter.
    const CreateDirectoryArgsSchema = z.object({
      path: z.string().describe('Path of the directory to create'),
    })
  • src/index.ts:270-278 (registration)
    Tool registration in the ListTools response, defining name, description, and input schema for create_directory.
    {
      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 behavioral traits: idempotent behavior ('If the directory already exists, this operation will succeed silently'), batch capability ('Can create multiple nested directories in one operation'), and a security constraint ('Only works within allowed directories'). It doesn't mention error conditions or performance characteristics, 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 distinct value: core functionality, batch capability, idempotent behavior, use cases, and constraints. There's no redundant information, and it's appropriately sized for the tool's complexity.

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 mutation tool with no annotations and no output schema, the description does well by explaining the idempotent behavior, batch capability, and security constraint. It could be more complete by mentioning what happens on failure (e.g., permission errors) or the return value, but given the single parameter and clear behavioral description, it's largely sufficient.

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% with the single 'path' parameter well-documented in the schema. The description adds some context by implying the path can specify nested directories ('Can create multiple nested directories in one operation'), but doesn't provide additional syntax or format details beyond what the schema already states. This meets the baseline for high schema coverage.

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 specific action ('Create a new directory or ensure a directory exists') and resource ('directory'), distinguishing it from siblings like list_directory, move_file, or edit_file. It explicitly mentions creating nested directories, which differentiates it from simpler 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 on when to use this tool ('Perfect for setting up directory structures for projects or ensuring required paths exist') and mentions a constraint ('Only works within allowed directories'). However, it doesn't explicitly state when not to use it or name specific alternatives among the sibling tools.

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/A-Niranjan/mcp-filesystem'

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