MipCode
Provides a git pre-commit hook to intercept commits and enforce L1 contract and blast-radius hydration before file changes are committed.
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.

MipCode
MipCode (mip-delta) checks Python changes and resting repositories for seam and contract inconsistencies: a caller that omits a newly required argument, a delegating wrapper that accepts an option and fails to forward it, an unused self.<param> configuration store, or an override whose signature drifts from its base. It also includes zero-dependency structural and fork-vs-upstream checks for Solidity (--audit-solidity, --fork-diff) and Solana/Anchor #[derive(Accounts)] constraint symmetry (--audit-anchor).
Run it before a commit, on a pull request, after a merge, or cold against HEAD. It reads source only and needs no configuration. Most changes produce no output. Treat what it prints as a prompt for review, because Stage-1 static reports can still include benign sites.
What it finds
In httpx (#1624, later fixed in #3023), adding Client(http1=False) forwarded http1=http1 everywhere except AsyncClient._init_proxy_transport:
def _init_proxy_transport(
self,
proxy: Proxy,
verify: VerifyTypes = True,
cert: CertTypes = None,
+ http1: bool = True,
http2: bool = False,
limits: Limits = DEFAULT_LIMITS,
trust_env: bool = True,
) -> AsyncBaseTransport:
return AsyncHTTPTransport(
verify=verify,
cert=cert,
http2=http2,
limits=limits,
trust_env=trust_env,
proxy=proxy,
)Accepting an unused optional parameter with a default is valid Python typing, so a type checker flags zero errors on those changed lines. Run on that commit, mip-delta prints one line:
[mip-delta] httpx/_client.py:1402 parameter_sink_review[static] AsyncClient._init_proxy_transport (new parameter http1 is not read in the function body; verify its intended behavioral sink)Across held-out replays of mature repos, this same class of checks independently flagged omissions and unawaited async calls at the same sites fixed or reported separately upstream in httpx (#3023), scrapy (#7730), and rich (Traceback.__init__ wrapper drops related to Textualize/rich#3301), alongside a missing-guard site in paramiko (AgentKey.sign_ssh_data, disable_algorithms).
We replayed the check over recent history in ten open-source repositories that it had not been run on. Each plan, with its thresholds, was committed before its run.
It is quiet. The ten repositories had 1,045 commits that changed a function's contract. 93.1% of them produced no report in the first five repositories and 97.4% in the second five, which ran a narrower set of checks.
It finds omissions that passed review. In 10 of those commits, the checks that both rounds ran reported a place the author had missed. Upstream later fixed the omission in six of them. The other four belong to two gaps in rich with no later fix that we found.
Those omissions are type-correct code. A new optional parameter that one layer accepts and does not forward passes a type checker.
Most raw Stage-1 reports are not omissions. Across the 68 sites adjudicated by two blind readers in the held-out rounds, 15 of 68 sites (22.1%: 10 real omissions, 5 review-worthy) were useful and 53 (77.9%) were false reports; in the post-fix baseline regression, 18 of 37 flagged commits (48.6%) contained a real omission or review-worthy site.
A type checker covers stale calls as well or better. For calls that no longer match a changed or removed function, mypy reported as much as the check or more.
The causes of three kinds of false report were fixed after those runs. A regression check on the same repositories shows the baseline default set (f4361fd) silent on 96.5% of the contract-changing commits, with a real omission or a site worth review in 18 of the 37 commits it flags. Those figures are fitted to these repositories and are not a new validation.
Two-Stage Precision Sieve (Optional LLM Micro-Triage)
Why not simply ask a fast LLM (claude-haiku-5-5) to inspect every git diff instead of running AST checks first? In Experiment 1, we benchmarked unguided Haiku diff review against AST-gated two-stage triage across all 37 flagged commits plus 30 silent contract-changing controls (N = 67 blinded commits, no workspace tools) from the f4361fd replay:
Arm | Flagged Kept ( | Useful Prec | Strict Prec | Real Recall ( | Silent FP ( | LLM Calls | Nominal Cost |
Arm A: |
| 48.6% | 35.1% | 13/13 (100.0%) | 0/30 (0.0%) | 0 |
|
Arm B: Two-stage ( |
| 92.3% | 76.9% | 10/13 (76.9%) | 0/30 (0.0%) | 37 |
|
Arm C: Unguided Haiku on diff ( |
| 35.0% | 27.5% | 11/13 (84.6%) | 14/30 (46.7%) | 67 |
|
Arm C (strict): Unguided Haiku ( |
| 77.8% | 66.7% | 6/13 (46.2%) | 0/30 (0.0%) | 67 |
|
Two stages beat diff-only LLM review on precision and noise: Unguided Haiku either floods clean commits with
46.7%false warnings (35.0%precision) or, when restricted to high-confidence alerts, misses over half of real omissions (46.2%strict recall — includinghttpx#3023). With Stage 1 suppressing96.5%of commits at$0, Haiku triage on the remaining3.5%cuts false alarms by94.7%(18/19) for ~$0.0024per flagged commit (9/13real recall and100.0%useful precision onconfirm_omissionalone).Available as
--review:mip-delta --check-git --reviewruns Stage-2 triage only when Stage 1 emits findings, usingANTHROPIC_API_KEY(stdliburllib) or an authenticatedclaudeCLI with zero extra dependencies.Post-Experiment-1 Stage-1 & rubric refinements: Demoting
state_field_reviewto opt-in lifted deterministic precision (48.6% -> 50.0%,37 -> 36flagged commits,0recall loss), adding deadself.<param>attribute-store detection inparameter_sink_reviewadded0false alarms across the 8,000-commit replay while directly flaggingrich:c856e6b46901(locals_hide_dunder,locals_hide_sunder) andurllib3:52392654b301(version_string), broadening the--reviewasync rubric (eager-to-deferredexecution) recoveredscrapy:9bfa58e36cca(confirm_omission) while keepinghttpx:e0b4528b170bsuppressed, and excluding vendored subtrees (vendor/,_vendor/,third_party/,<pkg>/packages/) plus Invoke@taskcontext args eliminated24/24targeted persistent FPs (70 -> 46merge-head open sites,0TPs lost) across the Experiment 2 PR set.
Runtime Observation & Ledger Audit (Experiment 2)
To make sure every subsystem in src/mipdelta/ earned its keep against real test suites and multi-commit PRs at $0 API cost, Experiment 2 audited both optional subsystems across four Python repositories (marshmallow, rich, httpx, mipcode) and 20 multi-commit upstream PRs (74 commits across 8 repositories):
Opt-in PEP 669 runtime observation (
--run-pytest,max_events_per_site=1default): Defaultmip-delta --check-gitstays zero-dependency static AST (~5 ms). As an explicit opt-in dynamic supplement, fixing 5 runtime/MRO lookup defects exposed by the audit turned--run-pytestinto0tool-ID/Mock crashes (pytest-covandpytest-xdistclean),+5.26%cold /+14.17%median warmpytestoverhead, and27/30 (90.0%)mutation recall (14/15 = 93.3%on optional delegating wrappers where installedmypyis0.0%;+56.7%net recall lift over static AST +mypy).Session & multi-push deduplication (
--ledger,ObligationLedger): Single-shot CI PR checks get identical results from stateless--base-ref, because WIP commits only naturally resolved9.1%–13.2%of opened sites before merge. We keepledger.pyscoped strictly to agent-hook / multi-push deduplication, where it cut repeat push alerts by52.7%–66.2%with0anchor churn across19line shifts.
Cold Repo Bug-Hunter (Snapshot Audit at Rest, --audit-repo)
You don't need a git diff to try mip-delta on a codebase. mip-delta --audit-repo scans a resting HEAD snapshot for standing wrapper option drops (delegating_wrapper_review), dead self.<param> configuration attributes never read anywhere in the workspace (parameter_sink_review), and hard subclass parameter-kind mismatches (override_signature_review).
In a 24-repository cold sweep (protocol) across popular Python libraries (5,708 production files, 77,052 candidate calls, median scan 1.36 s):
22 of 24 repositories (
91.7%) emitted zero alerts, showing strict quietness on mature codebases even with no diff boundary.9 of 10 Stage-1 findings (
90.0%) were real standing bugs:Textualize/rich(rich/traceback.py:309Traceback.__init__dropping 5locals_*options,rich/traceback.py:487recursiveTraceback.extractdroppinglocals_max_depth/locals_max_stringonExceptionGroups, and 2 deadself.locals_hide_{dunder,sunder}stores). In the initial sweep (20/24silent), it also caught MipCode's ownContainedGatewaySession.__init__storing an unreadself.max_visible_bytesquota (src/mipdelta/gateway.py), which has since been enforced (0self-findings).--reviewreached100%kept precision for$0.009854total: Stage-2 Haiku triage (reading injected[callee contract]signatures) suppressed the remaining benignLazyFilestdin"-"finding inclick($0.001102) while keepingrich(confirm_omission,$0.008752).Recent cold-audit catch & precision polish: Subsequent cold sweeps caught
WeaviateHandshake.__init__storing unreadbatch_dynamic=Truewhilewrite()always calledfixed_size()(reported infeyninc/chonkie#691), and precision filters now suppressraise NotImplementedError-only override stubs, explicit deprecation-sentinel defaults, and leaf callees that never read an interface-compatibility parameter while preserving multi-hop wrapper drops (such asTextualize/trogon'sfocus(scroll_visible)chain).
mip-delta --audit-repo --root . --json
mip-delta --audit-repo --root . --reviewSolidity & Web3 Contract-Delta Preview (--audit-solidity)
mip-delta also includes a zero-dependency Solidity structural contract analyzer (mipdelta.solidity) targeting cross-contract and patch-delta defects where solc compiles cleanly: try_catch_sink_review (non-reverting catch leaving pre-allocated memory array slots zero-initialized before hash/emit sinks), state_sink_review (dead private/internal constants or state variables), parameter_sink_review, delegating_wrapper_review (with branch-forwarding awareness), override_modifier_review, and sibling_guard_asymmetry (missing state guards or state-sync steps across sibling mutators sharing state or storage structs, including cross-library storage-struct pooling).
In addition (research preview, zero external Solidity/Rust toolchains required), mip-delta supports:
--fork-diff(mipdelta.solidity_fork): Deterministic fork-vs-upstream invariant regression diffing (--fork-diff --upstream <upstream> --root <fork>).--audit-anchor(mipdelta.anchor): Solana/Anchor#[derive(Accounts)]sibling constraint asymmetry auditing (has_one,seeds,Signer, mutability, and guard flags across sibling instructions sharing an account struct).
See the usage guide and v0.6 release notes for command details and scope notes.
In our offline Web3 & Solidity evaluation (curated harness, 12-target contest corpus, frozen v0.6.4 holdout):
WormholeGatewayAdapter._wormholeChainId(oz-community-contracts@0361935dc5ed): Flagged independently (state_sink_review,L28) and corroborated by an independent upstream cleanup removing_wormholeChainId(openzeppelin-community-contracts#276); the remainingrefundChainduplicatetargetChainat_sendMessage(L333) was reported by us in#321.ERC7786OpenBridge.sendMessage(oz-community-contracts@0361935dc5ed): Flagged failedtryiterations leavingoutbox[i]zero-initialized(address(0), bytes32(0))beforesendIdhashing /OutboxDetailsemission (try_catch_sink_review,L124–L144), which we reported inopenzeppelin-community-contracts#277 (comment)alongside@ernestognw's nonce PR (#277).Blinded DeFi patch delta (
vault_4626→vault_4626_patched): Caught both deadprivate constantinflation-defense constants (_VIRTUAL_SHARES,_VIRTUAL_ASSETS) in7.8 ms, with0false positives acrosssynthetic_lendingand benign escrow/staking controls.12-target contest & bug-bounty corpus (
1,622production.solfiles,1,821contracts,11,393functions in5.27 s):7/12targets (twyne-v1,veda-boring-vault,lombard-evm, and all 4Aquacomponents) emitted0findings; across all1,622files, only8total findings fired (ERC7786OpenBridge.sendMessage,WormholeGatewayAdapter._wormholeChainId,CompoundingValidatorStorage.VAULT_ADDRESS,TermMaxOrderV2.gt,OrderManagerV2.ORDER_MANAGER_SINGLETON,IntegrationsLens.decimalsInternal/MidasStrategy.withdrawInnerreported by us inStrata-Markets/contracts#20, andPrecompileHelper._TESTNET_HYPE_TOKEN_INDEX).Untouched zero-shot Solidity holdout (
v0.6.4frozen, 8 out-of-sample repos,448.solfiles in1.25 s):7/8(87.5%) repositories (v4-core,permit2,morpho-blue,metamorpho,solmate,limit-order-protocol,sablier-v2-core) emitted0findings; the only2alerts were deprecated proxy storage slots inOpenZeppelin/openzeppelin-contracts(EIP712._nameFallback/_versionFallback, annotated upstream withslither-disable-next-line constable-states).
mip-delta --audit-solidity --root contracts/ --fail-on-findings
mip-delta --before Vault_v1.sol --after Vault_v2.sol --json
mip-delta --fork-diff --upstream upstream_contracts/ --root fork_contracts/ --json
mip-delta --audit-anchor --root programs/ --jsonRelated MCP server: tesseract-context
Quick start
From your project’s Git checkout, activate a fresh virtual environment with Python 3.10 or later.
python -m pip install coherion-mipcode
mip-delta --help
mip-delta --check-git --root . --jsonThe Git check compares the working tree with HEAD by default. A clean checkout returns an empty findings list. Omit --json for compact text.
From the MipCode source checkout, try the bundled example that adds a required keyword. The command checks the proposed edit in memory.
mip-delta --root examples/contract-delta/before --write-path formatter.py --candidate-file examples/contract-delta/after/formatter.pyThe report points to consumer.py:5 and names required_keyword_missing.
Where to run it
Before a commit. Add the pre-commit hook to
.pre-commit-config.yaml(rev: v0.6.6orrev: main,id: mip-delta) to stop the commit while reported sites are open. A site you judge intentional can be--waived (see usage guide).On a pull request. Use the MipCode PR Caller Check on GitHub Marketplace to annotate affected Python callers. The workflow example pins the tested Action and shows how to make findings block a job.
After a merge. Run
mip-delta --check-merge(auto-resolvingMERGE_HEAD,HEAD^1/HEAD^2, or--base-ref) to catch two branches that merged without textual conflicts yet broke a shared contract (see usage guide).
A reported site stays open until a later edit resolves it. Stateless --base-ref covers single-shot CI PR gates; when running repeated local checks or agent hooks, --ledger deduplicates open sites (0 churn across line edits), --open lists what remains, and --waive records an intentional one. The usage guide covers these, opt-in checks, and observing dynamic calls during tests (--run-pytest).
With coding agents
(Looking for v0.5? MipCode started as an experimental MCP architectural-mipmap server in src/mipcode/ and src/semantic_lod/; benchmarks showed custom navigation tools lost to ripgrep, so v0.6+ pivoted to mip-delta—see docs/release-notes-v0.6.md for v0.5 pointers.)
MipCode began as a check for coding agents. In our early transcripts, agents failed multi-file tasks because they stopped early: the edited file looked finished, the existing tests passed, and the agent never looked for the caller it had just broken. In paired Codex runs on 14 selected tasks, agents that received the report passed 14 and agents without it passed 8. Most of those tasks were constructed, and a generic reminder to look again later recovered five of six selected misses.
The newer evidence is weaker for this use. In a small pilot, a current frontier model was given three tasks built from omissions that human authors had made. It covered the missed place in six of six sessions with no help, so the pilot stopped before comparing the check with a reminder.
The check can still run as Claude Code hooks, which add new sites after an edit and list open ones before the agent finishes. Treat the hooks as experimental.
For coding and security agents integrating mip-delta directly, see SKILL.md and the public machine-readable discovery endpoints (llms.txt, skill.md, and findings.json).
Research and development
Cold repo bug-hunter runs diff-free
mip-delta --audit-repoacross 24 restingHEADsnapshots (5,708files,22/24silent,9/10Stage-1 real standing bugs inrich,100%Stage-2 kept precision for$0.009854total API cost).Solidity & Web3 offline benchmark tests zero-dependency
mip-delta --audit-solidityand--before/--afterdeltas on cross-chain bridges (openzeppelin-community-contracts#276corroborated;#321,#277 (comment), andStrata-Markets/contracts#20reported by us), ERC-4626/lending patches, a 12-target contest/bounty corpus (1,622.solfiles in5.27 s,8findings), and an untouchedv0.6.48-repo holdout (448.solfiles in1.25 s,7/8silent).Two-stage precision sieve compares AST-only
mip-delta, AST-gated--reviewHaiku triage, and unguided Haiku diff review across 67 blinded commits from the ten-repository replay.Experiment 2 audit stress-tests opt-in
--run-pytestPEP 669 dynamic call observation across four real test suites (90.0%mutation recall,+14.17%median warm overhead) and auditsObligationLedgeracross 20 multi-commit upstream PRs (0anchor churn across line shifts, scoped strictly to hook/session deduplication).Held-out validation, round one and round two report the ten-repository replays, the reading of reported sites, recall on constructed omissions, and the mypy comparison. The regression check reruns them after the detector fixes.
Live pilot reports the six agent sessions and why the pilot stopped.
History replay runs the check over 2,944 upstream commits in the five repositories the checks were tuned on.
Engineering article explains the move from search tools to checks after edits and tests.
Evidence index links the earlier paired-task reports, data, and study limits.
One-shot brief pilot compares no brief, a lexical map, and a Semantic LOD brief.
Documentation index covers the preview and the earlier architecture.
python -m pip install -e ".[test]"
python -m pytest tests -qTool 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
Code-map tools for AI agents: see a repo's structure first, then edit only what matters.
Live GitHub repo AST X-Ray, 42 coding-agent DoD gates, Git worktree guards & brownfield baselines.
Enforces architectural invariants and code quality rules inside your AI agent's edit loop.
Governance and control for agentic software development. Trust AI written code.
Related MCP Servers
- AlicenseNot gradedqualityAmaintenanceEnables AI coding agents to access evidence-backed repository memory, code graph, project DNA, and deterministic change validation so they understand design decisions, past bugs, and invariants while working.2,071 npm18Functional Source , Version 1.1, ALv2 Future
- AlicenseNot gradedqualityCmaintenanceEnables AI coding agents to perform zero-token static audits, simulate refactorings in an ephemeral RAM clone, trace downstream ripple effects, and block unsafe writes with automatic rollback to prevent regressions.30 npmBusiness Source 1.1
- AlicenseBqualityBmaintenanceEnables AI coding agents to compile repositories into high-signal, cache-pinned context and to query dependency centrality, blast radius, AST skeletons, circular dependencies, hotspots, and auto-generated agent rules through MCP tools.71MIT
- FlicenseNot gradedqualityBmaintenanceEnables AI coding agents to ground reasoning in indexed code graphs, manage governed three-tier memory, compose ten engineering roles, enforce deterministic workflow gates, and generate evidence-based QA reports.61 npm1-