Skip to main content
Glama
modelcontextprotocol

Filesystem MCP Server

Official

create_directory

Create new directories or ensure existing ones are present, including nested structures, to set 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
pathYes

Implementation Reference

  • The handler function that executes the create_directory tool logic. It validates the provided 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 single 'path' string parameter.
    const CreateDirectoryArgsSchema = z.object({ path: z.string(), });
  • Registration of the create_directory tool with the MCP server, specifying title, description, input schema, output schema, annotations, and the 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 } }; } );

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