Skip to content
MCP server

protect-context

Guardrails for coding agents: contract, evidence ledger, loop brake and scope warnings

Runs locally

protect-context is a free MCP server for developer tools. It runs locally on your machine and is started by your AI client.

Pricing
Free
Platforms
CLI, Linux, macOS
Runs
Locally
Version
3.3.1
Listing updated

Similar MCP servers

Install

Add with the CLI

Run in a terminal

claude mcp add protect-context -- uvx protect-context

Add --scope user to use it in every project, or --scope project to share it in .mcp.json.

Or share it with your project

Add to .mcp.json

{
  "mcpServers": {
    "protect-context": {
      "command": "uvx",
      "args": [
        "protect-context"
      ]
    }
  }
}

Claude Code setup guide

Add to claude_desktop_config.json

{
  "mcpServers": {
    "protect-context": {
      "command": "uvx",
      "args": [
        "protect-context"
      ]
    }
  }
}

Settings → Developer → Edit Config, then quit and reopen Claude Desktop.

Claude Desktop setup guide

Install in CursorOpens Cursor, which asks you to confirm. Or add it by hand:

Add to ~/.cursor/mcp.json

{
  "mcpServers": {
    "protect-context": {
      "command": "uvx",
      "args": [
        "protect-context"
      ]
    }
  }
}

Use .cursor/mcp.json in a project to share it with the project.

Cursor setup guide

Install in VS CodeOpens VS Code, which asks you to confirm. Or add it by hand:

Add to ~/.copilot/mcp-config.json

{
  "mcpServers": {
    "protect-context": {
      "type": "stdio",
      "command": "uvx",
      "args": [
        "protect-context"
      ]
    }
  }
}

Or put the same entry in .mcp.json at your workspace root to share it.

VS Code setup guide

Add with the CLI

Run in a terminal

codex mcp add protect-context -- uvx protect-context

Or add to config.toml

Add to ~/.codex/config.toml

[mcp_servers.protect-context]
command = "uvx"
args = ["protect-context"]

Codex setup guide

Add to your client's MCP settings (most use this shape)

{
  "mcpServers": {
    "protect-context": {
      "command": "uvx",
      "args": [
        "protect-context"
      ]
    }
  }
}
  • Gemini CLI and Antigravity

    Gemini CLI

    Add to ~/.gemini/settings.json

    {
      "mcpServers": {
        "protect-context": {
          "command": "uvx",
          "args": [
            "protect-context"
          ]
        }
      }
    }

    Or run: gemini mcp add -s user protect-context uvx -- protect-context

    Antigravity

    Add to ~/.gemini/config/mcp_config.json

    {
      "mcpServers": {
        "protect-context": {
          "command": "uvx",
          "args": [
            "protect-context"
          ]
        }
      }
    }

    Use .agents/mcp_config.json to add it to one workspace only.

    Gemini CLI and Antigravity setup guide

  • Devin Desktop (formerly Windsurf)

    Add to ~/.config/devin/mcp_config.json

    {
      "mcpServers": {
        "protect-context": {
          "command": "uvx",
          "args": [
            "protect-context"
          ]
        }
      }
    }

    On Windows the file is %APPDATA%\devin\mcp_config.json. Use .devin/mcp_config.json to share it with a project.

    Devin Desktop setup guide

  • Cline

    Add to cline_mcp_settings.json

    {
      "mcpServers": {
        "protect-context": {
          "command": "uvx",
          "args": [
            "protect-context"
          ]
        }
      }
    }

    Open it from the MCP Servers icon → Configure → Configure MCP Servers.

    Cline setup guide

  • Zed

    Add to Zed settings.json

    {
      "context_servers": {
        "protect-context": {
          "command": "uvx",
          "args": [
            "protect-context"
          ]
        }
      }
    }

    Open it with zed: open settings file. Merge context_servers into the settings you already have.

    Zed setup guide

  • JetBrains AI Assistant and Junie

    AI Assistant

    Add to Settings → Tools → AI Assistant → Model Context Protocol (MCP) → Add

    {
      "mcpServers": {
        "protect-context": {
          "command": "uvx",
          "args": [
            "protect-context"
          ]
        }
      }
    }

    Junie

    Add to ~/.junie/mcp/mcp.json

    {
      "mcpServers": {
        "protect-context": {
          "command": "uvx",
          "args": [
            "protect-context"
          ]
        }
      }
    }

    Use .junie/mcp/mcp.json to share it with a project.

    JetBrains AI Assistant and Junie setup guide

  • Kiro

    Add to ~/.kiro/settings/mcp.json

    {
      "mcpServers": {
        "protect-context": {
          "command": "uvx",
          "args": [
            "protect-context"
          ]
        }
      }
    }

    Use .kiro/settings/mcp.json to add it to one workspace only.

    Kiro setup guide

Using several servers? Build one config file with the MCP config generator.

Configuration

  • PC_SESSION_IDSession name for evidence and loop views when several host sessions share one repo. Leave unset to use the default session.

About protect-context

Long agent sessions tend to lose earlier constraints, claim success without proof, rewrite unrelated files and retry the same failing command. This project treats those as state problems and keeps a project-local .agent-guard/ store that three interfaces share: a pi extension, an MCP server and a Python command line.

Its building blocks include a brief that restates the task and recent decisions before each turn, an evidence ledger that records every verification run with exit code and output digest, a loop brake that blocks repeated identical failures, a git-based scope audit that rates a diff as ok, warn or hard, and a durable journal of decisions, corrections and risks. Recall is keyword-based, without embeddings.

The README calls the suite advisory-first: it is not a sandbox and does not prove a change is correct. Loop blocking is a hard block in pi and the CLI but only reported through MCP. The server needs Python 3.10 or later and runs over stdio, for example with uvx protect-context mcp.

Tools this server provides (10)

Taken from the project documentation; the running server may differ.

From the tool list in its README, going by the names, 2 of 10 tools read data; 8 names don't say.

From the server's own tool labels and tool names; not verified by us.

guard_verify
Runs and records a verification command.
guard_note
Adds a journal entry.
guard_contract_checkName suggests: reads
Checks work against the contract.
guard_statusName suggests: reads
Shows current guard status.
guard_journal
Reads the durable journal.
guard_recall
Searches retained journal and evidence.
guard_evidence
Reads recorded evidence.
guard_diff_audit
Audits the diff scope.
guard_preflight
Reports tool presence and Git worktree state.
guard_budget
Reports context budget.

What it does

Evidence ledger
Records each verification run as an ID with exit code and output digest.
Loop brake
Fingerprints identical failing commands and blocks the Nth retry.
Diff scope audit
Rates changes ok, warn or hard from git diff stats.
Durable journal
Stores decisions, corrections, risks and notes with trust levels.
Local recall
Searches the journal by keyword, tag, type or evidence ID.
Context budget
Tracks usage watermarks and caps injected blocks.

Good for

  • Stop an agent claiming done without test output
  • Catch a quick fix that touches many files
  • Keep decisions across a long session
  • Audit what an agent verified in CI

Pricing

Free

Published on PyPI and npm; no paid plan mentioned

protect-context FAQ

Does protect-context sandbox the agent?

No. The README says it is advisory and not a sandbox.

Which interfaces exist?

A pi extension, an MCP server and a Python CLI sharing one store.

Does recall use embeddings?

No, it searches by keyword, tag, type, evidence ID and command.

What Python version is needed?

Python 3.10 or later for the CLI and MCP server.

Is protect-context free?

Yes. protect-context is free to use.

How do I add protect-context to Claude Code?

Run this command in your terminal: claude mcp add protect-context -- uvx protect-context

What are the best alternatives to protect-context?

The closest alternatives to protect-context are REA, Context7, Chrome DevTools MCP, Codebase Memory and GitHub.

Where this comes from

  • Description: written from the project's README.
  • Install steps: from the official MCP Registry entry.

How AIPoweredBot checks servers