git-mcp-server

git-mcp-server

A secure, git-aware MCP server for working with local repositories, enabling file management, shell commands, and full git operations within allowed directories.

Category
访问服务器

README

git-mcp-server

A secure, git-aware MCP server for working with local repositories inside LM Studio (or any MCP host).

Features

  • Full file access — read, write, edit, create, delete, move, search
  • Shell execution — run commands in allowed directories with blocked dangerous patterns
  • Complete git workflow — status, diff, log, branch, checkout, add, commit, push, pull, stash
  • Path sandboxing — every operation is validated against your allowed directories; path traversal is blocked
  • No network calls — inference stays local, this server never phones home

Prerequisites

  • Node.js 18+
  • npm
  • git

Installation

# 1. Clone or copy this folder somewhere permanent
cd ~/tools
git clone <this-repo> git-mcp-server  # or just copy the folder

# 2. Install dependencies
cd git-mcp-server
npm install

# 3. Build
npm run build

After build, the server binary is at dist/index.js.

Configure LM Studio

Open Developer tab → Install → Edit mcp.json in LM Studio and add:

{
  "mcpServers": {
    "git-mcp": {
      "command": "node",
      "args": [
        "/absolute/path/to/git-mcp-server/dist/index.js",
        "--allow-dir", "/path/to/your/repo"
      ]
    }
  }
}

Multiple repos

{
  "mcpServers": {
    "git-mcp": {
      "command": "node",
      "args": [
        "/absolute/path/to/git-mcp-server/dist/index.js",
        "--allow-dir", "/home/user/projects/repo-one",
        "--allow-dir", "/home/user/projects/repo-two"
      ]
    }
  }
}

Using environment variable instead

{
  "mcpServers": {
    "git-mcp": {
      "command": "node",
      "args": ["/absolute/path/to/git-mcp-server/dist/index.js"],
      "env": {
        "ALLOWED_DIRS": "/home/user/projects/repo-one:/home/user/projects/repo-two"
      }
    }
  }
}

On Windows use ; as the separator in ALLOWED_DIRS.

Security model

Layer What it does
Path sandboxing Every file/shell operation resolves the absolute path and checks it starts with an allowed dir. Path traversal (../) is blocked.
Shell blocklist rm -rf, sudo, mkfs, dd of=, curl | sh, eval, and similar patterns are rejected before execution.
No root directories You must explicitly list allowed dirs — there is no "allow everything" mode.
Delete is file-only delete_file refuses to delete directories; use run_command for that explicitly.
LM Studio confirmation LM Studio shows a confirmation dialog for every tool call, so you review before anything executes.

Available tools

File tools

Tool Description
read_file Read a single file
read_multiple_files Read several files in one call
list_directory List entries in a directory
directory_tree Recursive tree view (depth-limited)
write_file Write / overwrite a file
edit_file Targeted search-and-replace (returns diff)
create_directory Create directory with parents
delete_file Delete a file (not directories)
move_file Move or rename within allowed dirs
search_files Regex search across a directory

Shell

Tool Description
run_command Run a shell command in an allowed directory

Git

Tool Description
git_status Working tree status
git_diff Diff working tree, index, or refs
git_log Commit history
git_branch List, create, delete, rename branches
git_checkout Switch branches / create new ones
git_add Stage files
git_commit Commit staged changes
git_push Push to remote
git_pull Pull from remote (merge or rebase)
git_stash Save, pop, list, or drop stashes

Example prompts

Once connected in LM Studio:

  • "Show me the status of the repo at ~/projects/myapp"
  • "List all branches and tell me which has the most recent commit"
  • "Read src/index.ts and refactor the error handling"
  • "Stage all modified files and commit with the message 'fix: handle null case'"
  • "Search for all usages of fetchUser across the repo"
  • "Create a new branch called feature/auth and switch to it"

Recommended models for code work

Good tool-calling support is required. These work well locally:

  • Qwen3 8B / 14B — excellent function calling, strong at code
  • Llama 4 Scout — solid tool use, good multilingual support
  • Mistral 7B Instruct — fast, reliable for single-tool workflows

Q4_K_M quantization is the recommended starting point.

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选