mcp-git-ingest

mcp-git-ingest

MCP server for exploring GitHub repository structures and key files.

286
Stars
38
Forks
286
Watchers
10
Issues
mcp-git-ingest is a Model Context Protocol (MCP) server designed to programmatically read and visualize GitHub repository structures and retrieve important file contents. It leverages fastmcp for server functionality and gitpython for repository operations, ensuring robust error handling and cleanup. The tool offers commands to generate directory trees and fetch specified files, making it suitable for integrating repository context into AI workflows.

Key Features

Returns tree-like representations of GitHub repository directory structures
Retrieves contents of specified important files from GitHub repositories
Implements robust error handling and descriptive error messages
Uses deterministic temporary directories based on repository hashing
Supports efficient cleanup of temporary files and directories
Integrates with fastmcp for Model Context Protocol server functionality
Compatible with Python 3.8+
Includes CLI usage via mcp-client-cli
Skips .git directories for cleaner output
Provides Unicode-based visual directory trees

Use Cases

Automatically extracting and visualizing the structure of code repositories
Reading key files such as README or configuration files for documentation generation
Providing context to AI models for code analysis or summarization tasks
Integrating GitHub repository insights into model workflows via standardized endpoints
Validating repository layouts for CI/CD pipelines
Facilitating onboarding by summarizing repository structure for new team members
Cross-referencing multiple repositories for dependency management
Enabling programmatic audits of repository file contents
Accelerating code review processes with structured insights
Automating data retrieval for developer tools and extensions

README

MCP Git Ingest

smithery badge

A Model Context Protocol (MCP) server that helps read GitHub repository structure and important files.

Inspired by gitingest.

Configuration

json
{
    "mcpServers": {
        "mcp-git-ingest": {
            "command": "uvx",
            "args": ["--from", "git+https://github.com/adhikasp/mcp-git-ingest", "mcp-git-ingest"],
        }
    }
}

Usage

Using mcp-client-cli:

$ llm read https://github.com/adhikasp/mcp-git-ingest and determine how the code technically works

I'll help you understand the technical details of the mcp-git-ingest repository. I'll first fetch the directory structure and then read the important files to analyze how the code works.

Tool Calls:
  github_directory_structure
  Args:
    repo_url: https://github.com/adhikasp/mcp-git-ingest

Now, I'll read the important files to understand the technical implementation:

Tool Calls:
  github_read_important_files
  Args:
    repo_url: https://github.com/adhikasp/mcp-git-ingest
    file_paths: ['README.md', 'src/mcp_git_ingest/main.py', 'pyproject.toml']

Let me break down how this code technically works:

1. Purpose:
The `mcp-git-ingest` is a Model Context Protocol (MCP) server designed to help read GitHub repository structures and important files. It provides two main tools:
- `github_directory_structure`: Returns a tree-like representation of a repository's directory structure
- `github_read_important_files`: Reads and returns the contents of specified files in a repository

2. Technical Implementation:

a. Dependencies:
- Uses `fastmcp` for creating an MCP server
- Uses `gitpython` for Git repository operations
- Requires Python 3.8+

b. Key Functions:

`clone_repo(repo_url: str) -> str`:
- Creates a deterministic temporary directory based on the repository URL's hash
- Checks if the repository is already cloned
- If not, clones the repository
- Handles error cases and cleanup
- Returns the path to the cloned repository

`get_directory_tree(path: str, prefix: str = "") -> str`:
- Recursively generates a tree-like directory structure
- Skips `.git` directories
- Uses Unicode box-drawing characters to create a visual tree representation
- Handles sorting of entries

`github_directory_structure(repo_url: str) -> str`:
- Clones the repository
- Generates directory tree
- Cleans up the temporary repository after processing
- Returns the tree structure or an error message

`github_read_important_files(repo_url: str, file_paths: List[str]) -> dict[str, str]`:
- Clones the repository
- Reads specified files
- Returns a dictionary mapping file paths to their contents
- Handles file reading errors
- Cleans up the temporary repository

3. Error Handling:
- Uses try-except blocks to handle repository cloning, file reading errors
- Ensures temporary directories are always cleaned up using `finally` blocks
- Returns descriptive error messages

4. Performance Optimizations:
- Uses a hash-based temporary directory naming to potentially reuse cloned repositories
- Checks for existing repositories before cloning
- Implements cleanup to prevent accumulation of temporary files

5. Unique Features:
- Deterministic temporary directory creation
- Unicode tree representation
- Flexible file reading with error handling

6. Execution:
- Can be run as a CLI tool via `mcp-git-ingest`
- Configured through `pyproject.toml`
- Depends on `fastmcp` for MCP server functionality

The code is a robust, flexible tool for programmatically exploring and reading GitHub repositories, with a focus on error handling and clean implementation.

Would you like me to elaborate on any specific aspect of the implementation?

Star History

Star History Chart

Repository Owner

adhikasp
adhikasp

User

Repository Details

Language Python
Default Branch master
Size 17 KB
Contributors 3
License MIT License
MCP Verified Nov 12, 2025

Programming Languages

Python
85.1%
Dockerfile
14.9%

Tags

Topics

git llm mcp model-context-protocol

Join Our Newsletter

Stay updated with the latest AI tools, news, and offers by subscribing to our weekly newsletter.

We respect your privacy. Unsubscribe at any time.

Related MCPs

Discover similar Model Context Protocol servers

  • GitHub Enterprise MCP Server

    GitHub Enterprise MCP Server

    Expose GitHub Enterprise data through a Model Context Protocol server.

    GitHub Enterprise MCP Server provides an MCP (Model Context Protocol) interface to integrate with GitHub Enterprise APIs, enabling standardized access to repository data, issues, pull requests, workflows, and user management. It is compatible with both GitHub Enterprise Server and GitHub.com environments and supports features like repository management, file browsing, and enterprise statistics. The platform is designed for seamless integration with tools such as Cursor, making it simple to interact with GitHub data programmatically or via MCP-compliant clients.

    • 25
    • MCP
    • ddukbg/github-enterprise-mcp
  • GitHub MCP Server

    GitHub MCP Server

    Connect AI tools directly to GitHub for repository, issue, and workflow management via natural language.

    GitHub MCP Server enables AI tools such as agents, assistants, and chatbots to interact natively with the GitHub platform. It allows these tools to access repositories, analyze code, manage issues and pull requests, and automate workflows using the Model Context Protocol (MCP). The server supports integration with multiple hosts, including VS Code and other popular IDEs, and can operate both remotely and locally. Built for developers seeking to enhance AI-powered development workflows through seamless GitHub context access.

    • 24,418
    • MCP
    • github/github-mcp-server
  • GitHub GraphQL MCP Server

    GitHub GraphQL MCP Server

    A Model Context Protocol server for executing arbitrary GraphQL queries on GitHub's API.

    GitHub GraphQL MCP Server is a Model Context Protocol (MCP) server that enables interaction with GitHub's GraphQL API. It allows users to execute any GraphQL queries and mutations against GitHub, supporting variable injection and error handling. The server is designed to integrate with Claude for Desktop, providing tooling for AI environments to access or manipulate GitHub data. Detailed documentation and configuration examples are provided for rapid setup and use.

    • 9
    • MCP
    • QuentinCody/github-graphql-mcp-server
  • AtomGit MCP Server

    AtomGit MCP Server

    AI-powered management and automation of AtomGit repositories via the Model Context Protocol.

    AtomGit MCP Server implements the Model Context Protocol to enable AI-driven management and automation of AtomGit open collaboration platform repositories. It offers methods for managing repositories, issues, pull requests, branches, and labels, allowing seamless AI interaction with AtomGit. The server supports integration with platforms like Claude and VSCode, providing a standardized interface for AI to orchestrate complex collaboration workflows. Built with Node.js and easily deployable via npx or from source, it focuses on expanding collaborative capabilities using AI agents.

    • 7
    • MCP
    • kaiyuanxiaobing/atomgit-mcp-server
  • GitLab MR MCP

    GitLab MR MCP

    An MCP server for AI-powered interaction with GitLab merge requests and issues.

    GitLab MR MCP implements a server for the Model Context Protocol (MCP) enabling AI agents to perform structured interactions with GitLab repositories. It provides capabilities for reading merge request and issue details, listing projects, fetching diffs and comments, and making changes such as commenting or updating titles and descriptions. Installation is supported via Smithery or manually, and integration with MCP clients and Inspector tools is documented for development and troubleshooting.

    • 65
    • MCP
    • kopfrechner/gitlab-mr-mcp
  • Google Workspace MCP Server

    Google Workspace MCP Server

    Full natural language control of Google Workspace through the Model Context Protocol.

    Google Workspace MCP Server enables comprehensive natural language interaction with Google services such as Calendar, Drive, Gmail, Docs, Sheets, Slides, Forms, Tasks, and Chat via any MCP-compatible client or AI assistant. It supports both single-user and secure multi-user OAuth 2.1 authentication, providing a production-ready backend for custom apps. Built on FastMCP, it delivers high performance and advanced context handling, offering deep integration with the entire Google Workspace suite.

    • 890
    • MCP
    • taylorwilsdon/google_workspace_mcp
  • Didn't find tool you were looking for?

    Be as detailed as possible for better results