Back to search
mcp-git-ingest
MCP serverGitHub
A Model Context Protocol (MCP) server that helps read GitHub repository structure and important files.
Safety scan
A static text scan, not a guarantee. Select the badge to see what was scanned and every finding.
Checked today
Badge for your README
Markdown
[](/listings/adhikasp--mcp-git-ingest)HTML
<a href="/listings/adhikasp--mcp-git-ingest"><img src="/api/listings/adhikasp--mcp-git-ingest/badge.svg" alt="findsafeskills safety rating" /></a>Install
i
What was scanned
The files the safety scan read, as written by the repository's author and shown as plain text. Lines with a finding are marked.
README.md · README · 125 lines
View this file on GitHub (read at the repository's current version: the scan did not record which commit it read)
This file has changed since it was scanned, so this is not exactly the text that was scanned, and no line is marked. The findings are listed with the safety scan above.
- # MCP Git Ingest
- [](https://smithery.ai/server/mcp-git-ingest)
- A Model Context Protocol (MCP) server that helps read GitHub repository structure and important files.
- Inspired by [gitingest](https://gitingest.com/).
- <a href="https://glama.ai/mcp/servers/un2zatig9e"><img width="380" height="200" src="https://glama.ai/mcp/servers/un2zatig9e/badge" /></a>
- ## Configuration
- ```json
- {
- "mcpServers": {
- "mcp-git-ingest": {
- "command": "uvx",
- "args": ["--from", "git+https://github.com/adhikasp/mcp-git-ingest", "mcp-git-ingest"],
- }
- }
- }
- ```
- ## Security
- `git_read_important_files` only reads files inside the clone it just made:
- - absolute paths and `..` segments are rejected;
- - the path is resolved with symlinks followed (`realpath`), and must stay inside the repository, so a symlinked `README.md -> ~/.ssh/id_ed25519` in a cloned repo is refused too;
- - `.git/` is off limits (the clone URL can carry credentials);
- - a single file is capped at 512 KiB (`MCP_GIT_INGEST_MAX_FILE_BYTES` overrides);
- - `repo_url` must be `https://`, `ssh://` or scp-style `user@host:path` — `file://`, `ext::` and bare local paths are refused; set `MCP_GIT_INGEST_ALLOWED_HOSTS=github.com,gitlab.com` to restrict hosts.
- `git_directory_structure` never descends into symlinks (a repo could point one at `/`).
- Fixed in 0.1.1; thanks to Li-c-hui for the report (issue #19).
- ## Usage
- Using [mcp-client-cli](https://github.com/adhikasp/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?
- ```
Ratings and comments
Sign in to rate this skill.
Sign inFree to use. If it’s helped, pass it on.