Skip to content
Back to search

mcp-git-ingest

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
findsafeskills safety rating

Markdown

[![findsafeskills safety rating](/api/listings/adhikasp--mcp-git-ingest/badge.svg)](/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.

  1. # MCP Git Ingest
  2. [![smithery badge](https://smithery.ai/badge/mcp-git-ingest)](https://smithery.ai/server/mcp-git-ingest)
  3. A Model Context Protocol (MCP) server that helps read GitHub repository structure and important files.
  4. Inspired by [gitingest](https://gitingest.com/).
  5. <a href="https://glama.ai/mcp/servers/un2zatig9e"><img width="380" height="200" src="https://glama.ai/mcp/servers/un2zatig9e/badge" /></a>
  6. ## Configuration
  7. ```json
  8. {
  9. "mcpServers": {
  10. "mcp-git-ingest": {
  11. "command": "uvx",
  12. "args": ["--from", "git+https://github.com/adhikasp/mcp-git-ingest", "mcp-git-ingest"],
  13. }
  14. }
  15. }
  16. ```
  17. ## Security
  18. `git_read_important_files` only reads files inside the clone it just made:
  19. - absolute paths and `..` segments are rejected;
  20. - 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;
  21. - `.git/` is off limits (the clone URL can carry credentials);
  22. - a single file is capped at 512 KiB (`MCP_GIT_INGEST_MAX_FILE_BYTES` overrides);
  23. - `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.
  24. `git_directory_structure` never descends into symlinks (a repo could point one at `/`).
  25. Fixed in 0.1.1; thanks to Li-c-hui for the report (issue #19).
  26. ## Usage
  27. Using [mcp-client-cli](https://github.com/adhikasp/mcp-client-cli):
  28. ```
  29. $ llm read https://github.com/adhikasp/mcp-git-ingest and determine how the code technically works
  30. 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.
  31. Tool Calls:
  32. github_directory_structure
  33. Args:
  34. repo_url: https://github.com/adhikasp/mcp-git-ingest
  35. Now, I'll read the important files to understand the technical implementation:
  36. Tool Calls:
  37. github_read_important_files
  38. Args:
  39. repo_url: https://github.com/adhikasp/mcp-git-ingest
  40. file_paths: ['README.md', 'src/mcp_git_ingest/main.py', 'pyproject.toml']
  41. Let me break down how this code technically works:
  42. 1. Purpose:
  43. 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:
  44. - `github_directory_structure`: Returns a tree-like representation of a repository's directory structure
  45. - `github_read_important_files`: Reads and returns the contents of specified files in a repository
  46. 2. Technical Implementation:
  47. a. Dependencies:
  48. - Uses `fastmcp` for creating an MCP server
  49. - Uses `gitpython` for Git repository operations
  50. - Requires Python 3.8+
  51. b. Key Functions:
  52. `clone_repo(repo_url: str) -> str`:
  53. - Creates a deterministic temporary directory based on the repository URL's hash
  54. - Checks if the repository is already cloned
  55. - If not, clones the repository
  56. - Handles error cases and cleanup
  57. - Returns the path to the cloned repository
  58. `get_directory_tree(path: str, prefix: str = "") -> str`:
  59. - Recursively generates a tree-like directory structure
  60. - Skips `.git` directories
  61. - Uses Unicode box-drawing characters to create a visual tree representation
  62. - Handles sorting of entries
  63. `github_directory_structure(repo_url: str) -> str`:
  64. - Clones the repository
  65. - Generates directory tree
  66. - Cleans up the temporary repository after processing
  67. - Returns the tree structure or an error message
  68. `github_read_important_files(repo_url: str, file_paths: List[str]) -> dict[str, str]`:
  69. - Clones the repository
  70. - Reads specified files
  71. - Returns a dictionary mapping file paths to their contents
  72. - Handles file reading errors
  73. - Cleans up the temporary repository
  74. 3. Error Handling:
  75. - Uses try-except blocks to handle repository cloning, file reading errors
  76. - Ensures temporary directories are always cleaned up using `finally` blocks
  77. - Returns descriptive error messages
  78. 4. Performance Optimizations:
  79. - Uses a hash-based temporary directory naming to potentially reuse cloned repositories
  80. - Checks for existing repositories before cloning
  81. - Implements cleanup to prevent accumulation of temporary files
  82. 5. Unique Features:
  83. - Deterministic temporary directory creation
  84. - Unicode tree representation
  85. - Flexible file reading with error handling
  86. 6. Execution:
  87. - Can be run as a CLI tool via `mcp-git-ingest`
  88. - Configured through `pyproject.toml`
  89. - Depends on `fastmcp` for MCP server functionality
  90. The code is a robust, flexible tool for programmatically exploring and reading GitHub repositories, with a focus on error handling and clean implementation.
  91. Would you like me to elaborate on any specific aspect of the implementation?
  92. ```

Ratings and comments

Sign in to rate this skill.

Sign in

Free to use. If it’s helped, pass it on.