Repository avatar
Version Control
v0.1.0
active

repopeek-mcp

io.github.kitepon/repopeek-mcp

Read-only GitHub MCP server (5 tools) over bare git — plain-text output, deny-by-default.

Documentation

RepoPeek — a snowy owl peering through a brass spyglass from a moonlit stone balcony into padlocked glass library vaults
This image represents clear, read-only observation from outside the vault — seeing every line without ever opening a write lock.

RepoPeek (repopeek-mcp)

CI License: MIT Node.js >= 20 Release Glama

English · 日本語

RepoPatch (Write Sibling) · Tools · Architecture · Security · Contributing · Releases · MIT License

Least-privilege read-only GitHub MCP server (5 tools) over bare git — plain-text output, deny-by-default.

Built and maintained by Quo at kitepon.dev.

Part of the kitepon GitHub MCP pair: RepoPeek (read-only, 5 tools — this repo) + RepoPatch (write-scoped diff commits & draft PRs, 5 tools). Split read and write into two small, auditable servers so AI agents get read access everywhere and write access only when editing.


Why RepoPeek?

  1. Blast-radius isolation: Most AI sessions only need to read code. RepoPeek has zero write tools, reads only from bare git objects (never a working tree, never a shell), and denies every repository unless explicitly listed in ALLOWED_REPOS.
  2. Plain-text connector reliability: Every tool result — errors included — is plain type: "text" content. Web connectors such as Gemini's custom MCP connector (which drop file bodies returned as MCP resource blocks) receive complete file contents reliably.

Official GitHub MCP vs. RepoPeek + RepoPatch

CapabilityOfficial GitHub MCPRepoPeek + RepoPatch
Tool surface~50+ tools in one server5 read (RepoPeek) + 5 write (RepoPatch)
Read / write token splitShared tokenStrictly separated (read-only PAT vs. write-scoped PAT)
Large-file editsFull-file push_files / create_or_update_file (truncates on LLM output limits)Server-side diff patching (old_text -> new_text, atomic 1-commit push)
Default-branch & force-push safetyRelies on prompt discipline / repo rulesHard-refused in server (main/master/default_branch, force: false, secret-path blocks)
Plain-text web connectors (Gemini, etc.)Mixed resource / JSON blocks100% plain type: "text" results

How the pair fits together

flowchart LR
  Client["AI Client (Gemini, Claude, Cursor, Codex)"]
  Peek["RepoPeek (5 read tools)<br/>bare git · plain text"]
  Patch["RepoPatch (5 write tools)<br/>branch · atomic diff · draft PR"]
  GH["GitHub (repos / Git Data API)"]

  Client -- "list / read / grep" --> Peek
  Peek -- "read-only PAT or public clone" --> GH
  Client -- "create_branch / patch_files / PR" --> Patch
  Patch -- "write-scoped PAT (non-default only)" --> GH

Tools (5 read-only)

ToolPurpose
list_reposList repositories allowed by ALLOWED_REPOS with their default branch
list_filesRecursively list files and directories (secret files and vendor dirs omitted)
read_fileRead a file with line numbers and start_line / end_line pagination
read_filesRead multiple files in one call with a total character cap
grepSearch file contents (git grep, fixed string or extended regex, optional glob)

Example tool call (grep -> read_file)

{
  "name": "grep",
  "arguments": {
    "repo": "octocat/Hello-World",
    "query": "Hello",
    "glob": "*.md"
  }
}
README:1: Hello World!

Full specs: tool contract · architecture & data flow · deploy guide.


Quick start (Docker Compose)

git clone https://github.com/kitepon/repopeek-mcp.git && cd repopeek-mcp

TOKEN=$(openssl rand -base64 32)          # Bearer token; save in your password manager
cat > docker-compose.override.yml <<EOF
services:
  repopeek-mcp:
    environment:
      - ALLOWED_REPOS=octocat/Hello-World
      - REPOPEEK_TOKEN_SHA256=$(printf %s "$TOKEN" | sha256sum | cut -d' ' -f1)
      - REPOPEEK_STORE_KEY=$(openssl rand -base64 32)
EOF

docker compose up -d --build
curl -s http://127.0.0.1:39230/health      # {"status":"ok","service":"repopeek-mcp"}

The server listens on 127.0.0.1:39230 and refuses to start without REPOPEEK_TOKEN_SHA256. Only the token's SHA-256 goes into config; clients send Authorization: Bearer $TOKEN. See docker-compose.override.yml.example for all options.

Without Docker (Node.js 20+ and git)

npm ci && npm run build
export REPOPEEK_TOKEN_SHA256=$(printf %s "$TOKEN" | sha256sum | cut -d' ' -f1)
export REPOPEEK_STORE_KEY=$(openssl rand -base64 32) ALLOWED_REPOS=octocat/Hello-World
npm start   # http://0.0.0.0:39230/mcp

Connect an MCP client

Static Bearer header (Cursor, Claude Code, Codex, generic Streamable HTTP clients)

{
  "mcpServers": {
    "repopeek": {
      "url": "https://repopeek.example.com/mcp",
      "headers": {
        "Authorization": "Bearer YOUR_MCP_TOKEN"
      }
    }
  }
}

Web connectors with OAuth 2.1 (Gemini, etc.)

  1. Deploy RepoPeek behind HTTPS and set REPOPEEK_PUBLIC_URL=https://<your-host>.
  2. Add a custom MCP connector with URL https://<your-host>/mcp.
  3. The client registers via DCR + PKCE S256 and opens /authorize (protected by Cloudflare Access when configured, or by the Bearer token form).
  4. Test with: "call list_repos", then list_files, read_file, and grep.

Configuration

VariableDefaultMeaning
REPOPEEK_TOKEN_SHA256requiredSHA-256 hex of the shared Bearer token (exits without it)
ALLOWED_REPOSempty (refuse all)Comma-separated owner/name or owner/* (case-insensitive)
REPOPEEK_PUBLIC_URLhttp://localhost:<PORT>Public origin advertised in OAuth metadata
PORT39230HTTP port
REPOPEEK_DATA_DIR./data (/data in Docker)OAuth store, wrapped store key, clones and mirrors
REPOPEEK_STORE_KEYunsetBase64 of 32 bytes; encrypts the OAuth store when no auth module is used
GITHUB_TOKENunsetRead-only fine-grained PAT (Contents: read) for private repos; unset = public only
REPOPEEK_LOCAL_REPOSemptyComma-separated owner/name=/path (local bare repo or checkout, never fetched)
REPOPEEK_FETCH_INTERVAL_SEC300Fetch / mirror sync interval (0 disables)
REPOPEEK_SECRET_PATTERNSemptyExtra comma-separated secret-file globs (*, ?)
REPOPEEK_ACCESS_TEAM_DOMAINunsetCloudflare Access team domain (set together with REPOPEEK_ACCESS_AUD)
REPOPEEK_ACCESS_AUDunsetCloudflare Access application AUD
REPOPEEK_ACCESS_EMAILSemptyOptional comma-separated e-mail allow-list
REPOPEEK_AUTH_SOCKETunsetAuth-module caller socket (module mode + wrapped store key)
REPOPEEK_WRAP_KEY_NAMEunsetAuth-module wrap key name
REPOPEEK_MODULE_ITEMSemptyComma-separated owner=item for auth-module mode
REPOPEEK_LIST_MAX_ENTRIES500list_files entry cap
REPOPEEK_READ_MAX_CHARS40000read_file output cap
REPOPEEK_READ_FILES_MAX_CHARS80000read_files default total cap
REPOPEEK_READ_FILES_MAX_CHARS_LIMIT400000Hard max for max_total_chars
REPOPEEK_GREP_MAX_RESULTS50grep default hit cap
REPOPEEK_GREP_MAX_RESULTS_LIMIT500Hard max for max_results
REPOPEEK_GREP_LINE_MAX_CHARS300grep line trim

Source modes

  • Public clone (github mode, default): git clone --bare over HTTPS into REPOPEEK_DATA_DIR/repos on first use, refreshed every REPOPEEK_FETCH_INTERVAL_SEC.
  • Private repositories (standalone): set GITHUB_TOKEN to a read-only fine-grained PAT (Contents: read). Passed via GIT_CONFIG_* env only — never in argv, remote URL, or tool output.
  • Local repositories: REPOPEEK_LOCAL_REPOS=owner/name=/path serves a local repo without fetching.
  • Auth module (optional): zero-PAT container mode over a Unix socket (REPOPEEK_AUTH_SOCKET); see docs/architecture.md.

Security model

  • Read-only: zero write tools.
  • Allowlist: empty ALLOWED_REPOS refuses all repositories.
  • Secret-file hiding: .env, .env.*, *.pem, *.key, *secret*, id_rsa*, id_ed25519*, *.p12, *.pfx, credentials.json, plus REPOPEEK_SECRET_PATTERNS are omitted from list_files/grep and refused by read_file/read_files.
  • Input validation: refs starting with - or containing :, .. segments, absolute paths, and pathspec magic are refused.
  • Authentication: /mcp requires Authorization: Bearer (only SHA-256 stored); OAuth 2.1 tokens are stored in AES-256-GCM; /authorize supports Cloudflare Access JWT (fail closed).

See SECURITY.md to report vulnerabilities.

Development

npm ci
npm run lint
npm run typecheck
npm run build
npm test

See CONTRIBUTING.md before opening a pull request.

Directory listings

License

MIT — built by kitepon.dev.