Skip to main content
Glama

create_folder

Generate a new folder in the docs directory and optionally add a README.md file with basic frontmatter for structured documentation management.

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
createReadmeNo
pathYes

Implementation Reference

  • Implementation of the createFolder method in the DocumentHandler class. This is the core handler logic for the create_folder tool, which creates a folder in the docs directory and optionally generates 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 the input parameters for the create_folder tool: required 'path' string and optional 'createReadme' boolean (defaults to true).
    export const CreateFolderSchema = ToolInputSchema.extend({ path: z.string(), createReadme: z.boolean().default(true), });
  • src/index.ts:401-412 (registration)
    Registration and dispatching of the create_folder tool (named 'create_documentation_folder') in the CallToolRequestHandler. Parses arguments using CreateFolderSchema and calls documentHandler.createFolder.
    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 ); }
  • src/index.ts:252-257 (registration)
    Tool registration in ListToolsRequestHandler, defining the tool name 'create_documentation_folder', description, and input schema from CreateFolderSchema.
    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, },

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