Skip to main content
Glama

create_folder

Create a new folder in the documentation directory and optionally generate a README.md file with basic frontmatter to organize and structure documentation content.

Instructions

Create a new folder in the docs directory. Optionally creates a README.md file in the new folder with basic frontmatter.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathYes
createReadmeNo

Implementation Reference

  • Core implementation of the create_folder tool logic in the DocumentHandler class. Validates path, creates directory with fs.mkdir (recursive), and optionally creates a README.md file with frontmatter.
      async createFolder(
        folderPath: string,
        createReadme = true
      ): Promise<ToolResponse> {
        try {
          const validPath = await this.validatePath(folderPath);
    
          // Create the directory
          await fs.mkdir(validPath, { recursive: true });
    
          // Create a README.md file if requested
          if (createReadme) {
            const readmePath = path.join(validPath, "README.md");
            const folderName = path.basename(validPath);
            const content = `---
    title: ${folderName}
    description: Documentation for ${folderName}
    date: ${new Date().toISOString()}
    status: draft
    ---
    
    # ${folderName}
    
    This is the documentation for ${folderName}.
    `;
            await fs.writeFile(readmePath, content, "utf-8");
          }
    
          return {
            content: [
              { type: "text", text: `Successfully created folder: ${folderPath}` },
            ],
            metadata: {
              path: folderPath,
              readme: createReadme ? path.join(folderPath, "README.md") : null,
            },
          };
        } catch (error) {
          const errorMessage =
            error instanceof Error ? error.message : String(error);
          return {
            content: [
              { type: "text", text: `Error creating folder: ${errorMessage}` },
            ],
            isError: true,
          };
        }
      }
  • Zod schema defining input validation for the create_folder tool: path (string, required), createReadme (boolean, default true). Extends ToolInputSchema.
    export const CreateFolderSchema = ToolInputSchema.extend({
      path: z.string(),
      createReadme: z.boolean().default(true),
    });
  • src/index.ts:252-257 (registration)
    MCP tool registration for 'create_documentation_folder' (references create_folder in error messages), including description and input schema conversion.
      name: "create_documentation_folder",
      description:
        "Create a new folder in the docs directory. Optionally creates a README.md file " +
        "in the new folder with basic frontmatter.",
      inputSchema: zodToJsonSchema(CreateFolderSchema) as any,
    },
  • src/index.ts:401-412 (registration)
    Dispatch handler in MCP server that parses arguments with CreateFolderSchema and delegates to documentHandler.createFolder method.
    case "create_documentation_folder": {
      const parsed = CreateFolderSchema.safeParse(args);
      if (!parsed.success) {
        throw new Error(
          `Invalid arguments for create_folder: ${parsed.error}`
        );
      }
      return await documentHandler.createFolder(
        parsed.data.path,
        parsed.data.createReadme
      );
    }

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/alekspetrov/mcp-docs-service'

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