osick/git-context
If you are the rightful owner of git-context and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to dayong@mcphub.com.
Git Context is a lightweight MCP server designed to provide LLMs with up-to-date documentation from Git repositories, primarily for GitLab but extensible to other platforms.
Git Context
A lightweight MCP (Model Context Protocol) server that provides LLMs with up-to-date documentation from Git repositories. Primarily designed for GitLab but extensible to other Git platforms.
Features
- Search GitLab repositories by name
- Retrieve documentation with topic filtering
- Support for multiple versions (tags/branches)
- Configurable via
git_context.jsonin repositories - SQLite storage for fast local access
- MCP protocol for seamless LLM integration
- Works with Kiro CLI and GitHub Copilot and other AI tools
Installation
From PyPI (Recommended)
uvx git-context
From Source
cd git-context
uv pip install -e .
Configuration
Git Context supports multiple configuration methods with the following priority (highest to lowest):
- Command-line arguments (
--gitlab-url,--gitlab-token) - Specified config file (
--config /path/to/config.yaml) - Environment variables (
GITLAB_URL,GITLAB_TOKEN) - Standard config locations:
~/.config/git-context/config.yaml~/.git-context/config.yaml./config.yaml(current directory)
Option 1: Environment Variables (Easiest for uvx)
export GITLAB_URL="https://gitlab.company.internal"
export GITLAB_TOKEN="glpat-your-token-here"
export STORAGE_PATH="~/.git-context/context.db" # Optional
uvx git-context
Option 2: Config File
Create ~/.config/git-context/config.yaml:
gitlab:
url: "https://gitlab.company.internal"
token: "${GITLAB_TOKEN}" # or hardcode token
storage:
path: "~/.git-context/context.db"
Option 3: Command-Line Arguments
uvx git-context \
--gitlab-url https://gitlab.company.internal \
--gitlab-token glpat-your-token
Usage
Index a Repository
With environment variables:
export GITLAB_URL="https://gitlab.company.internal"
export GITLAB_TOKEN="your_token"
uvx git-context --index group/project
With command-line arguments:
uvx git-context \
--gitlab-url https://gitlab.company.internal \
--gitlab-token glpat-your-token \
--index group/subgroup/repository
From source:
uv run git-context --index group/subgroup/repository
Run as MCP Server
With Claude Code / MCP Clients
Option 1: Using uvx with environment variables (Simplest)
Add to MCP settings (e.g., ~/.config/claude/mcp.json):
{
"mcpServers": {
"git-context": {
"command": "uvx",
"args": ["git-context"],
"env": {
"GITLAB_URL": "https://gitlab.company.internal",
"GITLAB_TOKEN": "${GITLAB_TOKEN}"
}
}
}
}
Option 2: Using uvx with config file
{
"mcpServers": {
"git-context": {
"command": "uvx",
"args": [
"git-context",
"--config",
"/home/user/.config/git-context/config.yaml"
]
}
}
}
Option 3: From source (for development)
{
"mcpServers": {
"git-context": {
"command": "uv",
"args": [
"--directory",
"/absolute/path/to/git-context",
"run",
"git-context"
],
"env": {
"GITLAB_URL": "https://gitlab.company.internal",
"GITLAB_TOKEN": "${GITLAB_TOKEN}"
}
}
}
}
With Kiro CLI
Add to ~/.config/kiro/mcp.json:
{
"mcpServers": {
"git-context": {
"command": "uvx",
"args": ["git-context"],
"env": {
"GITLAB_URL": "https://gitlab.company.internal",
"GITLAB_TOKEN": "${GITLAB_TOKEN}"
}
}
}
}
Then use:
kiro-cli chat
Ask questions like:
- "Search for python in GitLab"
- "Fuzzy search for fastmcp"
- "Get GitLab docs for /group1/subgroup1/repo1"
- "Show me documentation about vector search from GitLab repo group/subgroup/repository"
With GitHub Copilot (VS Code)
Add to .vscode/mcp.json:
{
"mcpServers": {
"git-context": {
"command": "uvx",
"args": ["git-context"],
"env": {
"GITLAB_URL": "https://gitlab.company.internal",
"GITLAB_TOKEN": "${GITLAB_TOKEN}"
}
}
}
}
Repository Configuration
Add a git_context.json file to your repository root to customize indexing:
{
"projectTitle": "API Documentation",
"description": "Internal API documentation and guides",
"folders": ["docs", "guides"],
"excludeFolders": ["node_modules", "dist"],
"excludeFiles": ["CHANGELOG.md"]
}
MCP Tools
gitlab-search-libraries
Search for GitLab libraries/projects by name (exact match).
Input: libraryName (string)
Output: List of matching libraries with IDs and versions
gitlab-fuzzy-search
Fuzzy search for GitLab repositories. Returns top matches even with typos or partial names.
Input:
query(string): Search term (can be partial or fuzzy)limit(integer, optional): Max results (default: 10)
Output: Ranked list of repositories with match scores
Example: Search "blueprint" finds "blueprint-for-skivi", "api-blueprint", etc.
gitlab-index-repository
Index a GitLab repository to make its documentation searchable.
Input: repository (string): Format group/project or group/subgroup/project
Output: Success/error message
Example: Index "mygroup/blueprint"
gitlab-index-group
Index all repositories in a GitLab group (including subgroups).
Input:
group(string): Group path (e.g., "groupname")includeSubgroups(boolean, optional): Include subgroups (default: true)
Output: Summary of indexed repositories
Example: Index entire "mygroup" group with all subgroups and repos
gitlab-get-docs
Retrieve documentation for a specific library.
Input:
libraryId(string): Format/group/projector/group/project/versiontopic(string, optional): Filter by topicpage(integer, optional): Page number (default: 1)
Output: Formatted documentation content
Architecture
┌──────────────┐ ┌─────────────────┐ ┌──────────────┐
│ LLM/AI │◄───────►│ Git Context │◄───────►│ GitLab │
│ Client │ MCP │ Server │ API │ Server │
└──────────────┘ └─────────────────┘ └──────────────┘
│
▼
┌─────────────────┐
│ SQLite DB │
└─────────────────┘
Troubleshooting
Configuration not found?
- Set environment variables:
export GITLAB_URL=... GITLAB_TOKEN=... - Or create config file at:
~/.config/git-context/config.yaml - Or use CLI args:
--gitlab-url --gitlab-token - Run
git-context --helpto see all options
Server not starting?
- Check configuration is valid (try
git-context --help) - Verify GITLAB_TOKEN is set or provided via config
- Ensure GITLAB_URL is accessible
- For uvx: Make sure environment variables are set in MCP config
No results when searching?
- Index the repository first:
uvx git-context --index group/project - Check database exists:
ls ~/.git-context/context.db - Verify you have access to the GitLab project
GitLab connection errors?
- Verify token has
read_apiscope - Check GitLab URL is accessible
- Ensure token hasn't expired
- Test connection:
curl -H "PRIVATE-TOKEN: $GITLAB_TOKEN" $GITLAB_URL/api/v4/user
Requirements
- Python 3.11+
- uv package manager
- GitLab server with API access
- Personal access token with
read_apiscope