local-repo-mcp

local-repo-mcp

Secure agent coding runtime for local Git repos with policy enforcement, RBAC, sessions, approval workflow, and sandboxed writes, optionally connectable to ChatGPT via Secure MCP Tunnel.

Category
访问服务器

README

Local Repo MCP

<p align="right"><strong>English</strong> · <a href="./README.zh-CN.md">简体中文</a></p>

<p align="center"><strong>Safely connect one local Git repository to any MCP client.</strong></p>

<p align="center"> Read, search, inspect Git changes, apply validated text patches, and optionally run trusted tests—without exposing a general-purpose shell or your entire filesystem. </p>

Why this project?

Local Repo MCP solves one narrow problem:

Give ChatGPT, Claude, Cursor, and other MCP clients enough access to work with one local Git repository, while keeping the permission boundary small and understandable.

It is deliberately not an enterprise agent platform, policy engine, RBAC service, or terminal agent.

Highlights

  • One configured Git repository only
  • Read-only by default
  • No general-purpose shell
  • No unrestricted write_file
  • Validated text-patch writes
  • Filtered Git status and diff
  • No Git push, pull, checkout, reset, rebase, merge, stash, or clean
  • Optional predefined tests for trusted repositories
  • STDIO and Streamable HTTP transports
  • Optional OpenAI Secure MCP Tunnel
  • Simplified Chinese and English GUI

Architecture

Local client with STDIO

Local MCP client
      │
      │ starts a subprocess
      ▼
Local Repo MCP (STDIO)
      │
      ▼
One local Git repository

URL-based client with Streamable HTTP

MCP client
    │
    │ http://127.0.0.1:8000/mcp
    ▼
Local Repo MCP (Streamable HTTP)
    │
    ▼
One local Git repository

ChatGPT with Secure MCP Tunnel

ChatGPT
   │
OpenAI Secure MCP Tunnel
   │
tunnel-client
   │
Local Repo MCP (STDIO or HTTP)
   │
Local Git repository

Tools

Tool Minimum mode Description
repo_list_files read List allowed repository files
repo_read_file read Read one UTF-8 text file
repo_search_code read Fixed-string source-code search
repo_git_status read Filtered Git working-tree status
repo_git_diff read Filtered staged or unstaged diff
repo_apply_patch write Apply one validated unified text patch
repo_run_test test Run one predefined test command

Access modes

Mode Meaning
read Read, search, Git status, and Git diff
write Read tools plus validated patch application
test Write tools plus predefined test commands

Start with read.

Transports

STDIO

Use STDIO when the MCP client runs on the same machine and can launch a subprocess. STDIO has no host, port, or endpoint URL.

Streamable HTTP

Use Streamable HTTP for clients that connect to an MCP URL or run in another process/device.

Default endpoint:

http://127.0.0.1:8000/mcp

Security defaults:

  • binds to 127.0.0.1;
  • built-in Host/Origin validation;
  • optional Bearer Token;
  • non-local binds require Bearer authentication and an explicit allowed-host list.

Do not bind to 0.0.0.0 without understanding the network exposure. Use HTTPS through a trusted reverse proxy for non-local deployments.

Requirements

  • Python 3.11+
  • Git 2.39+
  • ripgrep (rg)
  • optional: OpenAI tunnel-client

Docker is not required.

Install

git clone https://github.com/cloud-Xolt/local-repo-mcp.git
cd local-repo-mcp
python -m venv .venv

Windows PowerShell:

.\.venv\Scripts\Activate.ps1
python -m pip install --upgrade pip
python -m pip install -r requirements.txt
python run_gui.py

Linux / macOS:

source .venv/bin/activate
python -m pip install --upgrade pip
python -m pip install -r requirements.txt
python run_gui.py

GUI

The GUI has five focused pages:

  1. Home — repository, access mode, transport, and common settings
  2. MCP Server — process status, real MCP handshake test, and client configuration
  3. ChatGPT Connection — Secure MCP Tunnel setup and diagnostics
  4. Logs — MCP, Tunnel, and audit logs
  5. About — scope, version, documentation, and project links

Common settings stay visible. Limits, dirty-worktree behavior, audit logging, and HTTP allowlists are collapsed under Advanced Settings.

The GUI stores normal configuration under the current user's config directory. The OpenAI runtime API key is memory-only and is never written to disk. An HTTP Bearer token, when enabled, is stored separately with restrictive file permissions.

Run without the GUI

STDIO

Linux / macOS:

export REPO_ROOT="/absolute/path/to/repository"
export MCP_MODE="read"
export MCP_TRANSPORT="stdio"
python server.py

Windows PowerShell:

$env:REPO_ROOT = "C:\absolute\path\to\repository"
$env:MCP_MODE = "read"
$env:MCP_TRANSPORT = "stdio"
python server.py

Example local-client configuration:

{
  "mcpServers": {
    "local-repo": {
      "command": "/absolute/path/to/.venv/bin/python",
      "args": ["/absolute/path/to/local-repo-mcp/server.py"],
      "env": {
        "REPO_ROOT": "/absolute/path/to/repository",
        "MCP_MODE": "read",
        "MCP_TRANSPORT": "stdio"
      }
    }
  }
}

Streamable HTTP

export REPO_ROOT="/absolute/path/to/repository"
export MCP_MODE="read"
export MCP_TRANSPORT="streamable-http"
export HTTP_HOST="127.0.0.1"
export HTTP_PORT="8000"
export HTTP_PATH="/mcp"
python server.py

Connect to:

http://127.0.0.1:8000/mcp

Bearer authentication:

export HTTP_AUTH_MODE="bearer"
export HTTP_AUTH_TOKEN="replace-with-a-random-token"

Real connection test

The GUI connection test does not merely check that a directory exists. It:

  1. creates an MCP client session;
  2. performs protocol initialization;
  3. lists the tools;
  4. verifies the expected read tools;
  5. calls repo_git_status;
  6. closes the session cleanly.

For STDIO it launches a temporary child process. For HTTP it connects to the running endpoint.

ChatGPT and Secure MCP Tunnel

Install tunnel-client from an official OpenAI source. This project does not download or update it automatically.

STDIO profile example:

export CONTROL_PLANE_API_KEY="sk-..."

tunnel-client init \
  --sample sample_mcp_stdio_local \
  --profile local-repo \
  --tunnel-id tunnel_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx \
  --mcp-command "/absolute/path/to/.venv/bin/python /absolute/path/to/local-repo-mcp/launch_mcp.py"

tunnel-client doctor --profile local-repo --explain
tunnel-client run --profile local-repo

The GUI can detect the executable, initialize a profile, run Doctor, and start/stop the Tunnel. The runtime API key remains in memory only.

For HTTP Tunnel mode, start the HTTP MCP server first. Automatic HTTP Tunnel setup currently supports an unauthenticated localhost endpoint; for custom Bearer-authenticated HTTP Tunnel setups, configure tunnel-client manually or use STDIO Tunnel.

Configuration

Core

Variable Default Description
REPO_ROOT . The single repository root
MCP_MODE read read, write, or test
MCP_TRANSPORT stdio stdio or streamable-http
MAX_FILE_BYTES 200000 Maximum readable file size
MAX_PATCH_BYTES 200000 Maximum patch size
MAX_SEARCH_RESULTS 50 Search result limit
MAX_OUTPUT_BYTES 20000 Diff/test output limit
ALLOW_DIRTY_WORKTREE false Allow patching a dirty worktree
AUDIT_LOG empty Optional audit JSONL path
TEST_TIMEOUT_MAX 300 Maximum test timeout

HTTP

Variable Default Description
HTTP_HOST 127.0.0.1 Bind address
HTTP_PORT 8000 Listen port
HTTP_PATH /mcp MCP endpoint path
HTTP_AUTH_MODE none none or bearer
HTTP_AUTH_TOKEN empty Bearer token
HTTP_ALLOWED_HOSTS localhost values Host allowlist
HTTP_ALLOWED_ORIGINS localhost values Origin allowlist
HTTP_JSON_RESPONSE true JSON response mode
HTTP_STATELESS true Stateless HTTP mode
HTTP_MAX_REQUEST_BYTES 262144 Maximum request body

Security model

The project is designed for one local user and one configured Git repository.

Controls include:

  • relative paths only;
  • parent traversal rejected;
  • symbolic links rejected;
  • common sensitive files blocked;
  • binary/non-UTF-8 reads rejected;
  • fixed-string ripgrep invocation with shell=False;
  • blocked paths filtered from Git status and diff;
  • text-patch-only writes;
  • binary, rename, copy, submodule, symlink, and mode-change patches rejected;
  • common credential patterns blocked in added patch lines;
  • bounded inputs and outputs;
  • no general-purpose shell;
  • no automatic branch, commit, or push operations.

Limitations:

  • common credential detection is not a complete secret scanner;
  • write mode modifies the current worktree;
  • test mode executes repository code and must be used only with trusted repositories;
  • the MCP client controls user-facing confirmations;
  • users should inspect git diff, commit, and push manually.

See SECURITY.md.

Predefined tests

Key Command
python_pytest python -m pytest -q
go_test go test ./...
node_test npm test --
node_lint npm run lint --
maven_test mvn test
gradle_test ./gradlew test

Users cannot provide arbitrary commands or additional command arguments.

Development

python -m pytest tests/ -v
python -m compileall server.py launch_mcp.py run_gui.py src gui

Project scope

In scope:

  • one local Git repository;
  • safe reading and search;
  • filtered Git inspection;
  • validated text patches;
  • optional predefined tests;
  • STDIO and Streamable HTTP;
  • optional GUI and Secure MCP Tunnel.

Out of scope:

  • arbitrary shell access;
  • general filesystem access;
  • RBAC and multi-user hosting;
  • enterprise policy engines or risk scoring;
  • automatic branch management;
  • automatic commit, merge, or push;
  • cloud execution and untrusted-code sandboxing;
  • automatic tunnel-client installation.

License

MIT License. See LICENSE.

推荐服务器

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 模型以安全和受控的方式获取实时的网络信息。

官方
精选