Skip to content

feat: implement MCP server #505

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 21 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
024faab
refactor: Use GitPython instead of git in command line
iburel Aug 8, 2025
fcf1190
fix: properly use GitPython subcommands
NicolasIRAGNE Aug 8, 2025
6823eca
fix: properly use GitPython subcommands
NicolasIRAGNE Aug 8, 2025
6c698a0
feat: add MCP (Model Context Protocol) server support
iburel Aug 8, 2025
fae3a8c
test: add comprehensive MCP server testing and documentation
iburel Aug 8, 2025
fb86ace
test: add comprehensive MCP server testing and documentation
NicolasIRAGNE Aug 9, 2025
c4d8a57
fix: use mcp==1.12.4 instead of mcp>=1.0.0
Aug 12, 2025
cdcd9e5
drop support for Python 3.8/3.9, require 3.10+
Aug 12, 2025
3283428
fix: update test assertions to match GitPython implementation
Aug 12, 2025
9414238
style: apply pre-commit fixes
Aug 12, 2025
d600180
style: apply additional pre-commit fixes
Aug 12, 2025
961f8b8
fix: prevent exception information exposure in MCP server
Aug 12, 2025
caf7a11
fix: remove problematic docs and fix markdown formatting
Aug 12, 2025
d12805d
fix: remove problematic files to fix CI
Aug 12, 2025
7343b83
fix: resolve CodeQL security issues and pre-commit hook violations
Aug 12, 2025
7a7e600
fix: update mcp_server tests to match changed logging calls
Aug 12, 2025
dc94847
fix: disable pylint import-error for optional MCP dependency
Aug 12, 2025
903b52a
fix: correct token value in test to match expected value
Aug 12, 2025
773805e
fix: suppress remaining dynamic import violations
Aug 12, 2025
4d45775
fix: resolve all pre-commit hook violations
Aug 12, 2025
1e6b57c
refactor to run with --mcp and add metrics
NicolasIRAGNE Aug 12, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ["3.8", "3.13"]
python-version: ["3.10", "3.13"]
include:
- os: ubuntu-latest
python-version: "3.13"
Expand All @@ -43,7 +43,7 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install ".[dev,server]"
python -m pip install ".[dev,server,mcp]"

- name: Cache pytest results
uses: actions/cache@v4
Expand Down
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# Changelog

## [Unreleased]

### Features

* **mcp:** Add Model Context Protocol (MCP) server support
- New `--mcp` CLI option to start MCP server
- `ingest_repository` tool for LLM integration
- Full MCP protocol compliance with stdio transport
- Enhanced MCP client examples for stdio transport

## [0.3.1](https://github.com/coderamp-labs/gitingest/compare/v0.3.0...v0.3.1) (2025-07-31)


Expand Down
48 changes: 48 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ You can also replace `hub` with `ingest` in any GitHub URL to access the corresp
- Token count
- **CLI tool**: Run it as a shell command
- **Python package**: Import it in your code
- **MCP Server**: Model Context Protocol server for LLM integration

## 📚 Requirements

Expand All @@ -74,6 +75,12 @@ pip install gitingest[server]

to include server dependencies for self-hosting.

For MCP (Model Context Protocol) support:

```bash
pip install gitingest[mcp]
```

However, it might be a good idea to use `pipx` to install it.
You can install `pipx` using your preferred package manager.

Expand Down Expand Up @@ -150,6 +157,47 @@ See more options and usage details with:
gitingest --help
```

## 🤖 MCP (Model Context Protocol) Server

Gitingest includes an MCP server that allows LLMs to directly access repository analysis capabilities through the Model Context Protocol.

### Starting the MCP Server

```bash
# Start the MCP server with stdio transport
python -m mcp_server
```

### Available Tools

The MCP server provides the following tools:

- **`ingest_repository`**: Ingest a Git repository or local directory and return a structured digest

### Example MCP Client

See `examples/mcp_client_example.py` for a complete example of how to use the MCP server.

### Configuration

Use the provided `examples/mcp-config.json` to configure the MCP server in your MCP client:

#### Stdio Transport (Default)

```json
{
"mcpServers": {
"gitingest": {
"command": "python",
"args": ["-m", "mcp_server"],
"env": {
"GITHUB_TOKEN": "${GITHUB_TOKEN}"
}
}
}
}
```

## 🐍 Python package usage

```python
Expand Down
Loading
Loading