ingest_git
Analyze and clone a Git repository or local directory, then process files based on specified patterns and parameters. Retrieve summaries, file structures, or file contents directly.
Instructions
This function analyzes a source (URL or local path), clones the corresponding repository (if applicable), and processes its files according to the specified query parameters. It can return a summary, a tree-like structure of the files, or the content of the files.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| branch | No | The branch to clone and ingest. | main |
| exclude_patterns | No | Pattern or set of patterns specifying which files to exclude, e.q. '*.md, src/' | |
| include_patterns | No | Pattern or set of patterns specifying which files to include, e.q. '*.md, src/' | |
| max_file_size | No | Maximum allowed file size for file ingestion.Files larger than this size are ignored, by default 10*1024*1024 (10 MB). | |
| source | Yes | The source to analyze, which can be a URL (for a Git repository) or a local directory path. |
Implementation Reference
- src/gitingestmcp/server.py:11-57 (handler)The core handler function for the 'ingest_git' MCP tool. It defines the input parameters with descriptions (schema), is registered via @mcp.tool(), and implements the logic by calling the external ingest_async function to process the git repository or directory and return a combined summary, tree, and content.@mcp.tool() async def ingest_git( source: Annotated[ str, Field( description="The source to analyze, which can be a URL (for a Git repository) or a local directory path." ), ], max_file_size: Annotated[ int, Field( description=( "Maximum allowed file size for file ingestion." "Files larger than this size are ignored, by default 10*1024*1024 (10 MB)." ) ), ] = 10 * 1024 * 1024, include_patterns: Annotated[ str, Field(description="Pattern or set of patterns specifying which files to include, e.q. '*.md, src/'"), ] = "", exclude_patterns: Annotated[ str, Field(description="Pattern or set of patterns specifying which files to exclude, e.q. '*.md, src/'"), ] = "", branch: Annotated[str, Field(description="The branch to clone and ingest.")] = "main", ) -> str: """ This function analyzes a source (URL or local path), clones the corresponding repository (if applicable), and processes its files according to the specified query parameters. It can return a summary, a tree-like structure of the files, or the content of the files. """ summary, tree, content = await ingest_async( source, max_file_size=max_file_size, include_patterns=include_patterns, exclude_patterns=exclude_patterns, branch=branch, ) return "\n\n".join( [ summary, tree, content, ] )