Skip to main content
Glama

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,

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