invariant-mcp
Exports OASIS SARIF 2.1.0 reports for GitHub Code Scanning, enabling invariant check results to be consumed by GitHub code scanning and security workflows.
Provides a GitHub Actions workflow integration for running invariant-mcp and generating SARIF reports in CI.
Integrates with OpenAI Codex by providing MCP server configuration and synchronizing repository safety invariants into AGENTS.md; also exports SARIF for Codex Security and GitHub Code Scanning.
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.
invariant-mcp: Deterministic Pre-Flight Invariant Gates & Cryptographic Execution Receipts for Autonomous Coding Agents
invariant-mcp is a zero-trust verification layer and Model Context Protocol (MCP) server for autonomous software engineering agents (OpenAI Codex, Claude Code, Gemini, Cursor).
Autonomous coding agents frequently introduce syntactically valid, unit-test-passing patches that trigger catastrophic production failures—such as passing string literals to cache.delete_many() (silent character-by-character cache misses), swallowing database exceptions inside transaction.atomic() without nested savepoints, issuing synchronous CREATE INDEX locks on live PostgreSQL tables, blocking asyncio event loops, or hallucinating test-suite execution in multi-agent handoffs.
invariant-mcp closes this reliability gap with three deterministic primitives:
Pre-Flight AST & Unified-Diff Invariant Engine (
INV-001–INV-012): Sub-5ms static analysis over staged/unstaged git diffs with zero-false-positive handling of deleted lines (-) and full OASIS SARIF 2.1.0 export for GitHub Code Scanning & Codex Security.Tamper-Evident Cryptographic Execution Receipts: Runs test/build suites via
shlexvector execution (shell=False) and signs{command, cwd, exit_code, timestamp, stdout/stderr SHA-256}with HMAC-SHA256, preventing subagent verification spoofing.Cross-Agent Rule Compiler: Compiles canonical repository safety invariants simultaneously into
AGENTS.md(OpenAI Codex),CLAUDE.md(Claude Code),GEMINI.md, and.cursorrules.
Quickstart
# Install via uv or pip
uv tool install invariant-mcp
# or
pip install invariant-mcp
# 1. Check uncommitted git diffs against all 12 production invariants
invariant-gate check .
# 2. Export OASIS SARIF 2.1.0 report for GitHub Code Scanning / CI
invariant-gate sarif . --output results.sarif
# 3. Execute test suite and mint an HMAC-SHA256 verification receipt
invariant-gate verify "pytest -q"
# 4. Sync safety invariants across AGENTS.md, CLAUDE.md, GEMINI.md, and .cursorrules
invariant-gate sync .Related MCP server: ChangeWarden
MCP Server Configuration
OpenAI Codex (~/.codex/config.toml)
[mcp_servers.invariant]
command = "uvx"
args = ["invariant-mcp"]Claude Code (~/.claude.json / .mcp.json)
{
"mcpServers": {
"invariant": {
"command": "uvx",
"args": ["invariant-mcp"]
}
}
}Exposed MCP Tools
Tool | Description |
| Analyze a unified git diff or patch hunk before applying or committing changes. |
| Scan a repository's working tree and return structured JSON or OASIS SARIF 2.1.0. |
| Execute tests/builds ( |
| Cryptographically verify a subagent's |
| Deterministically check response formatting constraints (line counts, strict JSON, table count). |
| Inspect all 12 built-in production safety invariants and upstream documentation links. |
| Synchronize |
Built-In Production Safety Invariants
ID | Severity | Category | Failure Mode Prevented |
|
| Cache Correctness |
|
|
| Database Safety | Catching |
|
| Distributed Systems |
|
|
| Database Safety | Synchronous |
|
| Distributed Systems | Unrouted Celery `apply_async(eta=... |
|
| Agent Governance | Autonomous scripts invoking |
|
| Security |
|
|
| Concurrency | Python AST detection of |
|
| Security | Direct f-string interpolation inside |
|
| Reliability | Outbound synchronous |
|
| Security | Hardcoded API tokens ( |
|
| ML Systems | PyTorch |
Citation
See CITATION.cff and the accompanying technical report in paper/ for architectural benchmarks and formal evaluation across autonomous coding workflows.
License
MIT License — see LICENSE.
GitHub Actions Integration
- uses: astral-sh/setup-uv@v4
- run: uvx invariant-mcp --help
- run: uvx --from invariant-mcp invariant-gate sarif . --output results.sarifTool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
Pre-execution governance for AI agents. Deterministic PASS/FAIL/REVIEW verdicts, replayable proof.
Deterministic runtime safety for AI agents: scan PII, gate tool actions, verify LLM output.
AgentGuard — 20-tool AI safety MCP: policy preflight, risk scoring, audit logging, rate limits.
Agent routing, safety preflight, execution receipts, best execution and verified outcomes.
Related MCP Servers
- FlicenseAqualityBmaintenanceEnables coding agents to perform workspace-confined file operations, read-only Git inspection, and structured shell commands, while requiring out-of-band human approval for mutations and external executions and maintaining an audit trail.143-
- FlicenseNot gradedqualityCmaintenanceEnables AI coding agents to request bounded GitHub changes through a default-deny policy, independent human approval, one-time execution with a GitHub App credential, and verifiable receipts.1-
- AlicenseNot gradedqualityNot gradedmaintenanceEnables autonomous agents to run shell and subprocess commands through a guardrail that blocks destructive system mutations, path traversals, and reverse shells. It also adds prompt-injection detection, spend circuit breakers, loop detection, and privacy sanitization so agent execution stays within safe, budgeted bounds.MIT
- AlicenseAqualityBmaintenanceEnables coding agents to perform advisory runtime safety checks by inspecting proposed file paths and shell commands, tracking caller budgets, detecting repeated actions, and masking common credentials in output without executing commands or opening target files.4GPL 3.0