Repository Architecture MCP Server

Repository Architecture MCP Server

Analyzes GitHub and local repositories to automatically generate visual architectural diagrams such as dependency graphs, class diagrams, and data flow diagrams.

Category
访问服务器

README

Repository Architecture MCP Server

An MCP (Model Context Protocol) server that analyzes GitHub repositories and automatically generates visual architectural diagrams including dependency graphs, class diagrams, and data flow diagrams.

Features

  • Repository Analysis: Analyze both GitHub repositories (public/private) and local repositories
  • Multi-language Support: Parse Python, JavaScript, TypeScript, Java, and Go codebases
  • Dependency Diagrams: Visualize module dependencies and service interconnections
  • Class Diagrams: Generate UML class diagrams with inheritance relationships
  • Data Flow Diagrams: Show how data moves through the system
  • Multiple Export Formats: Support for Mermaid, SVG, and PNG outputs
  • Local Analysis: No GitHub token required for local repository analysis

Diagram Preview Tools

To preview the generated diagrams, you'll need appropriate tools or extensions depending on the output format:

Mermaid Diagrams

Mermaid diagrams can be previewed using:

VS Code Extensions:

  • Mermaid Preview by vstirbu: Install via VS Code Extensions marketplace

    • Search for "Mermaid Preview" in VS Code Extensions (Ctrl+Shift+X)
    • Click Install
    • Open any .md file containing Mermaid code blocks and use the preview pane
  • Markdown Preview Mermaid Support by Matt Bierner: Enhanced markdown preview with Mermaid support

    • Search for "Markdown Preview Mermaid Support" in VS Code Extensions
    • Provides live preview of Mermaid diagrams in markdown files

Online Tools:

Browser Extensions:

  • Mermaid Diagrams for Chrome/Firefox - Renders Mermaid in GitHub and other platforms

SVG Diagrams

SVG files can be viewed in:

  • Any modern web browser (Chrome, Firefox, Safari, Edge)
  • VS Code with SVG preview extensions
  • Image viewers that support SVG format

PNG Diagrams

PNG files can be viewed in:

  • Any image viewer or web browser
  • VS Code with image preview extensions
  • Built-in system image viewers

Recommended Setup

For the best experience, we recommend:

  1. Install the Mermaid Preview extension in VS Code for live Mermaid diagram preview
  2. Use the Markdown Preview Mermaid Support extension for enhanced markdown rendering
  3. Keep a browser tab open to Mermaid Live Editor for quick diagram testing

Installation

pip install -e .

For development:

pip install -e ".[dev]"

Verify Installation

Test that the server is working:

# Check command is available
repo-architecture-mcp --help

# Test server startup (Ctrl+C to stop)
repo-architecture-mcp --log-level DEBUG

Usage

As MCP Server

Run the server with stdio transport:

repo-architecture-mcp

With debug logging:

repo-architecture-mcp --log-level DEBUG

Available MCP Tools

All tools work with both GitHub URLs and local repository paths:

  • analyze_repository: Analyze repository structure (GitHub URL or local path)
  • generate_dependency_diagram: Create dependency visualization
  • generate_class_diagram: Create class relationship diagram
  • generate_data_flow_diagram: Create data flow visualization
  • get_repository_summary: Get high-level repository statistics

Local Path Examples:

  • Current directory: "url": "."
  • Relative path: "url": "./my-project"
  • Absolute path: "url": "/home/user/project"
  • Home directory: "url": "~/projects/app"

File Saving Feature: All diagram generation tools now support automatic file saving:

  • save_to_file: Set to true to save diagrams to files
  • output_path: Optional custom file path (auto-generates if not provided)

Example with file saving:

{
  "tool": "generate_dependency_diagram",
  "arguments": {
    "url": ".",
    "format": "mermaid",
    "save_to_file": true,
    "output_path": "./diagrams/dependencies.mmd"
  }
}

Diagram Quality Improvements:

  • ✅ Proper Mermaid syntax: All generated diagrams use valid Mermaid syntax
  • ✅ Markdown code blocks: Diagrams are wrapped in proper markdown code blocks for better display
  • ✅ Character sanitization: Special characters in node names are properly handled
  • ✅ Clean display names: Node labels are cleaned for better readability
  • ✅ Edge limiting: Automatically limits edges to prevent Mermaid rendering issues (default: 400 edges)
  • ✅ Smart prioritization: Most important relationships are preserved when limiting edges

Local Repository Analysis

For local repositories, you don't need a GitHub token:

# Analyze current directory
repo-architecture-mcp --analyze-local .

# Analyze specific local path  
repo-architecture-mcp --analyze-local /path/to/project

MCP Configuration

Quick Setup

  1. Copy the provided mcp.json to your MCP client configuration directory
  2. Set your GitHub token: export GITHUB_TOKEN=your_token_here
  3. Add the server to your MCP client

Basic MCP Configuration

For GitHub repositories:

{
  "mcpServers": {
    "repo-architecture": {
      "command": "repo-architecture-mcp",
      "args": ["--log-level", "INFO"],
      "env": {
        "GITHUB_TOKEN": "${GITHUB_TOKEN}"
      },
      "disabled": false,
      "autoApprove": ["analyze_repository"]
    }
  }
}

For local repositories (no token needed):

{
  "mcpServers": {
    "repo-architecture-local": {
      "command": "repo-architecture-mcp",
      "args": ["--log-level", "INFO"],
      "cwd": "${workspaceFolder}",
      "disabled": false,
      "autoApprove": [
        "analyze_repository",
        "generate_dependency_diagram"
      ]
    }
  }
}

For Cursor IDE

Workspace Configuration for Local Analysis (.cursor/settings/mcp.json):

{
  "mcpServers": {
    "repo-architecture-local": {
      "command": "repo-architecture-mcp",
      "cwd": "${workspaceFolder}",
      "disabled": false,
      "autoApprove": [
        "analyze_repository",
        "generate_dependency_diagram"
      ]
    }
  }
}

User Configuration for GitHub (~/.cursor/settings/mcp.json):

{
  "mcpServers": {
    "repo-architecture": {
      "command": "repo-architecture-mcp",
      "args": ["--max-workers", "4"],
      "env": {
        "GITHUB_TOKEN": "${GITHUB_TOKEN}"
      },
      "disabled": false,
      "autoApprove": ["analyze_repository"]
    }
  }
}

For GitHub Copilot Chat

This MCP server integrates seamlessly with GitHub Copilot Chat to provide architectural insights directly in your development workflow. Use the available tools through Copilot's chat interface to analyze repositories and generate diagrams.

Available Tools

  • analyze_repository: Analyze repository structure and code
  • generate_dependency_diagram: Create dependency visualizations
  • generate_class_diagram: Generate UML class diagrams
  • generate_data_flow_diagram: Create data flow diagrams
  • get_repository_summary: Get repository statistics

Configuration Options

The server accepts these command-line arguments:

  • --config PATH: Custom configuration file
  • --log-level LEVEL: Set logging level (DEBUG, INFO, WARNING, ERROR)
  • --github-token TOKEN: GitHub authentication token
  • --max-workers N: Number of parallel workers (default: 4)
  • --memory-limit MB: Memory limit in megabytes (default: 2048)
  • --cache-ttl HOURS: Cache time-to-live (default: 24)
  • --output-format FORMAT: Default output format (mermaid, svg, png)

Environment Variables

  • GITHUB_TOKEN: GitHub personal access token
  • LOG_LEVEL: Logging level
  • REPO_ARCH_CONFIG: Path to configuration file

See examples/mcp-config-examples.md for more detailed configuration examples and examples/local-repo-config.md for local repository setup.

Development

Project Structure

src/repo_architecture_mcp/
├── __init__.py          # Package initialization
├── main.py              # Main entry point
└── server.py            # Core MCP server implementation

Running Tests

pytest

Code Formatting

black src/ tests/

Type Checking

mypy src/

License

MIT License

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选