io.github.Ray0907/git-mcp-server

السجل الرسمي أدوات المطورين

MCP server for GitLab and GitHub

ماذا يمكنك أن تفعل مع io.github.Ray0907/git-mcp-server؟

  • Create file: src/tools/{category}/{action}.ts
  • Export from category index: src/tools/{category}/index.ts
  • Add to allTools: src/tools/index.ts

التثبيت

أضف هذا إلى إعدادات MCP في عميلك (Claude Desktop: claude_desktop_config.json، وCursor: ‏.cursor/mcp.json، ويستخدم VS Code وغيره الصيغة نفسها «mcpServers»).

NPM package @raytien/git-mcp-server
Claude Code
claude mcp add git-mcp-server -e 'GIT_PROVIDER=<GIT_PROVIDER>' -e 'GIT_TOKEN=<your git_token>' -e 'GIT_API_URL=<GIT_API_URL>' -e 'GIT_READ_ONLY=<GIT_READ_ONLY>' -- npx -y @raytien/git-mcp-server@0.2.3
إعداد JSON (Claude Desktop وCursor وVS Code)
{
    "mcpServers": {
        "git-mcp-server": {
            "command": "npx",
            "args": [
                "-y",
                "@raytien/git-mcp-server@0.2.3"
            ],
            "env": {
                "GIT_PROVIDER": "<GIT_PROVIDER>",
                "GIT_TOKEN": "<your git_token>",
                "GIT_API_URL": "<GIT_API_URL>",
                "GIT_READ_ONLY": "<GIT_READ_ONLY>"
            }
        }
    }
}

متغيرات البيئة

  • GIT_PROVIDER Provider type: gitlab or github
  • GIT_TOKEN إلزامي سري Personal Access Token for GitHub or GitLab
  • GIT_API_URL API URL for self-hosted instances
  • GIT_READ_ONLY Disable write operations (true/false)

التوثيق

مأخوذ من ملف README للمشروع على GitHub ويُحدَّث أسبوعيًا. تفتح الروابط على GitHub.

المحتويات
  1. Git MCP Server
  2. Quick Start
  3. Available Tools
  4. Configuration
  5. Architecture
  6. Development
  7. Adding a New Tool
  8. Inspired By
  9. License

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
  1. Go to GitHub > Settings > Developer settings > Personal access tokens > Tokens (classic)
  2. Generate new token with scopes: repo, read:org, workflow
  3. Copy the token (starts with ghp_)
GitLab
  1. Go to GitLab > Settings > Access Tokens
  2. Create a new token with scopes: api, read_api, read_repository, write_repository
  3. Copy the token (starts with glpat-)

Available Tools

Repository
ToolDescription
get_file_contentsRead file content from repository
get_repository_treeList directory structure
push_filesPush file changes in a single commit
create_branchCreate a new branch
list_branchesList repository branches
list_commitsList commit history
search_codeSearch for code in repository
Issues
ToolDescription
get_issueGet a single issue
list_issuesList issues
create_issueCreate a new issue
update_issueUpdate an issue
Pull/Merge Requests
ToolDescription
get_pull_requestGet a merge request
list_pull_requestsList merge requests
create_pull_requestCreate a merge request
get_pull_request_diffsGet merge request changes
merge_pull_requestMerge a merge request
CI/CD (Pipelines / Workflow Runs)
ToolDescription
get_pipelineGet pipeline/workflow run status
list_pipelinesList pipelines/workflow runs
list_pipeline_jobsList pipeline jobs/workflow jobs
get_job_logGet job log output

Note: GitHub Actions workflow runs map to GitLab pipelines. The same tools work for both platforms.

Comments
ToolDescription
create_commentAdd comment to issue/MR
list_commentsList comments
Users
ToolDescription
get_meGet current authenticated user

Configuration

Environment VariableRequiredDefaultDescription
GIT_PROVIDERNogitlabProvider type: gitlab or github
GIT_TOKENYes-Personal Access Token
GIT_API_URLNoProvider defaultAPI URL (auto-detected from provider)
GIT_AUTH_TYPENobearerAuth type: bearer or private-token
GIT_READ_ONLYNofalseDisable write operations
LOG_LEVELNoinfoLog level: debug, info, warn, error

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/                  # Utilities

Development

# Install dependencies
npm install

# Build
npm run build

# Run tests
npm test

# Run locally
npm start

# Development mode (watch)
npm run dev

Adding a New Tool

  1. 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, ...);
    },
});
  1. Export from category index: src/tools/{category}/index.ts
  2. Add to allTools: src/tools/index.ts

Inspired By

License

MIT

الأسئلة الشائعة

ما هو io.github.Ray0907/git-mcp-server؟

MCP server for GitLab and GitHub

كيف أثبّت io.github.Ray0907/git-mcp-server؟

يعمل على جهازك. في Claude Code: claude mcp add git-mcp-server -e 'GIT_PROVIDER=<GIT_PROVIDER>' -e 'GIT_TOKEN=<your git_token>' -e 'GIT_API_URL=<GIT_API_URL>' -e 'GIT_READ_ONLY=<GIT_READ_ONLY>' -- npx -y @raytien/git-mcp-server@0.2.3. وفي العملاء الآخرين، الصق إعداد JSON من هذه الصفحة في إعدادات MCP الخاصة بهم.

هل يحتاج io.github.Ray0907/git-mcp-server إلى مفتاح API؟

نعم. يتطلب GIT_TOKEN، وتضبطها في إعداداته.

هل io.github.Ray0907/git-mcp-server مفتوح المصدر؟

نعم. شيفرته متاحة على GitHub بترخيص MIT.

من يصون io.github.Ray0907/git-mcp-server؟

ينشره Ray0907. يدرجه AI.tn لكنه لا يصونه ولا يوصي به.

من سجل MCP الرسمي. الإدراج ليس توصية: راجع شيفرة الخادم وصلاحياته قبل منحه الوصول إلى بياناتك.