Skip to main content

An MCP server for gitingest

Project description

Gitingest MCP server

An MCP server for gitingest that provides access to Git repository analysis through the Model Context Protocol (MCP). This server leverages the gitingest library to analyze Git repositories and make their content available in a format optimized for LLMs.

Overview

This MCP server provides a single unified tool for accessing Git repository data. It automatically handles repository ingestion as needed, so users can immediately query repository content without an explicit ingestion step.

Tool: gitingest

The server provides a single tool called gitingest that can be used to analyze Git repositories. The tool accepts the following parameters:

  • repo_uri (required): URL or local path to the Git repository
  • token (optional): A GitHub Personal Access Token (PAT) for accessing private repositories.
  • resource_type: Type of data to retrieve (summary, tree, content, or all). Default is summary.
  • max_file_size: Maximum file size in bytes to include in the analysis. Default is 10MB.
  • include_patterns: Comma-separated patterns of files to include in the analysis.
  • exclude_patterns: Comma-separated patterns of files to exclude from the analysis.
  • branch: Specific branch to analyze.
  • output: File path to save the output to.
  • max_tokens: Truncates the response to a specified number of tokens.

Accessing Private Repositories

You can ingest private GitHub repositories by providing a GitHub Personal Access Token (PAT).

There are two primary ways to configure this:

  1. Set an Environment Variable in your MCP Config (Recommended for Servers): This is the best approach for persistent configuration. Add an env block to your server definition in your MCP configuration file. The gitingest library will automatically use the GITHUB_TOKEN environment variable.

    "mcpServers": {
      "trelis-gitingest-mcp": {
        "command": "uvx",
        "args": [
          "trelis-gitingest-mcp"
        ],
        "env": {
          "GITHUB_TOKEN": "github_pat_..."
        }
      }
    }
    
  2. Pass the Token in the Tool Call (Per-Request Basis): If you only need to access a private repository for a single call, or prefer not to set the environment variable, you can include the token parameter directly in your request.

    {
      "repo_uri": "https://github.com/your-username/your-private-repo",
      "token": "github_pat_..."
    }
    

Resource Types and Large Repositories

For large repositories, it's recommended to first request only the summary (which is the default). After ingestion, you can access more detailed information through the resources:

  • Use the tree resource to explore the repository structure
  • Use the content resource to access the full content (if not too large)

If the repository is too large, consider using include_patterns and/or exclude_patterns to limit the scope of the ingestion.

Accessing Resources After a Tool Call

After you call the gitingest tool for a repository, the server defines resources for that repository:

  • Summary: A high-level summary of the repository
  • Tree: The file/directory structure
  • Content: The full content (subject to size limits)

These resources can be accessed individually via the resources interface in any MCP-compatible client. This is useful for browsing or fetching specific aspects of a repository after ingestion.

MCP Server Configuration

To use this MCP server from PyPI, add the following to your MCP config:

"mcpServers": {
  "trelis-gitingest-mcp": {
    "command": "uvx",
    "args": [
      "trelis-gitingest-mcp"
    ]
  }
}

To run directly from the GitHub repository:

"mcpServers": {
  "trelis-gitingest-mcp": {
    "command": "uvx",
    "args": [
      "git+https://github.com/TrelisResearch/trelis-gitingest-mcp"
    ]
  }
}

Development

Building and Publishing

To prepare the package for distribution:

  1. Sync dependencies and update lockfile:
    uv sync
    
  2. Build package distributions:
    uv build
    
  3. Publish to PyPI:
    uv publish
    

Debugging

The best way to debug MCP servers is with the MCP Inspector.

You can launch the Inspector with your local server using this command:

npx @modelcontextprotocol/inspector uv --directory /Users/RonanMcGovern/TR/trelis-gitingest-mcp run trelis-gitingest-mcp

or using uvx for the mcp server:

npx @modelcontextprotocol/inspector uvx https://github.com/TrelisResearch/trelis-gitingest-mcp.git

Upon launching, the Inspector will display a URL that you can access in your browser to begin debugging.

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

trelis_gitingest_mcp-1.1.0.tar.gz (27.9 kB view details)

Uploaded Source

Built Distribution

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

trelis_gitingest_mcp-1.1.0-py3-none-any.whl (10.7 kB view details)

Uploaded Python 3

File details

Details for the file trelis_gitingest_mcp-1.1.0.tar.gz.

File metadata

File hashes

Hashes for trelis_gitingest_mcp-1.1.0.tar.gz
Algorithm Hash digest
SHA256 badbe8b86f05ba8bf77fa438c42062020776aaebbb71ae8dabffbd1293b0c7fd
MD5 405e12df8dd0f9fe34c9895c01540593
BLAKE2b-256 018e004c25b7801e004826f162cc6f5d2afbaa7eb30da302c94f102ce91d2e71

See more details on using hashes here.

File details

Details for the file trelis_gitingest_mcp-1.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for trelis_gitingest_mcp-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 751cc250f6719a4dcab974f0cff50e0f21a0c4330c6c96b65ec82588e7f9aa52
MD5 0f8b33ef0421a540b88928f51fec292d
BLAKE2b-256 8edb60662ccc0aa52c5d442e93f33392cb1c222e6da6c7e32dadc351e5abdae9

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