Files in the top-level directory from the latest check-in
- .fossil-settings
- .grok
- fossil_mcp
- tests
- bootstrap.sh
- FOSSIL-FOR-AGENTS.md
- pyproject.toml
- README.md
fossil-scm-mcp
A Model Context Protocol (MCP) server for Fossil SCM. Designed for low-latency, high-context AI agent workflows with LLMs (Claude, Cursor, etc). Exposes Fossil's versioning, artifacts, timeline, and durable tech notes as first-class tools and resources.
Quick Start for Other AI Agents (Self-Bootstrapping from Fossil Remote)
🚨 CRITICAL RULE — AGENTS MUST OBEY THIS WITHOUT EXCEPTION 🚨
This entire project (and any work you perform while inside this checkout or any subdirectory) is stored exclusively in a Fossil SCM repository.
- DO NOT USE
git(or any git command, .git files, etc.) ANYWHERE inside this directory tree. - Use only
fossilfor version control. - This rule applies even if you create sub-projects inside the tree.
This is the most important rule for any agent using this MCP. The whole point of this server is to demonstrate and enforce proper Fossil-only workflows.
0. Check that Fossil is installed (required before anything else)
# Check for Fossil
if command -v fossil >/dev/null 2>&1; then
echo "✓ Fossil found: $(fossil version | head -1)"
else
echo "✗ Fossil is NOT installed in PATH."
echo ""
echo "Install Fossil for your platform:"
echo ""
echo " • Linux (Debian / Ubuntu / Mint): sudo apt update && sudo apt install fossil"
echo " • Linux (Fedora / RHEL / Rocky): sudo dnf install fossil"
echo " • Linux (Arch / Manjaro): sudo pacman -S fossil"
echo " • Linux (openSUSE): sudo zypper install fossil"
echo " • macOS (Homebrew): brew install fossil"
echo " • Windows: Download the .exe from https://fossil-scm.org/home/uv/download.html"
echo " • Any OS (official binaries): https://fossil-scm.org/home/uv/download.html"
echo ""
echo "After installing, verify with: fossil version"
echo "Then re-run the steps below."
exit 1
fi
This project is designed to be installed directly by another agent from the public Fossil repository, without Git.
# 1. Acquire the source using Fossil (the correct tool)
fossil clone https://refaqtory.net/fossil-scm-mcp /tmp/fossil-scm-mcp.fossil
# 2. Open a checkout in your working area
mkdir -p ~/agent-work/fossil-scm-mcp
cd ~/agent-work/fossil-scm-mcp
fossil open /tmp/fossil-scm-mcp.fossil
# 3. Bootstrap the Python environment (creates .venv, which is ignored)
./bootstrap.sh
# 4. Run the MCP server
.venv/bin/python -m fossil_mcp
# or the shorter alias
.venv/bin/fossil-mcp
Once running, the server provides the special resource fossil://agent/fossil-best-practices (also available as the file FOSSIL-FOR-AGENTS.md). Read it immediately — it teaches you the correct "Fossil way" (atomic commits, heavy use of tech notes for memory, keeping the repo perfectly clean, etc.).
The bootstrap.sh script prefers uv when available (excellent for agents) and falls back to a standard venv. The resulting environment lets you run the server or the integration test with almost zero friction.
The clone URL above corresponds to the repository browsable at the URL you were given (https://refaqtory.net/fossil-scm-mcp/dir?ci=tip).
Goals & Constraints
- Strict Fossil-only: All source/version history lives in Fossil. Zero Git usage. No untracked junk.
- Low latency, high context: Minimal parsing overhead, compact outputs tuned for LLM context windows. Direct
fossilCLI calls via subprocess (no heavy libs). - Safety first: Never
shell=True. All arguments properly escaped/list-passed. Commit requires explicit message. Graceful structured errors. - Agent memory: First-class support for Fossil Tech Notes (
fossil_technote) for persistent cross-session agent state, design logs, decisions. - Portable: Pure Python + stdio. Works anywhere Fossil is in PATH.
Proposed Architecture (Baseline)
Runtime & SDK
- Python >= 3.10 (target 3.12)
mcpofficial SDK (FastMCP high-level server) for correct, low-boilerplate MCP protocol handling (initialize, tools/list, tools/call, resources/read, error mapping, stdio framing).- Transport: stdio only (no SSE/HTTP for this server; keeps it simple/daemonless for CLI agents).
Project Layout (final)
.
├── .fossil-settings/
│ └── ignore-glob # aggressively ignore venvs, __pycache__, build, test artifacts
├── README.md
├── pyproject.toml # modern packaging, deps (mcp), scripts
├── fossil_mcp/
│ ├── __init__.py
│ ├── __main__.py # `python -m fossil_mcp`
│ └── server.py # FastMCP instance, all @tool / @resource
└── tests/
└── integration_test.py # spawns server over stdio, drives JSON-RPC, asserts responses
Implementation Strategy
- Thin CLI adapter layer: helper
run_fossil(args: list[str], input: str | None = None, timeout=30) -> strusingsubprocess.run(..., shell=False). - Structured tools return compact JSON (as text) or LLM-friendly minimal text.
- Tech notes via
fossil wiki ... --technote ...(create/export/commit). Append implemented by read-modify-write. - Resources are read-only snapshots (no side effects).
- All errors (missing artifact, bad ref, fossil not found, parse fail) caught and returned as MCP tool error responses with
{"error": "...", "command": "...", "stderr": "..."}. Server never crashes on bad calls. - Timeline/diff outputs trimmed: full SHAs kept (for follow-up calls) but no color, no excessive headers, human + machine friendly.
Tools (Actions)
fossil_status— Aggregate offossil status,fossil changes,fossil extras. Returns structured JSON:{ "checkout": {...}, "changes": [{"status":"EDITED","path":".."}], "extras": ["untracked.."] }fossil_commit—fossil commit -m "msg" [ --allow-empty ? ]. Requires non-empty message. Optionaladdremove: boolto auto-include new files. Returns result text. Dry-run supported.fossil_timeline— Recent history. Usesfossil json timeline checkin ...internally for accuracy, then renders to compact lines optimized for context (e.g.[<short-uuid>] <user> <tags> <comment>). Params:limit:int=20,tag:str|None,branch:str|None.fossil_diff— Unified diff viafossil diff --unified -N ...(or json where helpful). Params:files: list[str]|None(None = all uncommitted),context:int=3,revision:str|None(for historical).fossil_technote— Multi-action for durable memory:action: "list" | "read" | "create" | "append"- For read/create/append:
ref(datetime|id|tag),content,tags, etc. - Create uses
--technote now, append does export + commit update.
fossil_artifact_view— Raw content:fossil artifact <SHA>orfossil cat <file> -r <REV>. Returns exact bytes decoded as utf8 (or error). Critical for grounding LLM on exact file versions or manifests.
Resources (Data Sources)
fossil://repo/manifest— Current check-in's manifest artifact (viafossil artifact <current-uuid>). Useful for exact tree hash, parent, etc.fossil://repo/config— Key repo metrics: project name/code, checkout uuid, settings of interest (main-branch, etc.), parsed fromfossil info -v+ selective settings. Compact JSON.
Error & Observability
- Every tool/resource call that invokes fossil captures stdout/stderr/exitcode.
- Timeouts enforced.
- MCP protocol errors for client-visible failures; never let unhandled exception kill the stdio loop.
Testing
- Integration test: pure stdlib (no mcp client dep required for the test driver). Spawns
python -m fossil_mcp, writes JSON-RPC requests on stdin, asserts valid responses and thatfossil_statusreturns well-formed data containing current checkout. - Later: unit tests for parsers if complex.
Performance / Polish
- Subprocess calls are fast (fossil is instant on small repos).
- No persistent state in server (stateless per call; good for agents).
- Future: optional
--fossil-repoarg or FOSSIL_REPO env, but default to cwd (normal fossil behavior via .fslckout).
Installation & Usage (for LLM Clients)
Prerequisites
- Fossil SCM (version >= 2.20) must be installed and in your PATH.
- Check:
fossil version - Install instructions: see the "Quick Start for Other AI Agents" section above (package manager commands for Linux/macOS, official downloads for Windows, etc.).
- Check:
- Python >= 3.10 + pip
(The mcp Python package will be pulled in automatically when you pip install -e . inside a venv.)
Development Setup (recommended)
The easiest way for agents and humans is:
./bootstrap.sh
.venv/bin/python -m fossil_mcp
See the "Quick Start for Other AI Agents" section above for the full clone + bootstrap flow from the public Fossil remote.
Manual equivalent (if you prefer):
python3 -m venv .venv
.venv/bin/pip install -e .
.venv/bin/python -m fossil_mcp
The integration test also auto-detects the local .venv:
python tests/integration_test.py # or .venv/bin/python ...
This project keeps your system Python untouched and always talks to the real fossil binary in your PATH.
Claude Desktop / Cursor / MCP Host Config Example
{
"mcpServers": {
"fossil-scm": {
"command": "python",
"args": [
"/home/ben/Documents/refaqtor/fossil-scm-mcp/fossil_mcp/server.py"
],
"env": {}
}
}
}
Recommended (with uv for hermetic):
{
"mcpServers": {
"fossil-scm": {
"command": "uv",
"args": [
"--with", "mcp",
"run", "--python", "3.12",
"python", "-m", "fossil_mcp"
],
"cwd": "/path/to/your/fossil-workdir"
}
}
}
The server inherits the cwd / .fslckout, so open the desired Fossil checkout before launching the host, or set cwd in the MCP client config.
Direct CLI Test
python -m fossil_mcp --help # if implemented
# or just launch and send manual JSON-RPC (advanced)
Development Process Notes
This project was built entirely inside Fossil with strict phase commits + tech notes:
- Every milestone ends with
fossil add+fossil commitwith technical message. - Architectural decisions and intermediate state captured with
fossil technote add ...
See the timeline (fossil timeline) for the exact engineering log.
License
MIT (or public domain, matching Fossil spirit).
Status
Phase 3 complete (full tool + resource impl). All 6 tools and 2 resources execute real fossil commands safely. See Fossil timeline and fossil wiki list --technote for the live engineering log (including multiple tech notes created during verification of fossil_technote).
- Phase 1: baseline + README + ignore-glob (committed)
- Phase 2: pyproject + server shell + verified initialize (committed)
- Phase 3: full production logic in all handlers + error paths + technote CRUD (this commit)
- Phase 4: automated integration test (next)