Skip to content

The MCP server that tracks why your AI agent changed code

Six months from now, someone may look at a change your AI agent made today and ask: why is it like this? The diff is in git, while the constraint or rejected alternative may have stayed in a chat window. Selvedge is an open-source MCP server and CLI for preserving that stated context: an agent or person records an explanation, then retrieves it in a later session.

An agent session adds a column called user_tier_v2. The commit message says Update schema. git blame attributes it to claude-code. Six months later nobody knows why there’s a _v2, whether user_tier is safe to drop, or what the migration plan was — and the next agent session, asked to “clean up the users table,” has no way to find out. It will guess. Guessing is how AI-coded codebases rot.

Selvedge’s log_change tool records the reason the agent provides. Its instruction block tells the agent when to log; connecting the server alone does not capture every change. In this hypothetical example:

// tool call, made by the agent in the same context that produced the change
log_change({
"entity_path": "users.user_tier_v2",
"change_type": "add",
"reasoning": "Parallel column for the new billing tiers so we can backfill while user_tier keeps serving reads. Cut over once backfill passes checksum; then drop user_tier."
})

Later — next week or next year — the question answers itself:

$ selvedge blame users.user_tier_v2
users.user_tier_v2
Changed 2026-02-19 09:31:02
Type add
Entity column
Agent claude-code
Commit 4f21c0e
Reasoning:
Parallel column for the new billing tiers so we can backfill while user_tier keeps serving
reads. Cut over once backfill passes checksum; then drop user_tier.
Status active (last add on 2026-02-19)

The same answer is available to the agent over MCP as blame, and in bulk as history — so “what changed in users in the last 30 days, and why” is one call, not an archaeology dig.

Here, reasoning means the explanation explicitly supplied by the agent or person. Selvedge does not extract hidden model reasoning or verify that the explanation is correct.

Approach What you get What to check
Commit messages A committed explanation alongside the patch Whether the message records the constraint and alternatives you need
git blame Line attribution to commits and authors, including whole-file rename tracking Whether the linked commit contains an explanation; move and whitespace options can help trace changes
Attribution tools Attribution and, depending on the tool, linked prompts or session context What the integration captures, what can be queried later, and what is shared
Selvedge Supplied explanations and outcomes, queryable by entity Whether the decision was logged, its source and timing, and whether the explanation is supported

Decision history for AI-coded codebases: recorded reasons, and what was already tried and rejected. It’s 8 MCP tools that also work as a plain CLI: log_change, prior_attempts, blame, diff, history, changeset, search, stale_decisions. Data lives in a SQLite file under .selvedge/ next to your code. MIT licensed, with no LLM in the core or required hosted backend. An MCP client can send retrieved records to its model provider, and publishing the database shares its contents. Keep private records in a private destination.

Terminal window
pip install selvedge
selvedge setup # configure a supported client and install agent instructions

Full quickstart →

Capture is half the loop. The other half: before editing an entity, the agent can call Selvedge’s prior_attempts to inspect qualifying recorded attempts and outcomes. It still needs to assess whether the evidence applies to the proposed edit. The full history is also a decision audit trail you can search and export as Agent Trace records.

What MCP server tracks why an AI agent changed code?

Selvedge records the change and explanation supplied to log_change by an agent or person. Calling it during the work can preserve context before the session ends. Later, selvedge blame <entity> returns the most recent recorded change and its explanation.

Is the reasoning inferred from the diff by a second model?

Selvedge’s core does not use an LLM to infer an explanation from a diff. It stores the explanation supplied by its caller. That explanation may be recorded during the work, imported, or written later; preserve its source and timing, and review it against the available evidence.

How is this different from git blame or line-attribution tools?

git blame connects lines to commits and authors. Attribution tools may also retain prompts or session context; inspect what each tool records. Selvedge stores supplied explanations against entities such as users.email. To link history across a rename, explicitly record the new entity path with change_type="rename" and rename_from set to the previous path.

What happens to changes made before Selvedge was installed?

Selvedge cannot recover reasoning that was never preserved. selvedge import can read SQL DDL, Alembic migrations, and Agent Trace records. Imported records and later explanations should retain their source and timing; they are not evidence that a reason was recorded during the original change.

Which AI coding tools does it work with?

Selvedge setup supports Claude Code, Codex, Copilot, Cursor, Gemini CLI, and Windsurf. It installs MCP configuration and agent instructions. Native lifecycle adapters are available for all six setup targets, with different capabilities by client. Review the compatibility guide; other MCP clients can be configured manually.

Check current compatibility and capabilities.