MartinLoop — Stop Runaway Loops, Bad Code & Token Waste
This server is an MCP-based governed execution and inspection layer for AI coding agents. It enforces budgets, verification gates, and audit receipts to prevent runaway loops and unsafe changes.
Core execution
martin_runexecutes coding tasks with hard USD, token, and iteration limits plus path scopes; it requires prior doctor, estimate, plan, and preflight receipts.martin_plancreates scoped implementation plans, verifier proposals, policy packs, and risk recommendations.martin_preflightvalidates a planned run before any execution or spend.martin_doctorruns read-only environment and run-store diagnostics.martin_estimatepredicts cost, route, and pre-work burn without running the agent.
Inspection, monitoring, and audit
martin_inspect,martin_get_run,martin_get_attempt,martin_get_verification_results, andmartin_run_dossier/martin_dossierload summaries, run details, attempts, verification evidence, artifacts, events, and full dossiers.martin_status,martin_list_runs,martin_triage_runs, andmartin_logsshow current budget/cost state, filter runs, prioritize runs needing attention, and stream recent events.
Run control
martin_pause,martin_cancel, andmartin_continuerecord durable human control requests with audit trails.
Evaluation and PR workflow
martin_evalgrades runs on task completion, verifier health, diff discipline, risk, and reviewability.martin_pr_summary,martin_review_pr, andmartin_create_prgenerate PR titles/summaries, review PRs against dossiers, and create or preview GitHub PRs with integrated MartinLoop dossier content.
MartinLoop
Your coding agent says it's done. MartinLoop makes it prove it.
One system to control, verify and understand coding-agent work.
MartinLoop gives AI coding agents budgets, stop conditions, rollback rules, and receipts.
Built from thousands of agent runs where the problem was not intelligence -- it was uncontrolled execution.
Get started: npx -y martin-loop@latest start
Try the demo: npx -y martin-loop@latest demo
MartinLoop is part of the NVIDIA Inception program.
Start Here
Install — run npx -y martin-loop@0.5.0 start, or install it globally with npm install -g martin-loop@0.5.0.
Governed run — define an objective, verifier, budget, and iteration cap with martin run.
Verifier — completion requires fresh verifier evidence bound to the active run and workspace. A configured verifier proves only the checks it runs; VERIFIED is not a claim that the code is bug-free or automatically safe to merge.
Budget — set a hard spend ceiling with --budget-usd and an attempt ceiling with --max-iterations.
Receipts — inspect the latest result with martin dossier --latest and validate stored integrity with martin runs verify --latest.
MCP — install @martinloop/mcp@0.5.0 in a supported host or generate host configuration with martin mcp print-config.
Documentation — continue with the quickstart, CLI reference, or MCP setup.
When --model is provided, MartinLoop passes it through unchanged. Without --model, the authenticated host runtime chooses its own default. MartinLoop does not inject a hidden fallback model.
Related MCP server: Playwright MCP
Why MartinLoop
AI coding agents are useful, but unbounded retry loops are expensive.
A task that looked like a small fix can become dozens of attempts, a blown token budget, and a diff nobody trusts. MartinLoop gives every run an explicit contract: objective, verifier, budget, scope, receipts, and a clear stop condition.
Use it when AI coding work needs to stay bounded, inspectable, and safe to review before it becomes expensive or destructive.
Why Teams Adopt MartinLoop
It turns agent behavior into inspectable run receipts you can actually review.
It enforces hard stop conditions before runaway retries spend more money.
It adds rollback-aware rules so failed attempts do not silently leave unsafe changes behind.
It helps teams compare outcomes across agents under one governed flow.
Teams use MartinLoop when they need governed agent execution that can be reviewed and trusted.
2-Minute Install Path
npx -y martin-loop@latest start
npx -y martin-loop@latest demo
cd martin-loop-demo
npm install
npx -y martin-loop@latest run "Summarize the demo workspace and prove tests still pass" --verify "npm test" --budget-usd 2 --max-iterations 1Quick Start
Try MartinLoop in a disposable demo workspace:
npx -y martin-loop@latest start
npx -y martin-loop@latest demo
npx -y martin-loop@latest --version
cd martin-loop-demo
npm install
npx -y martin-loop@latest run "Summarize the demo workspace and prove tests still pass" --verify "npm test" --budget-usd 2 --max-iterations 1
npx -y martin-loop@latest dossier --latest
npx -y martin-loop@latest share --latestOptional global install:
npm install -g martin-loop
martin-loop --versionIf this flow is useful, open an issue with feedback so we can keep improving the public experience.
start prints the first-run guided path. run auto-checks doctor, session-start, and preflight, then executes when the environment is ready. Use --proof only when you intentionally want an explicit no-spend lane.
Inspect-first flow:
npx -y martin-loop@latest doctor
npx -y martin-loop@latest session-start
npx -y martin-loop@latest preflight "Summarize the demo workspace and prove tests still pass" --verify "npm test"share --latest writes three files into the selected run directory under share/: run-receipt.json, run-receipt.md, and proof-card.svg.
Release notes for the current root package: MartinLoop 0.5.0.
Visual Proof
MartinLoop turns an AI coding run into an inspectable execution record: budget used, verifier result, changed files, rollback evidence, and final receipt.
Ungoverned agents can retry until cost and scope drift. MartinLoop adds budget caps, verifier gates, and audit evidence so the run has a clear stop condition.
Proof Receipts
Proof receipts are local share bundles for governed AI coding runs. They show the task, spend, budget, verifier result, receipt integrity, and any evidence boundary that should not be rounded into confidence.
This real governed run spent $0.51 against a $3.00 budget. The verifier passed and the receipt integrity was signed, but the proof stayed at EVIDENCE_BOUNDARY because rollback evidence was not recorded.
Generate your own receipt after a governed run:
npx -y martin-loop@latest run "Summarize the demo workspace and prove tests still pass" --proof --verify "npm test"
npx -y martin-loop@latest runs verify --latest
npx -y martin-loop@latest share --latestExample receipt files: Markdown and JSON.
Run This Audit Yourself
Use this lane from a clean temp directory to verify the public CLI flow exactly as shipped:
npx -y martin-loop@0.5.0 --version
npx -y martin-loop@0.5.0 start
npx -y martin-loop@0.5.0 demo
cd martin-loop-demo
npm install
npx -y martin-loop@0.5.0 run "Summarize the demo workspace and prove tests still pass" --verify "npm test" --budget-usd 2 --max-iterations 1 --json
npx -y martin-loop@0.5.0 dossier --latest --json
npx -y martin-loop@0.5.0 share --latest --jsonFor deterministic installs, pin the package line (martin-loop@0.5.0) or use martin-loop@latest. Plain npx martin-loop can resolve a stale local cache on some machines.
Expected share bundle outputs:
share/run-receipt.jsonshare/run-receipt.mdshare/proof-card.svg
See It In Action
The point is not that every governed run is always cheaper. The point is that every run becomes inspectable and enforceable: budget policy, verifier result, stop reason, and evidence are explicit.
For a deterministic public repro lane, use the benchmark workspace and compare governed execution to unbounded retry behavior:
npx martin-loop bench --suite under-3-challengenpx martin-loop bench --suite ralphy-engineering-50
Ralph-Style Loops
A Ralph-style loop is the failure mode where an AI coding agent keeps trying without knowing when continuing is unsafe, uneconomical, or unlikely to succeed.
MartinLoop keeps the useful part of the loop, then adds brakes:
stop before budget overspend
classify unsafe or invalid actions before execution
write an audit record for every attempt
preserve rollback and verifier evidence for review
reduce runaway context growth with compact run summaries
Failure Taxonomy (13 Runtime Classes)
Public governed runs use one canonical taxonomy: the 13 runtime FailureClass values from @martin/contracts.
See the canonical table: Failure Taxonomy (13 Runtime Classes).
What It Does
Budget caps stop the next attempt before a configured USD, token, or iteration limit is exceeded.
Verifier gates require a real check, such as
npm test, before a run can count as complete.Policy checks block unsafe verifier commands, risky path changes, and secret-like task inputs before execution.
Failure classification uses canonical runtime classes for triage and reporting. See Failure Taxonomy (13 Runtime Classes).
Run receipts capture stop reason, verifier evidence, budget posture, integrity state, and the next safe action.
martin share --latestturns the latest governed run into a local share bundle with a redacted JSON receipt, Markdown recap, and proof-card SVG.MCP integration gives hosts one write-capable execution entrypoint plus richer planning, inspection, and review helpers.
How It Works
Layer | Purpose |
Task contract | Objective, verifier plan, repo root, allowed paths, denied paths, acceptance criteria, workspace, project, and budget. |
Policy and budget | Defaults come from |
Agent adapters | Claude CLI, Codex CLI, Gemini CLI, and direct-provider adapters normalize execution results. |
Safety and verification | Scope checks, verifier command checks, prompt integrity, and grounding decide whether work can continue. |
Persistence | JSONL run records, evidence summaries, and repo-backed artifacts make every run inspectable later. Each loop record is locally signed (HMAC, per-runs-root key) and |
Trust Boundaries
Cost and token outputs always include provenance (
actual,estimated, orunavailable).For Codex specifically, MartinLoop reports authoritative usage only when the host exposes it; otherwise MartinLoop labels usage as estimated and avoids presenting it as settled accounting.
Receipt integrity must be
verifiedbefore a run is treated as trustworthy evidence for external review.
CLI
martin-loop doctor
martin-loop demo
martin-loop session-start [--host <claude|codex|gemini|generic>]
martin-loop phase status|contract|session-start|preflight|run [--execute]
martin-loop preflight <objective> [options]
martin-loop run <objective> [options]
martin-loop bench --suite <suiteId>
martin-loop triage
martin-loop dossier (--latest | --loop-id <id> | --file <path>)
martin-loop runs list|get|attempt|verify ...
martin-loop mcp print-config --host <codex|claude|gemini|generic>
martin-loop mcp install --host <codex|claude|gemini|generic>
martin-loop challenge [--loop-id <id> | --file <path> | --latest]
martin-loop share (--loop-id <id> | --file <path> | --latest) [--out-dir <path>]
martin-loop badge [--format svg|json] [--runs-dir <path>]Common options:
--budget <n> Hard cost cap in USD
--budget-usd <n> Alias for --budget
--soft-limit-usd <n> Soft budget threshold in USD
--verify <cmd> Verifier command after each attempt
--proof Explicitly opt into a no-spend proof adapter lane
--max-iterations <n> Maximum number of attempts
--max-tokens <n> Maximum token budget
--engine <name> Adapter to use: claude, codex, gemini, or openai
--cwd <path> Repo root for the run
--allow-path <glob> Restrict writes to this path pattern; repeatable
--deny-path <glob> Block this path pattern; repeatable
--runs-dir <path> Override the local Martin runs rootExamples below use npx martin-loop so they work without a global install. If you install martin-loop globally, the martin alias works too.
Use martin-loop share --latest after dossier when you want a redacted bundle you can hand to another person without sending raw run-store files.
More detail: CLI reference and configuration reference.
Benchmarks
MartinLoop ships a public deterministic benchmark workspace in benchmarks/ plus the installed-package bench command.
From an installed package:
npx martin-loop bench --suite under-3-challenge
npx martin-loop bench --suite ralphy-engineering-50From a clean public clone:
pnpm install --frozen-lockfile
pnpm bench:build
pnpm bench:eval
pnpm bench:report:ralphyEquivalent workspace-filter commands:
pnpm --filter @martin/benchmarks build
pnpm --filter @martin/benchmarks test
pnpm --filter @martin/benchmarks eval
pnpm --filter @martin/benchmarks report:ralphyThe installed-package command reads the shipped public fixtures. The repo-clone workflow runs the public benchmark workspace directly.
MCP
Run the standalone MCP package directly:
npx -y @martinloop/mcpAdd it to common hosts:
codex mcp add martin-loop -- npx -y @martinloop/mcp
claude mcp add --transport stdio --scope user martin-loop -- npx -y @martinloop/mcp
claude mcp add --transport stdio --scope user martin-loop -- cmd /c npx -y @martinloop/mcpGenerate host config from the root CLI:
npx martin-loop mcp print-config --host codex --transport stdio --profile minimal
npx martin-loop mcp print-config --host claude --transport stdio --profile diagnostic
npx martin-loop mcp print-config --host gemini --transport stdio --profile full-local
npx martin-loop mcp print-config --host generic --transport stdio --profile github-reviewThe root martin-loop package and the standalone @martinloop/mcp package are both advancing to 0.5.0 in this release. Their version lines may move independently in future releases.
The public MCP release train labels are:
0.1.4operator foundation0.2.0cockpit expansion0.2.5public MCP package line0.2.7usability and review release0.3.0host adoption and onboarding release0.3.1review and handoff release
The standalone MCP registry/server identifier is io.github.Keesan12/martin-loop.
More detail: MCP setup, MCP tool reference, and MCP compatibility.
SDK
npm install martin-loopimport { MartinLoop, createClaudeCliAdapter } from "martin-loop";
const loop = new MartinLoop({
adapter: createClaudeCliAdapter({ workingDirectory: process.cwd() }),
defaults: {
workspaceId: "my-workspace",
projectId: "my-project",
budget: {
maxUsd: 3,
softLimitUsd: 2.25,
maxIterations: 3,
maxTokens: 20_000,
},
},
});
const result = await loop.run({
task: {
title: "Fix auth regression",
objective: "Fix the failing auth regression tests",
verificationPlan: ["pnpm test"],
repoRoot: process.cwd(),
},
});
console.log(result.decision.status);The root SDK also exports createCodexCliAdapter, createGeminiCliAdapter, createDirectProviderAdapter, and createOpenAiCompatibleAdapter.
More detail: SDK reference and package map.
Examples
Development
Requirements:
Node.js 20+
pnpm 10.x
git clone https://github.com/Keesan12/martin-loop.git
cd martin-loop
pnpm install --frozen-lockfile
pnpm lint
pnpm test
pnpm build
pnpm public:copy-scan
pnpm public:git-surface
pnpm oss:validate
pnpm public:smoke
pnpm release:matrix:localStandalone MCP validation:
pnpm --filter @martinloop/mcp lint
pnpm --filter @martinloop/mcp test
pnpm --filter @martinloop/mcp build
pnpm --filter @martinloop/mcp smoke:pack
pnpm --filter @martinloop/mcp smoke:published:pack
pnpm --filter @martinloop/mcp verify:releaseContributing
Issues, bug reports, workflow feedback, and focused pull requests are welcome. Public-facing docs should stay concise, user-centered, and accurate.
git checkout -b feat/your-feature
pnpm lint
pnpm test
git commit -m "feat: describe what you built"
git push -u origin feat/your-featureTelemetry & Privacy
MartinLoop sends minimal anonymous usage data to help improve reliability and prioritize development. A first-run notice appears before any data is transmitted. No data is sent on that first run.
What is sent:
Random installation ID (generated locally, never linked to your identity)
Per-process session ID
CLI version, Node version, OS and architecture
Event name and timestamp
Command category, run duration, success/failure category
Whether a receipt was generated; whether recovery occurred
Opaque remote-experience ID/type after a click
What is never sent:
Source code, prompts, task text, repository contents, file names, file paths
Environment variables, secrets, provider/model output
Receipt contents, ledger contents, approval details, verifier evidence
Email addresses, workspace, project, or organization identifiers
Raw exception messages or stack traces
Endpoint: https://tupopqvqnyyjuxseyxkr.supabase.co/functions/v1/product-events
Headers sent: Content-Type: application/json, User-Agent: MartinLoop-CLI/<version>
No authorization header, API key, or direct table access.
Opt out anytime:
martin telemetry offInspect what is sent:
martin telemetry explainEnvironment variables that disable telemetry: MARTIN_TELEMETRY_DISABLED=1, DO_NOT_TRACK=1, CI=1
MartinLoop continues to work normally with telemetry disabled. No features are gated on telemetry consent.
License
Apache-2.0. See LICENSE.
Maintenance
Related MCP Servers
- AlicenseAqualityAmaintenanceThis server enables LLMs to retrieve and process content from web pages, converting HTML to markdown for easier consumption.189,405MIT
- AlicenseAquality-maintenanceEnables browser automation through Playwright using accessibility tree snapshots instead of screenshots. Supports web scraping, form interactions, testing, and connecting to existing browser sessions with logged-in accounts.2310,3065
- Alicense-qualityFmaintenanceGovernance kernel for AI agents — policy enforcement, code safety verification, multi-model hallucination detection (CMVK), trust attestation (IATP), and immutable audit trails. Works with Claude Desktop, Cursor, and any MCP client.72MIT
- AlicenseAqualityAmaintenanceAgentGuard47 is runtime safety infrastructure for AI agents. It adds budget caps, loop detection, retry limits, timeouts, local traces, and incident reports so agents can stop bad runs while they are happening, not just explain them afterward.74MIT
Related MCP Connectors
Budget & cost control for AI agents — per-agent spend caps + rate limits before each call.
Enterprise AI Control Plane: governance, guardrails, spend tracking, compliance & smart routing.
See, price, and control every tool call your AI agents make: policy checks, cost, and audit tools.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/Keesan12/martin-loop'
If you have feedback or need assistance with the MCP directory API, please join our Discord server