mcp-git-readonly
Provides read-only tools for interacting with a single Git repository, including viewing commit logs, diffs, and blame information, with argument-injection-safe refs and paths and capped output.
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
@trysac/mcp-git-readonly
Read-only MCP server for a single git repository. It registers exactly three tools — git_log, git_diff and git_blame — with strict validation for refs and repository-relative paths, fixed git argument vectors, no shell, and bounded output. git_log and git_blame return parsed arrays; git_diff returns raw diff text.
Features
Three read-only tools —
git_log,git_diffandgit_blame; no write operations, working-tree status or multi-repository access.Argument injection defenses — refs and paths are validated before any runner call; every command places
--end-of-optionsbefore revisions and--before paths.Restricted child environment — only
PATH,HOME,SYSTEMROOTandTEMPare passed through, plusGIT_LITERAL_PATHSPECS=1,GIT_TERMINAL_PROMPT=0,GIT_CONFIG_NOSYSTEM=1andGIT_OPTIONAL_LOCKS=0.Bounded resources — per-command timeout (default 10,000 ms), stdout byte cap (default 1,048,576 bytes) with UTF-8-boundary truncation, and stderr bounded to 10,000 characters in the runner and 200 characters in thrown git-failure messages.
Parsed and marked results — log and blame are parsed into JSON arrays; truncated MCP tool text gets a final
[truncated]line.
Related MCP server: mcp-repo-context
Installation
Not published to npm yet. Build it from a clone, then install it from the local path:
git clone https://github.com/Trysac/u219-mcp-git-readonly.git
cd u219-mcp-git-readonly && npm ci && npm run build
cd ../your-project && npm install ../u219-mcp-git-readonlyImports keep the package name: import { ... } from "@trysac/mcp-git-readonly".
Requires Node.js 20+ and an ESM-capable runtime.
Usage
As a library
import { createServer } from '@trysac/mcp-git-readonly';
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
const server = createServer({ root: '/absolute/path/to/repo' });
await server.connect(new StdioServerTransport());As a library helper
run(argv, io) starts a stdio MCP server when argv is exactly ['--repo', '<path>']. Invalid arguments write usage: mcp-git-readonly --repo <path> to stderr and return 2. The supplied source does not include a bundled executable; call it from a script you control:
import { run } from '@trysac/mcp-git-readonly';
process.exitCode = await run(process.argv.slice(2), process);Tools
Tool | Arguments | Returns |
|
| JSON array of |
|
| Raw diff text |
|
| JSON array of |
ref defaults to HEAD; maxCount defaults to 20 and must be an integer from 1 to 100. Ref validation allows 1–200 characters from [A-Za-z0-9._/@^~-], but rejects refs starting with - or /, containing .. or @{, or ending with .lock. Path validation allows 1–1024 characters, requires repository-relative / separators, and rejects absolute paths, backslashes, NUL bytes, empty/./.. segments, and any segment starting with :.
createGitTools({ root, runner?, timeoutMs?, maxOutputBytes? }) returns gitLog, gitDiff and gitBlame. createServer(opts) accepts the same options plus optional serverName and serverVersion. GitToolError has a code of invalid_ref, invalid_path, invalid_argument or timeout. A non-zero git exit throws Error('git failed: ...') with trimmed stderr capped at 200 characters; MCP handlers return that message text with isError: true.
Why not a shell tool or a git MCP server with write access
A shell tool can run arbitrary git commands and mutate the repository; general git MCP servers may expose write operations. This package exposes three read-only commands only, passes fixed argument vectors, and tests pin those vectors.
Security
See docs/SECURITY.md for the threat model and limitations.
Development
npm install
npx vitest run test/index.test.tsTool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
Related MCP Connectors
Read, search, edit, commit and run approved commands in projects on your own Mac or Linux computers.
Read-only scan of a public GitHub repo for leaked secrets, with a 0-100 grade.
Code intelligence for LLMs. Analyze, search, and retrieve code from any public git repository.
Provides read access to your GKE and Kubernetes resources.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceEnables read-only inspection of Git repository status and diff summaries, along with validation of OpenTofu and Ansible configurations, through a strictly limited, non-mutating toolset.MIT
- 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
- AlicenseNot gradedqualityBmaintenanceProvides bounded, read-oriented access to authorized local workspaces through filesystem and git tools, multimodal file inspection, and explicitly allowlisted named tasks, without exposing write, delete, or arbitrary-shell capabilities.51 npmMIT

IMALI Commanderofficial
FlicenseBqualityBmaintenanceEnables AI assistants to safely read, write, upload, download, search, and check git status within a single scoped folder, locally or over authenticated HTTPS, with optional read-only mode and audit logging.10293 npm-