Git MCP Server
Git MCP Server
A clean, modular Git MCP server supporting both GitHub and GitLab.
Quick Start
Claude Desktop Configuration
Add to your claude_desktop_config.json:
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
Windows: %APPDATA%\Claude\claude_desktop_config.json
GitHub
{
"mcpServers": {
"git": {
"command": "npx",
"args": ["-y", "@raytien/git-mcp-server"],
"env": {
"GIT_PROVIDER": "github",
"GIT_TOKEN": "ghp_xxxxxxxxxxxxxxxxxxxx"
}
}
}
}GitHub Enterprise
{
"mcpServers": {
"git": {
"command": "npx",
"args": ["-y", "@raytien/git-mcp-server"],
"env": {
"GIT_PROVIDER": "github",
"GIT_API_URL": "https://github.your-company.com/api/v3",
"GIT_TOKEN": "ghp_xxxxxxxxxxxxxxxxxxxx"
}
}
}
}GitLab.com (SaaS)
{
"mcpServers": {
"git": {
"command": "npx",
"args": ["-y", "@raytien/git-mcp-server"],
"env": {
"GIT_PROVIDER": "gitlab",
"GIT_TOKEN": "glpat-xxxxxxxxxxxxxxxxxxxx"
}
}
}
}Self-Hosted GitLab
{
"mcpServers": {
"git": {
"command": "npx",
"args": ["-y", "@raytien/git-mcp-server"],
"env": {
"GIT_PROVIDER": "gitlab",
"GIT_API_URL": "https://gitlab.your-company.com/api/v4",
"GIT_TOKEN": "glpat-xxxxxxxxxxxxxxxxxxxx"
}
}
}
}Read-Only Mode
{
"mcpServers": {
"git": {
"command": "npx",
"args": ["-y", "@raytien/git-mcp-server"],
"env": {
"GIT_PROVIDER": "github",
"GIT_TOKEN": "ghp_xxxxxxxxxxxxxxxxxxxx",
"GIT_READ_ONLY": "true"
}
}
}
}Get Your Token
GitHub
Go to GitHub > Settings > Developer settings > Personal access tokens > Tokens (classic)
Generate new token with scopes:
repo,read:org,workflowCopy the token (starts with
ghp_)
GitLab
Go to GitLab > Settings > Access Tokens
Create a new token with scopes:
api,read_api,read_repository,write_repositoryCopy the token (starts with
glpat-)
Available Tools
Repository
Tool | Description |
| Read file content from repository |
| List directory structure |
| Push file changes in a single commit |
| Create a new branch |
| List repository branches |
| List commit history |
| Search for code in repository |
Issues
Tool | Description |
| Get a single issue |
| List issues |
| Create a new issue |
| Update an issue |
Pull/Merge Requests
Tool | Description |
| Get a merge request |
| List merge requests |
| Create a merge request |
| Get merge request changes |
| Merge a merge request |
CI/CD (Pipelines / Workflow Runs)
Tool | Description |
| Get pipeline/workflow run status |
| List pipelines/workflow runs |
| List pipeline jobs/workflow jobs |
| Get job log output |
Note: GitHub Actions workflow runs map to GitLab pipelines. The same tools work for both platforms.
Comments
Tool | Description |
| Add comment to issue/MR |
| List comments |
Users
Tool | Description |
| Get current authenticated user |
Configuration
Environment Variable | Required | Default | Description |
| No |
| Provider type: |
| Yes | - | Personal Access Token |
| No | Provider default | API URL (auto-detected from provider) |
| No |
| Auth type: |
| No |
| Disable write operations |
| No |
| Log level: |
Architecture
src/
├── index.ts # Entry point
├── server.ts # MCP server (provider-agnostic)
├── config.ts # Configuration (multi-provider)
├── providers/ # Platform abstraction
│ ├── interface.ts # GitProvider interface
│ ├── types.ts # Platform-agnostic types
│ ├── config.ts # Provider configuration
│ ├── factory.ts # Provider Factory (creates GitLab/GitHub)
│ ├── gitlab/ # GitLab implementation
│ └── github/ # GitHub implementation
├── tools/ # Tool definitions
│ ├── define.ts # defineTool helper
│ ├── registry.ts # Tool registry
│ ├── repository/ # Repository tools
│ ├── issues/ # Issue tools
│ ├── merge-requests/ # PR/MR tools
│ ├── pipelines/ # CI/CD tools
│ ├── notes/ # Comment tools
│ └── users/ # User tools
├── gitlab/ # GitLab API client
│ ├── client.ts # HTTP client
│ └── types.ts # GitLab API types
├── github/ # GitHub API client
│ ├── client.ts # HTTP client
│ └── types.ts # GitHub API types
├── auth/ # Authentication
└── lib/ # UtilitiesDevelopment
# Install dependencies
npm install
# Build
npm run build
# Run tests
npm test
# Run locally
npm start
# Development mode (watch)
npm run devAdding a New Tool
Create file:
src/tools/{category}/{action}.ts
import { z } from 'zod';
import { defineTool, repoParam } from '../define.js';
const schema = z.object({
repo: repoParam,
// ... your params
});
export const myTool = defineTool({
name: 'my_tool',
description: 'What this tool does',
schema,
category: 'my-category',
read_only: true,
handler: async (input, ctx) => {
return ctx.provider.repository.someMethod(input.repo, ...);
},
});Export from category index:
src/tools/{category}/index.tsAdd to allTools:
src/tools/index.ts
Inspired By
gitlab-mcp - GitLab MCP server
github-mcp-server - Official GitHub MCP server
License
MIT
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/Ray0907/git-mcp-server'
If you have feedback or need assistance with the MCP directory API, please join our Discord server