doc-version-mcp
# π doc-version-mcp
[](https://www.python.org/downloads/)
[](https://github.com/jlowin/fastmcp)
[](https://opensource.org/licenses/MIT)
> **FastMCP Server for Document Versioning, Content-Addressable Storage (CAS), AST Diffs, and AI-Compliance Auditing.**
`doc-version-mcp` provides a robust, local-first document versioning engine built on top of the Model Context Protocol (MCP). It brings Git-like precision to LLM agents and human authors without cluttering Git commit histories, offering deterministic snapshots, word-level differential AST projections, and collaborative safety rails.
---
## β‘ Quick Start (Windows PowerShell One-Liner)
Install and configure `doc-version-mcp` automatically with a single command in PowerShell:
```powershell
irm https://raw.githubusercontent.com/hjamet/doc-version-mcp/main/install.ps1 | iex
```
The installer automatically:
1. Detects or creates the target directory (`~/Documents/code/doc-version-mcp`).
2. Configures a dedicated Python virtual environment (`.venv`) with all dependencies.
3. Initializes the Content-Addressable Storage (CAS) hierarchy at `~/.gemini/antigravity/cas_commits/`.
4. Registers the server into your Antigravity MCP configuration (`mcp_config.json`).
5. Copies metadata schemas and installs command-line wrappers (`doc-version.cmd`, `doc-version.ps1`).
---
## ποΈ Architecture & Key Features
```
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β LLM Agent / User β
ββββββββββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββ
β FastMCP Stdio Transport
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β doc-version-mcp β
β βββββββββββββββββββββββββββββ ββββββββββββββββββββββββββββ β
β β CAS Storage Engine β β AST & Diff Generator β β
β β - SHA-256 Addressing β β - LaTeX & KaTeX Diffs β β
β β - zlib Level 9 Compress β β - Mode 'paper' & 'draft'ββ
β β - Isolated Commit Trees β β - AI Compliance Auditingββ
β βββββββββββββββββββββββββββββ ββββββββββββββββββββββββββββ β
ββββββββββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Local Storage & Workspace Integrity β
β ~/.gemini/antigravity/cas_commits/{commits,objects}/ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
```
- **Content-Addressable Storage (CAS)**: Documents are stored as immutable, content-addressed blobs compressed via `zlib` (level 9) and indexed by SHA-256 hashes, keeping disk overhead minimal.
- **Dual Operational Modes**:
- **`paper` Mode**: Tailored for scientific manuscripts (LaTeX and Markdown). Analyzes mathematical environments, AST sections, and evaluates AI-stylometry metrics ($P(\text{AI}) < 0.10$).
- **`draft` Mode**: Dedicated to precision editing of drafts. Audits `<XXX>` uncertainty placeholders and enforces a strict text retention threshold ($\ge 90\%$).
- **Deterministic Collaboration**:
- Seamless upstream synchronization (`record_git_pull_event`) with automatic stashing (`--autostash`).
- Strict preservation of co-author contributions with blocking conflict detection.
- Zero uncontrolled global rewrites: changes are validated block-by-block.
- **Local-First & Portable**: Pure local Python package, independent of cloud services and fully compatible with multi-machine setups.
---
## π οΈ MCP Tools Reference
`doc-version-mcp` exposes 6 declarative MCP tools:
| Tool Name | Description | Key Parameters |
|---|---|---|
| `commit_document` | Creates a timestamped CAS snapshot of a document on disk or in virtual memory. | `target` (str, req), `message` (str, req), `author` (str, default `"agent"`), `content` (str, opt), `is_pinned` (bool, default `False`), `mode` (str, default `"paper"`) |
| `get_diff_artifact` | Computes surgical word-level diffs and generates an interactive Markdown artifact in Antigravity Brain. | `target` (str, req), `diff_explanation` (str, opt), `brain_dir` (str, opt), `artifact_name` (str, opt), `mode` (str, default `"paper"`), `from_commit_id` (str, opt), `to_commit_id` (str, opt) |
| `restore_commit` | Restores a document from a historical CAS commit ID. Supports dry-run preview. | `commit_id` (str, req), `target` (str, opt), `dry_run` (bool, default `False`) |
| `list_commits` | Lists stored CAS commits with timestamps, authors, and metadata. | `target` (str, opt), `limit` (int, default `10`), `mode` (str, opt) |
| `prune_commits` | Purges expired snapshots based on TTL and disk quota, protecting pinned baselines. | `ttl_days` (int, default `14`), `max_size_mb` (int, default `500`), `keep_baselines` (bool, default `True`) |
| `record_git_pull_event` | Synchronizes a Git repository via `git pull --rebase` with autostash and creates an upstream snapshot. | `repo_path` (str, req), `autostash` (bool, default `True`) |
---
## π§ Client Configuration Guide
### 1. Google Antigravity
Add the server to `~/.gemini/antigravity/mcp_config.json`:
```json
{
"mcpServers": {
"doc-version": {
"command": "C:\\Users\\<USER>\\Documents\\code\\doc-version-mcp\\.venv\\Scripts\\doc-version.exe",
"args": [],
"env": {
"SystemRoot": "C:\\Windows",
"PATH": "%PATH%"
}
}
}
}
```
### 2. Claude Desktop
Add to `%APPDATA%\Claude\claude_desktop_config.json`:
```json
{
"mcpServers": {
"doc-version": {
"command": "C:\\Users\\<USER>\\Documents\\code\\doc-version-mcp\\.venv\\Scripts\\doc-version.exe",
"args": []
}
}
}
```
### 3. Cursor
Configure in `.cursor/mcp.json` or Global Settings:
```json
{
"mcpServers": {
"doc-version": {
"command": "C:\\Users\\<USER>\\Documents\\code\\doc-version-mcp\\.venv\\Scripts\\doc-version.exe",
"args": []
}
}
}
```
### 4. Claude Code CLI
```bash
claude mcp add doc-version -- C:\Users\<USER>\Documents\code\doc-version-mcp\.venv\Scripts\doc-version.exe
```
---
## π» Local Development & Testing
### Installation from Source
```powershell
# Clone the repository
git clone https://github.com/hjamet/doc-version-mcp.git
cd doc-version-mcp
# Create and activate virtual environment
python -m venv .venv
.\.venv\Scripts\Activate.ps1
# Install in editable mode with development dependencies
pip install --upgrade pip
pip install -e ".[dev]"
```
### Running Test Suite
```powershell
pytest tests/ -v
```
### Manual Inspection & CLI Run
```powershell
# Verify FastMCP server entry point
doc-version --help
```
---
## π License
This project is licensed under the terms of the [MIT License](LICENSE).
TDQS
Scored across 6 tools
Each tool targets a distinct operation: git sync, snapshot creation, diff generation, restore, listing, and pruning. No overlapping purposes; descriptions clearly separate responsibilities.
All tools follow a consistent verb_noun snake_case pattern (record_git_pull_event, commit_document, get_diff_artifact, restore_commit, list_commits, prune_commits). Verbs and nouns are clear and predictable.
With 6 tools, the server is well-scoped for a document versioning domain. Each tool covers a core operation without redundancy, striking a balance between minimalism and functionality.
The tool surface covers the full lifecycle: create (commit_document), read/restore (restore_commit), list (list_commits), delete (prune_commits), diff (get_diff_artifact), and external integration (record_git_pull_event). No obvious gaps for the stated purpose.