Back to Blog
RecipeJan 30, 202617 min read

Build an AI Code Documentation Generator with MCP (GitHub + Filesystem Recipe)

NT

Nikhil Tiwari

MCP Playground

🍳 MCP Recipe

  • What you'll build: An AI that reads your codebase (GitHub or local) and generates READMEs, API docs, and module summaries
  • MCP servers used: GitHub MCP, Filesystem MCP
  • Time to complete: 45-60 minutes
  • Difficulty: Intermediate

Documentation drifts out of date as soon as code changes. This recipe gives you an AI documentation generator that reads your repo—via GitHub or the local filesystem—and produces READMEs, API overviews, and per-module summaries.

You'll be able to ask:

  • "Generate a README for this repo: purpose, setup, and main commands."
  • "Document the public API of the src/api folder: list endpoints and their parameters."
  • "Summarize what each file in src/utils does in one sentence."

What You'll Build

1. Read Code

GitHub MCP or Filesystem MCP

2. Analyze

AI infers structure and purpose

3. Output Docs

README, API doc, or module summary

Prerequisites

GitHub MCP

PAT with repo read access

Filesystem MCP

Optional; for local repos

MCP Client

Claude Desktop or Cursor

Step 1: Set Up GitHub MCP

Configure GitHub MCP with a Personal Access Token (repo read scope). You'll get tools like: get_file, list_directory, search_code, list_pull_requests. Use these so the AI can read repo structure and file contents.

See our AI GitHub PR Reviewer recipe for detailed GitHub MCP setup.

Step 2: (Optional) Add Filesystem MCP for Local Repos

For local projects, add Filesystem MCP pointed at your repo root. The AI can then read files directly from disk—useful when you're not pushing to GitHub yet or want faster iteration.

Step 3: Example Prompts

  • "Read the root of owner/repo and generate a README with: project name, one-paragraph description, prerequisites, install steps, and how to run tests."
  • "Document every exported function in src/api: name, parameters, return type, and a one-line description."
  • "List all files in src and write a short 'Module overview' section for each (2-3 sentences)."

Best Practices

  • Point the AI at specific paths (e.g. src/, docs/) to keep context focused and token usage lower.
  • Ask for docs in small chunks (one folder at a time) for large repos.
  • Include "Do not invent endpoints or parameters; only document what exists in the code" to reduce hallucination.

Test GitHub MCP in the Browser

Try GitHub MCP with MCP Playground

Open MCP Playground →

Related Recipes

Frequently Asked Questions

Can it update existing README files?
Yes, if you use Filesystem MCP with write access to the repo directory. Ask the AI to "Update the README with the following section..." and it can modify the file. Always review diffs before committing.
Does it work with private repos?
Yes. GitHub MCP with a PAT that has access to the private repo can read it. Keep the PAT minimal (read-only) and store it securely.
NT

Written by Nikhil Tiwari

15+ years in product development. AI enthusiast building developer tools that make complex technologies accessible to everyone.