Skip to main content

MCP Git Ingest: GitHub repository analysis tools

Project description

MCP Git Ingest

smithery badge

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

Inspired by gitingest.

Configuration

{
    "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?

Project details


Download files

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

Source Distribution

mseep_mcp_git_ingest-0.1.1.tar.gz (4.9 kB view details)

Uploaded Source

Built Distribution

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

mseep_mcp_git_ingest-0.1.1-py3-none-any.whl (5.4 kB view details)

Uploaded Python 3

File details

Details for the file mseep_mcp_git_ingest-0.1.1.tar.gz.

File metadata

  • Download URL: mseep_mcp_git_ingest-0.1.1.tar.gz
  • Upload date:
  • Size: 4.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.12

File hashes

Hashes for mseep_mcp_git_ingest-0.1.1.tar.gz
Algorithm Hash digest
SHA256 103a6785d03dfd889f61ce2172b62edc5ef2a01536e78493e26774f929e54319
MD5 76618286f6cc9ca708440a2e075e6269
BLAKE2b-256 6057bfc85fda7d3e0af18b3a2efb56f6c0b46d9376c9ca6ce234d9594e5b98c7

See more details on using hashes here.

File details

Details for the file mseep_mcp_git_ingest-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for mseep_mcp_git_ingest-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 749968e3182cfdd7177f14e4287d45393d66e0bfd4aba044905e7d7b7efce231
MD5 7e9bf357bb80dbc42ab7a78031567241
BLAKE2b-256 21f6687755612988d87f48efb0e4ced4b94cf848b616090487aa84bee152bc03

See more details on using hashes here.

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