Skip to main content
Glama

Filesystem MCP Server

Official

create_directory

Set up or validate directory structures by creating new directories or ensuring existing paths. Supports nested directories in a single operation, ideal for project setups or required paths within allowed spaces.

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

NameRequiredDescriptionDefault
pathYes

Input Schema (JSON Schema)

{ "$schema": "http://json-schema.org/draft-07/schema#", "additionalProperties": false, "properties": { "path": { "type": "string" } }, "required": [ "path" ], "type": "object" }

Implementation Reference

  • Handler function for the create_directory tool. Validates the path, creates the directory recursively using fs.mkdir, and returns a success message.
    async (args: z.infer<typeof CreateDirectoryArgsSchema>) => { const validPath = await validatePath(args.path); await fs.mkdir(validPath, { recursive: true }); const text = `Successfully created directory ${args.path}`; return { content: [{ type: "text" as const, text }], structuredContent: { content: text } }; }
  • Zod schema defining the input arguments for the create_directory tool: a path string.
    const CreateDirectoryArgsSchema = z.object({ path: z.string(), });
  • Registers the create_directory tool with the MCP server, including title, description, input/output schemas, annotations, and the inline handler function.
    server.registerTool( "create_directory", { title: "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: { path: z.string() }, outputSchema: { content: z.string() }, annotations: { readOnlyHint: false, idempotentHint: true, destructiveHint: false } }, async (args: z.infer<typeof CreateDirectoryArgsSchema>) => { const validPath = await validatePath(args.path); await fs.mkdir(validPath, { recursive: true }); const text = `Successfully created directory ${args.path}`; return { content: [{ type: "text" as const, text }], structuredContent: { content: text } }; } );

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/modelcontextprotocol/filesystem'

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