Metadata-Version: 2.4
Name: trelis-gitingest-mcp
Version: 0.1.2
Summary: An MCP server for gitingest
Author-email: RonanMcGovern <78278410+RonanKMcGovern@users.noreply.github.com>
Requires-Python: >=3.12
Requires-Dist: gitingest>=0.1.0
Requires-Dist: mcp>=1.9.3
Description-Content-Type: text/markdown

# trelis-gitingest-mcp 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
- `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.

### 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.

### Automatic Ingestion and Simple Caching

The server will automatically ingest repositories on demand. You don't need to call a separate ingestion function before querying.

Results are cached in memory during the server's runtime, so subsequent requests for the same repository will be faster. However, the cache is cleared when the server restarts.

Once a repository is ingested, you can access its data either by calling the `gitingest` tool again or by using the resources interface.

### Examples

**Get everything for a repository:**
```json
{
  "repo_uri": "https://github.com/user/repo"
}
```

**Get just the summary:**
```json
{
  "repo_uri": "https://github.com/user/repo",
  "resource_type": "summary"
}
```

**Get the file tree:**
```json
{
  "repo_uri": "https://github.com/user/repo",
  "resource_type": "tree"
}
```

**Get the full content:**
```json
{
  "repo_uri": "https://github.com/user/repo",
  "resource_type": "content"
}
```

**Custom ingestion parameters:**
```json
{
  "repo_uri": "https://github.com/user/repo",
  "branch": "dev",
  "exclude_patterns": "*.md,tests/*",
  "max_file_size": 5242880
}
```

**Using include patterns to focus on specific files:**
```json
{
  "repo_uri": "https://github.com/user/repo",
  "include_patterns": "src/*.py,bin/*"
}
```

**Note:** The patterns `src/*.py` and `bin/*` will only match Python files directly in the `src` directory and any files directly in the `bin` directory, not in subdirectories.

**Save output to a file:**
```json
{
  "repo_uri": "https://github.com/user/repo",
  "resource_type": "all",
  "output": "/path/to/output/file.txt"
}
```

## Configuration

## Quickstart

### Install

#### Claude Desktop

On MacOS: `~/Library/Application\ Support/Claude/claude_desktop_config.json`
On Windows: `%APPDATA%/Claude/claude_desktop_config.json`

Development/Unpublished Servers Configuration
```json
"mcpServers": {
  "trelis-gitingest-mcp": {
    "command": "uv",
    "args": [
      "--directory",
      "/Users/your-username/trelis-gitingest-mcp",
      "run",
      "trelis-gitingest-mcp"
    ]
  }
}
```

Published Servers Configuration
```json
"mcpServers": {
  "trelis-gitingest-mcp": {
    "command": "uvx",
    "args": [
      "trelis-gitingest-mcp"
    ]
  }
}
```

## Development

### Building and Publishing

To prepare the package for distribution:

1. Sync dependencies and update lockfile:
```bash
uv sync
```

2. Build package distributions:
```bash
uv build
```

This will create source and wheel distributions in the `dist/` directory.

3. Publish to PyPI:
```bash
uv publish
```

Note: You'll need to set PyPI credentials via environment variables or command flags:
- Token: `--token` or `UV_PUBLISH_TOKEN`
- Or username/password: `--username`/`UV_PUBLISH_USERNAME` and `--password`/`UV_PUBLISH_PASSWORD`

### Debugging

Since MCP servers run over stdio, debugging can be challenging. For the best debugging
experience, we strongly recommend using the [MCP Inspector](https://github.com/modelcontextprotocol/inspector).


You can launch the MCP Inspector via [`npm`](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm) with this command:

```bash
npx @modelcontextprotocol/inspector uv --directory /Users/your-username/trelis-gitingest-mcp run trelis-gitingest-mcp
```


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