Cross Repo Ops MCP
Cross Repo Ops MCP
一个仓库中立的 MCP(Model Context Protocol)能力层,用于受控的本地仓库操作。
功能
Cross Repo Ops MCP 提供了一个安全加固的 stdio JSON-RPC 服务器,可在本地 git 仓库上暴露有界、受策略控制的操作:
读取:目录树列表、ripgrep 搜索、有界文件读取、git status/diff
写入:带 create/modify 支持的上下文校验补丁(仅可写仓库)
任务:已批准的命名任务执行(仅限允许列表,不允许任意 shell 命令)
Git:列出/创建/切换分支、提交(仅显式列出的文件)、推送(仅 origin,且仅可推送仓库)
Related MCP server: git-remote-mcp
架构
Cross Repo Ops MCP 是一个仓库中立的能力层,用于受控的本地仓库操作。它被设计为位于 XcodeIDEapp 项目旁边,借鉴了 IDE 仪表盘脚手架模式的思路,但保持通用,不依赖任何特定的 IDE 或项目结构。
Cross Repo Ops MCP = controlled local repository actions (read, patch, git, tasks)该服务器是策略驱动的:仓库、能力、排除路径和已批准任务都在 JSON 配置中声明。核心中没有硬编码任何项目特定的逻辑。
模块
模块 | 职责 |
| 集中式仓库能力策略(允许列表、writable/pushable 标志、排除路径、任务允许列表、限制、超时) |
| 单一权威路径验证边界(遍历、符号链接、绝对路径、包含性检查) |
| 目录树列表、ripgrep 搜索、有界文件读取、git status/diff |
| 带 create/modify 支持的上下文校验补丁应用 |
| 带安全防护的分支、提交和推送操作 |
| 命名任务允许列表的解析与执行 |
| stdio JSON-RPC MCP 服务器 |
| 错误类型 |
安全模型
仓库允许列表:只有策略中显式列出的仓库才可访问。
能力标志:
writable和pushable按仓库设置,默认false。路径包含性:所有路径都会解析并对照仓库根目录进行检查。拒绝路径遍历(
..)、绝对路径和符号链接。敏感文件排除:
.env、*.pem、API 密钥、令牌、凭据和二进制文件被阻止读取和写入。补丁安全:
old_text必须精确匹配;多个匹配时需要context来消除歧义。create=true拒绝覆盖已有文件。任务允许列表:任务按名称从服务器端允许列表中解析,而非来自用户输入。不允许任意 shell 命令。
Git 安全:拒绝批量暂存(
git add -A)。提交仅限于显式列出的文件。敏感文件不能被提交。分支名称会针对注入进行校验。推送仅限于origin,且仅限可推送仓库。输出限制:所有操作都有可配置的输出上限(读取字符数、搜索结果数、目录树条目数、diff 字符数、任务输出)。
安装
# No external dependencies required — Python 3.10+ standard library only.
cd cross-repo-ops
pip install -e . # optional, for package install使用方法
运行 MCP 服务器
python3 -m cross_repo_ops服务器在 stdin/stdout 上监听 JSON-RPC 2.0 消息。
自定义策略
CROSS_REPO_OPS_CONFIG=/path/to/policy.json python3 -m cross_repo_ops策略文件格式
{
"repos": {
"myrepo": {
"root": "/path/to/repo",
"writable": true,
"pushable": false
}
},
"tasks": {
"myrepo": {
"build": {
"command": ["xcodebuild", "-scheme", "MyApp", "build"],
"cwd": "{root}",
"timeout": 180
},
"test": {
"command": ["xcodebuild", "test", "-scheme", "MyApp"],
"cwd": "{root}",
"timeout": 300
}
}
}
}MCP 工具
工具 | 描述 |
| 列出文件/目录,并应用安全排除 |
| 带输出上限的 ripgrep 搜索 |
| 读取非敏感文本文件的有界片段 |
| 检查 git 状态 |
| 查看未暂存/已暂存/提交的 diff |
| 应用上下文校验的补丁(仅可写仓库) |
| 运行已批准的命名任务(仅限允许列表) |
| 列出/创建/切换分支(创建/切换需要可写仓库) |
| 暂存并提交显式列出的文件(仅可写仓库) |
| 推送到 origin(仅可推送仓库) |
测试
python3 -m unittest tests.test_security tests.test_adversarial -v32 个测试,涵盖:
允许和阻止的读取
路径遍历、绝对路径和符号链接逃逸的拒绝
敏感文件的读取/写入/提交阻止
可写与只读仓库的强制实施
正确/过时上下文的补丁
针对排除文件的补丁
命名任务允许列表(成功、未知名称、shell 注入尝试)
任务超时和输出截断
Git status/diff
分支名称注入防护
提交防护(空消息、敏感文件、批量暂存、预先暂存的文件)
对不可推送仓库的推送拒绝
服务器缺少参数的处理
许可证
MIT
Available Tools
10 toolsapply_patchB
Apply a bounded, context-checked patch to a file in a writable repository. If old_text is empty and create=true, creates the file.
Inputs: path (required), repo (required), new_text (required), old_text (required), +2 more.
git_branchC
List or safely create a branch in a repository.
Inputs: repo (required), action (required), branch_name.
git_commitC
Stage and commit files in a writable repository.
Inputs: repo (required), files (required), message (required).
git_diffC
View the diff of unstaged or staged changes in a repository.
Inputs: repo (required), path, commit, staged, +1 more.
git_pushC
Push the current or specified branch to origin in a pushable repository.
Inputs: repo (required), branch, remote.
git_statusC
Inspect the current Git repository status.
Inputs: repo (required).
repo_readB
Read a bounded slice of a non-sensitive text file from an allowed repository.
Inputs: path (required), repo (required), max_lines, start_line.
repo_searchB
Search an allowed repository using ripgrep with bounded output and safety exclusions.
Inputs: repo (required), pattern (required), path, file_glob, +6 more.
repo_treeC
List files and directories in an allowed repository with safety exclusions.
Inputs: repo (required), path, max_entries, include_hidden.
run_taskB
Run an approved named task for a repository. No arbitrary shell commands are accepted.
Inputs: name (required), repo (required).
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 10 tools
Each tool maps cleanly to a distinct action: repo_* covers content browsing/search, git_* covers repository state operations, and apply_patch/run_task cover modifications. Adjacent tools like git_status and git_diff are clearly separated by purpose. No two tools appear to do the same thing.
Most tools follow a clear domain-prefix pattern: repo_* for content operations and git_* for VCS operations. The exceptions are apply_patch and run_task, which use bare verb_noun names but remain readable and consistent with the overall snake_case style.
Ten tools is an ideal size for this scope; each tool covers a distinct operation without redundancy. The set feels intentionally scoped rather than padded.
The read/search → patch → branch → commit → push workflow provides a complete edit-and-publish lifecycle. Minor gaps include no repository enumeration, no git pull/fetch, and no way to list approved run_task tasks, but these do not block the primary workflow.
Maintenance
Related MCP Connectors
MCP gateway with runtime security policy, tool-call-level control, and audit of agent actions.
One MCP server for all your MCP servers: code mode, per-tool permissions, approvals and audit.
MCP server for mandates, delegation, policy-gated execution, credential grants, and audit.
Remote MCP for Android CLI agent build gate, structured receipts, audit logs, and reviewer-ready evi
Related MCP Servers
- AlicenseAqualityCmaintenanceEnables safe filesystem and git operations confined within a single allowed directory tree, using symlink-resolved path containment to protect against path traversal. Users can read, write, list, and search files, as well as initialize repos and run status, stage, commit, diff, and log operations through MCP.11MIT
- AlicenseCqualityCmaintenanceEnables MCP clients to inspect and modify local git repositories by running commands such as status, log, diff, add, commit, branch, and stash. Push operations are not performed locally; instead diffs are sent to a configurable HTTP API that handles the upload, with all other remote git commands blocked.27MIT
- AlicenseNot gradedqualityBmaintenanceEnables read-only, allowlisted filesystem and Git inspection of explicitly configured local repositories through MCP, with bounded reads and no arbitrary path or write access.11 npmMIT
- AlicenseNot gradedqualityBmaintenanceEnables MCP clients to inspect local Git repositories through five focused, read-only tools for repository trees, literal text search, numbered file reads, bounded git diffs, and project summaries while confining paths, skipping secret-like and binary files, and enforcing output limits.MIT