Skip to main content
Glama

generate_readme

Create professional README.md files by analyzing project directories to generate comprehensive documentation with badges, sections, and proper formatting.

Instructions

Generate a well-formatted, visually appealing README.md file for a project. This tool analyzes the project directory and automatically creates a comprehensive README with: badges, emojis, proper sections (description, installation, usage, project structure, dependencies, etc.), code blocks, and professional formatting. The generated README is ready to use and follows best practices.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
projectPathYesThe absolute path to the project directory

Implementation Reference

  • The core handler function that implements the logic for generating a comprehensive, formatted README.md file based on analyzed project data. It constructs sections like badges, description, technologies, installation, usage, structure, dependencies, etc.
    function generateReadme(projectData: any): string { const { projectName, description, version, author, license, homepage, repository, scripts, dependencies, devDependencies, detectedTechnologies, configFiles, directoryStructureFormatted, } = projectData; let readme = ""; readme += `# ${projectName}\n\n`; const badges: string[] = []; if (version) badges.push( `![Version](https://img.shields.io/badge/version-${version}-blue.svg)`, ); if (license) badges.push( `![License](https://img.shields.io/badge/license-${license}-green.svg)`, ); if (detectedTechnologies.includes("Node.js")) badges.push( `![Node.js](https://img.shields.io/badge/node.js-✓-brightgreen.svg)`, ); if (detectedTechnologies.includes("TypeScript")) badges.push( `![TypeScript](https://img.shields.io/badge/typescript-✓-blue.svg)`, ); if (detectedTechnologies.includes("Python")) badges.push(`![Python](https://img.shields.io/badge/python-✓-yellow.svg)`); if (detectedTechnologies.includes("Rust")) badges.push(`![Rust](https://img.shields.io/badge/rust-✓-orange.svg)`); if (detectedTechnologies.includes("Go")) badges.push(`![Go](https://img.shields.io/badge/go-✓-00ADD8.svg)`); if (badges.length > 0) { readme += badges.join(" ") + "\n\n"; } if (description) { readme += `## 📝 Description\n\n${description}\n\n`; } if (detectedTechnologies.length > 0) { readme += `## 🛠️ Technologies Used\n\n`; detectedTechnologies.forEach((tech: string) => { readme += `- ${tech}\n`; }); readme += `\n`; } readme += `## 📦 Installation\n\n`; if (dependencies.length > 0 || devDependencies.length > 0) { readme += `\`\`\`bash\n`; if (detectedTechnologies.includes("Node.js")) { readme += `npm install\n`; } else if (detectedTechnologies.includes("Python")) { readme += `pip install -r requirements.txt\n`; } else if (detectedTechnologies.includes("Rust")) { readme += `cargo build\n`; } else if (detectedTechnologies.includes("Go")) { readme += `go mod download\n`; } readme += `\`\`\`\n\n`; } else { readme += `Clone the repository and follow the setup instructions.\n\n`; } const scriptKeys = Object.keys(scripts); if (scriptKeys.length > 0) { readme += `## 🚀 Usage\n\n`; readme += `Available scripts:\n\n`; scriptKeys.forEach((script) => { readme += `\`\`\`bash\nnpm run ${script}\n\`\`\`\n`; readme += `${scripts[script]}\n\n`; }); } if (directoryStructureFormatted) { readme += `## 📁 Project Structure\n\n`; readme += `\`\`\`\n${directoryStructureFormatted}\`\`\`\n\n`; } if (dependencies.length > 0) { readme += `## 📚 Dependencies\n\n`; dependencies.forEach((dep: string) => { readme += `- ${dep}\n`; }); readme += `\n`; } if (devDependencies.length > 0) { readme += `## 🔧 Dev Dependencies\n\n`; devDependencies.forEach((dep: string) => { readme += `- ${dep}\n`; }); readme += `\n`; } if (configFiles) { readme += `## 📝 Config-files\n\n${configFiles}\n\n`; } if (license) { readme += `## 📄 License\n\n`; readme += `This project is licensed under the ${license} License.\n\n`; } if (author) { readme += `## 👤 Author\n\n`; readme += `${typeof author === "string" ? author : JSON.stringify(author)}\n\n`; } if (homepage || repository) { readme += `## 🔗 Links\n\n`; if (homepage) readme += `- [Homepage](${homepage})\n`; if (repository) { const repoUrl = typeof repository === "string" ? repository : repository.url; readme += `- [Repository](${repoUrl})\n`; } readme += `\n`; } readme += `---\n\n`; readme += `*Generated with ❤️ by README Generator MCP Server*\n`; return readme; }
  • src/index.ts:443-460 (registration)
    Tool registration in the listTools handler, defining the name, description, and input schema for the generate_readme tool.
    { name: "generate_readme", description: "Generate a well-formatted, visually appealing README.md file for a project. " + "This tool analyzes the project directory and automatically creates a comprehensive README with: " + "badges, emojis, proper sections (description, installation, usage, project structure, dependencies, etc.), " + "code blocks, and professional formatting. The generated README is ready to use and follows best practices.", inputSchema: { type: "object", properties: { projectPath: { type: "string", description: "The absolute path to the project directory", }, }, required: ["projectPath"], }, },
  • The switch case handler in the CallToolRequestSchema that dispatches the generate_readme tool call, performing project analysis and invoking the generateReadme function.
    case "generate_readme": { const { projectPath } = args as { projectPath: string }; const analysis = await analyzeProject(projectPath); const readme = generateReadme(analysis.projectData); return { content: [ { type: "text", text: readme, }, ], }; }
  • Helper function that analyzes the project directory to extract structured data (package.json, technologies, structure, etc.) required by generateReadme.
    async function analyzeProject(projectPath: string): Promise<any> { try { const structure = await getDirectoryStructure(projectPath); let packageJson: any = null; try { const packagePath = join(projectPath, "package.json"); const packageContent = await readFile(packagePath, "utf-8"); packageJson = JSON.parse(packageContent); } catch { // package.json might not exist } const files = await readdir(projectPath); const detectedTechnologies: string[] = []; const configFiles: string[] = []; if (files.includes("package.json")) { detectedTechnologies.push("Node.js"); configFiles.push("package.json"); } if (files.includes("tsconfig.json")) { detectedTechnologies.push("TypeScript"); configFiles.push("tsconfig.json"); } if (files.includes("requirements.txt")) { detectedTechnologies.push("Python"); configFiles.push("requirements.txt"); } if (files.includes("setup.py")) { detectedTechnologies.push("Python"); configFiles.push("setup.py"); } if (files.includes("Cargo.toml")) { detectedTechnologies.push("Rust"); configFiles.push("Cargo.toml"); } if (files.includes("go.mod")) { detectedTechnologies.push("Go"); configFiles.push("go.mod"); } if (files.includes("pom.xml")) { detectedTechnologies.push("Java"); configFiles.push("pom.xml"); } if (files.includes("build.gradle")) { detectedTechnologies.push("Java/Gradle"); configFiles.push("build.gradle"); } if (files.includes("Dockerfile")) { detectedTechnologies.push("Docker"); configFiles.push("Dockerfile"); } if (files.includes(".env.example") || files.includes(".env.template")) { configFiles.push( files.find((f) => f === ".env.example") || ".env.template", ); } const structureString = formatDirectoryStructure(structure, 0); return { template: README_TEMPLATE, projectData: { projectName: packageJson?.name || parse(projectPath).base, description: packageJson?.description || null, version: packageJson?.version || null, author: packageJson?.author || null, license: packageJson?.license || null, homepage: packageJson?.homepage || null, repository: packageJson?.repository || null, scripts: packageJson?.scripts || {}, dependencies: packageJson?.dependencies ? Object.keys(packageJson.dependencies) : [], devDependencies: packageJson?.devDependencies ? Object.keys(packageJson.devDependencies) : [], detectedTechnologies, configFiles, directoryStructure: structure, directoryStructureFormatted: structureString, rootFiles: files, }, }; } catch (error) { throw new Error(`Failed to analyze project: ${error}`); } }

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/JojoSlice/README-Gen-MCP-Server'

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