Skip to main content

An AWS Labs Model Context Protocol (MCP) server for code-doc-gen

Reason this release was yanked:

modern LLMs now handle documentation generation more effectively using native file and code intelligence tools

Project description

AWS Labs Code Documentation Generation MCP Server

smithery badge

A Model Context Protocol (MCP) server that automatically analyzes repository structure and generates comprehensive documentation for code projects. This server uses repomix to extract project structure and creates tailored documentation based on project type.

Architecture

How the Server Works

The code-doc-gen-mcp-server follows this workflow:

  1. prepare_repository:

    • Uses RepomixManager to analyze a project directory
    • Runs repomix to generate an XML representation of the repo
    • Extracts directory structure from this XML
    • Returns a ProjectAnalysis with the directory structure
  2. create_context:

    • Creates a DocumentationContext with the ProjectAnalysis
  3. plan_documentation:

    • Uses the directory structure from DocumentationContext
    • Creates a DocumentationPlan with document structure and sections
  4. generate_documentation:

    • Generates document templates based on the plan

Key Components

  1. RepomixManager: Manages the execution of repomix and parses its XML output to extract directory structure
  2. DocumentationContext: Central state container that tracks project info and documentation progress
  3. ProjectAnalysis: Data structure containing analyzed project metadata (languages, dependencies, etc.)
  4. DocumentationPlan: Structured plan for document generation with section outlines
  5. DocumentGenerator: Creates actual document templates based on the plan

Features

  • Project Structure Analysis: Uses repomix to analyze repository structure and extract key components
  • Content Organization: Creates appropriately structured documentation based on project type
  • Multiple Document Types: Supports README, API docs, backend docs, frontend docs, and more
  • Integration with Other MCP Servers: Works with AWS Diagram MCP server
  • Custom Document Templates: Templates for different document types with appropriate sections

Prerequisites

  1. Install uv from Astral or the GitHub README
  2. Install Python using uv python install 3.10
  3. Install repomix using pip install repomix>=0.2.6

Installation

Cursor VS Code
Install MCP Server Install on VS Code

This MCP server can be added to your AWS AI assistants via the appropriate MCP configuration file:

{
  "mcpServers": {
    "awslabs.code-doc-gen-mcp-server": {
      "command": "uvx",
      "args": ["awslabs.code-doc-gen-mcp-server@latest"],
      "env": {
        "FASTMCP_LOG_LEVEL": "ERROR"
      },
      "disabled": false,
      "autoApprove": []
    }
  }
}

Windows Installation

For Windows users, the MCP server configuration format is slightly different:

{
  "mcpServers": {
    "awslabs.code-doc-gen-mcp-server": {
      "disabled": false,
      "timeout": 60,
      "type": "stdio",
      "command": "uv",
      "args": [
        "tool",
        "run",
        "--from",
        "awslabs.code-doc-gen-mcp-server@latest",
        "awslabs.code-doc-gen-mcp-server.exe"
      ],
      "env": {
        "FASTMCP_LOG_LEVEL": "ERROR",
        "AWS_PROFILE": "your-aws-profile",
        "AWS_REGION": "us-east-1"
      }
    }
  }
}

Core Concepts

DocumentationContext

The DocumentationContext class maintains the state of the documentation process throughout its lifecycle:

  • project_name: Name of the project being documented
  • working_dir: Working directory for the project (source code location)
  • repomix_path: Path where documentation files will be generated
  • status: Current status of the documentation process
  • current_step: Current step in the documentation workflow
  • analysis_result: Contains the ProjectAnalysis with project metadata

ProjectAnalysis

The ProjectAnalysis class contains detailed information about the project:

  • project_type: Type of project (e.g., "Web Application", "CLI Tool")
  • features: Key capabilities and functions of the project
  • file_structure: Project organization with directory structure
  • dependencies: Project dependencies with versions
  • primary_languages: Programming languages used in the project
  • apis (optional): API endpoint details
  • backend (optional): Backend implementation details
  • frontend (optional): Frontend implementation details

Tools

prepare_repository

async def prepare_repository(
    project_root: str = Field(..., description='Path to the code repository'),
    ctx: Context = None,
) -> ProjectAnalysis

This tool:

  1. Extracts directory structure from the repository using repomix
  2. Returns a ProjectAnalysis template for the MCP client to fill
  3. Provides directory structure in file_structure["directory_structure"]

The MCP client then:

  1. Reviews the directory structure
  2. Uses read_file to examine key files
  3. Fills out the ProjectAnalysis fields
  4. Sets has_infrastructure_as_code=True if CDK/Terraform code is detected

create_context

async def create_context(
    project_root: str = Field(..., description='Path to the code repository'),
    analysis: ProjectAnalysis = Field(..., description='Completed ProjectAnalysis'),
    ctx: Context = None,
) -> DocumentationContext

Creates a DocumentationContext from the completed ProjectAnalysis.

plan_documentation

async def plan_documentation(
    doc_context: DocumentationContext,
    ctx: Context,
) -> DocumentationPlan

Creates a documentation plan based on the project analysis, determining what document types are needed and creating appropriate document structures.

generate_documentation

async def generate_documentation(
    plan: DocumentationPlan,
    doc_context: DocumentationContext,
    ctx: Context,
) -> List[GeneratedDocument]

Generates document structures with sections for the MCP client to fill with content.

Integration with Other MCP Servers

This MCP server is designed to work with:

  • AWS Diagram MCP Server: For generating architecture diagrams
  • AWS CDK MCP Server: For documenting CDK infrastructure code

License

This project is licensed under the Apache License, Version 2.0. See the LICENSE file for details.

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

awslabs_code_doc_gen_mcp_server-1.0.6.tar.gz (118.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

awslabs_code_doc_gen_mcp_server-1.0.6-py3-none-any.whl (29.4 kB view details)

Uploaded Python 3

File details

Details for the file awslabs_code_doc_gen_mcp_server-1.0.6.tar.gz.

File metadata

File hashes

Hashes for awslabs_code_doc_gen_mcp_server-1.0.6.tar.gz
Algorithm Hash digest
SHA256 50b7bc36ff042ce4d6bb85dd6100a3d20b03646a7567c1c63f444428e5985eb8
MD5 d7a9006c5dc3429956545e37c83950a7
BLAKE2b-256 0da9ba7ee32eb3980f040e650d27b58d7fc609ee039c9a75c3848a5239d457fb

See more details on using hashes here.

Provenance

The following attestation bundles were made for awslabs_code_doc_gen_mcp_server-1.0.6.tar.gz:

Publisher: release.yml on awslabs/mcp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file awslabs_code_doc_gen_mcp_server-1.0.6-py3-none-any.whl.

File metadata

File hashes

Hashes for awslabs_code_doc_gen_mcp_server-1.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 3eedffde6136b269e4101a4faabf009467d53ea02b6b0475a0416a0940ffb0a9
MD5 20dea57b4d43cd7703fb796d4be005e9
BLAKE2b-256 ff53ecd1159c389d1abb9f9ae651e554e6673dbf84d0dfb453d74beb486920f9

See more details on using hashes here.

Provenance

The following attestation bundles were made for awslabs_code_doc_gen_mcp_server-1.0.6-py3-none-any.whl:

Publisher: release.yml on awslabs/mcp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page