@martinloop/mcp 0.3.7 → 0.3.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (88) hide show
  1. package/README.md +196 -137
  2. package/dist/resources.js +148 -148
  3. package/dist/server.js +0 -0
  4. package/dist/tools/tool-support.js +11 -1
  5. package/dist/vendor/adapters/claude-cli.d.ts +2 -2
  6. package/dist/vendor/adapters/claude-cli.js +127 -51
  7. package/dist/vendor/adapters/codex-launcher.js +10 -1
  8. package/dist/vendor/adapters/openai-compatible.js +6 -6
  9. package/package.json +86 -76
  10. package/server.json +21 -21
  11. package/dist/vendor/adapters/adapters/src/claude-cli.d.ts +0 -146
  12. package/dist/vendor/adapters/adapters/src/claude-cli.js +0 -1100
  13. package/dist/vendor/adapters/adapters/src/cli-bridge.d.ts +0 -103
  14. package/dist/vendor/adapters/adapters/src/cli-bridge.js +0 -569
  15. package/dist/vendor/adapters/adapters/src/codex-launcher.d.ts +0 -78
  16. package/dist/vendor/adapters/adapters/src/codex-launcher.js +0 -663
  17. package/dist/vendor/adapters/adapters/src/direct-provider.d.ts +0 -10
  18. package/dist/vendor/adapters/adapters/src/direct-provider.js +0 -40
  19. package/dist/vendor/adapters/adapters/src/index.d.ts +0 -8
  20. package/dist/vendor/adapters/adapters/src/index.js +0 -8
  21. package/dist/vendor/adapters/adapters/src/openai-compatible.d.ts +0 -62
  22. package/dist/vendor/adapters/adapters/src/openai-compatible.js +0 -306
  23. package/dist/vendor/adapters/adapters/src/runtime-support.d.ts +0 -17
  24. package/dist/vendor/adapters/adapters/src/runtime-support.js +0 -59
  25. package/dist/vendor/adapters/adapters/src/stub-agent-cli.d.ts +0 -8
  26. package/dist/vendor/adapters/adapters/src/stub-agent-cli.js +0 -40
  27. package/dist/vendor/adapters/adapters/src/stub-direct-provider.d.ts +0 -8
  28. package/dist/vendor/adapters/adapters/src/stub-direct-provider.js +0 -12
  29. package/dist/vendor/adapters/adapters/src/verifier-only.d.ts +0 -9
  30. package/dist/vendor/adapters/adapters/src/verifier-only.js +0 -63
  31. package/dist/vendor/adapters/contracts/src/context-graph.d.ts +0 -48
  32. package/dist/vendor/adapters/contracts/src/context-graph.js +0 -26
  33. package/dist/vendor/adapters/contracts/src/execution-policy.d.ts +0 -78
  34. package/dist/vendor/adapters/contracts/src/execution-policy.js +0 -43
  35. package/dist/vendor/adapters/contracts/src/governance.d.ts +0 -24
  36. package/dist/vendor/adapters/contracts/src/governance.js +0 -11
  37. package/dist/vendor/adapters/contracts/src/identity.d.ts +0 -29
  38. package/dist/vendor/adapters/contracts/src/identity.js +0 -30
  39. package/dist/vendor/adapters/contracts/src/index.d.ts +0 -412
  40. package/dist/vendor/adapters/contracts/src/index.js +0 -225
  41. package/dist/vendor/adapters/contracts/src/operator.d.ts +0 -19
  42. package/dist/vendor/adapters/contracts/src/operator.js +0 -11
  43. package/dist/vendor/adapters/contracts/src/trajectory.d.ts +0 -26
  44. package/dist/vendor/adapters/contracts/src/trajectory.js +0 -27
  45. package/dist/vendor/adapters/core/src/compiler.d.ts +0 -52
  46. package/dist/vendor/adapters/core/src/compiler.js +0 -52
  47. package/dist/vendor/adapters/core/src/context-graph.d.ts +0 -3
  48. package/dist/vendor/adapters/core/src/context-graph.js +0 -371
  49. package/dist/vendor/adapters/core/src/context-integrity.d.ts +0 -26
  50. package/dist/vendor/adapters/core/src/context-integrity.js +0 -80
  51. package/dist/vendor/adapters/core/src/grounding.d.ts +0 -38
  52. package/dist/vendor/adapters/core/src/grounding.js +0 -273
  53. package/dist/vendor/adapters/core/src/identity.d.ts +0 -20
  54. package/dist/vendor/adapters/core/src/identity.js +0 -86
  55. package/dist/vendor/adapters/core/src/index.d.ts +0 -186
  56. package/dist/vendor/adapters/core/src/index.js +0 -1495
  57. package/dist/vendor/adapters/core/src/leash.d.ts +0 -48
  58. package/dist/vendor/adapters/core/src/leash.js +0 -497
  59. package/dist/vendor/adapters/core/src/persistence/compiler.d.ts +0 -18
  60. package/dist/vendor/adapters/core/src/persistence/compiler.js +0 -34
  61. package/dist/vendor/adapters/core/src/persistence/index.d.ts +0 -10
  62. package/dist/vendor/adapters/core/src/persistence/index.js +0 -5
  63. package/dist/vendor/adapters/core/src/persistence/integrity.d.ts +0 -39
  64. package/dist/vendor/adapters/core/src/persistence/integrity.js +0 -252
  65. package/dist/vendor/adapters/core/src/persistence/ledger.d.ts +0 -23
  66. package/dist/vendor/adapters/core/src/persistence/ledger.js +0 -9
  67. package/dist/vendor/adapters/core/src/persistence/memory-store.d.ts +0 -63
  68. package/dist/vendor/adapters/core/src/persistence/memory-store.js +0 -115
  69. package/dist/vendor/adapters/core/src/persistence/runs-reader.d.ts +0 -66
  70. package/dist/vendor/adapters/core/src/persistence/runs-reader.js +0 -140
  71. package/dist/vendor/adapters/core/src/persistence/store.d.ts +0 -89
  72. package/dist/vendor/adapters/core/src/persistence/store.js +0 -125
  73. package/dist/vendor/adapters/core/src/persistence/trace-store.d.ts +0 -85
  74. package/dist/vendor/adapters/core/src/persistence/trace-store.js +0 -125
  75. package/dist/vendor/adapters/core/src/policy-compiler.d.ts +0 -2
  76. package/dist/vendor/adapters/core/src/policy-compiler.js +0 -195
  77. package/dist/vendor/adapters/core/src/policy.d.ts +0 -156
  78. package/dist/vendor/adapters/core/src/policy.js +0 -704
  79. package/dist/vendor/adapters/core/src/repo-analyzer.d.ts +0 -53
  80. package/dist/vendor/adapters/core/src/repo-analyzer.js +0 -263
  81. package/dist/vendor/adapters/core/src/rollback.d.ts +0 -15
  82. package/dist/vendor/adapters/core/src/rollback.js +0 -253
  83. package/dist/vendor/adapters/core/src/routing.d.ts +0 -82
  84. package/dist/vendor/adapters/core/src/routing.js +0 -336
  85. package/dist/vendor/adapters/core/src/test-integrity.d.ts +0 -64
  86. package/dist/vendor/adapters/core/src/test-integrity.js +0 -197
  87. package/dist/vendor/adapters/core/src/trajectory.d.ts +0 -18
  88. package/dist/vendor/adapters/core/src/trajectory.js +0 -295
package/README.md CHANGED
@@ -1,137 +1,196 @@
1
- # @martinloop/mcp
2
-
3
- You give an AI agent a coding task. It runs. You get a bill.
4
-
5
- But did it actually work? Did it pass your tests? How much did it spend? What files did it touch? Did it loop 47 times trying the same broken approach?
6
-
7
- You don't know. And that's the problem.
8
-
9
- ## What This Does
10
-
11
- MartinLoop is a governed loop for AI coding agents. You tell it what to do, set a budget, and point it at your test suite. It runs the agent, checks your tests after every attempt, and stops when either the tests pass or the money runs out.
12
-
13
- When it's done, you get a receipt — not a vague summary, but a structured record: dollars spent, attempts made, verification results, files changed, and whether you got what you asked for.
14
-
15
- **One line to connect it:**
16
-
17
- ```sh
18
- claude mcp add martin-loop -- npx -y @martinloop/mcp
19
- ```
20
-
21
- That's it. Your agent now runs governed.
22
-
23
- ## Real Numbers From Real Runs
24
-
25
- We tested this against live repos with real API spend:
26
-
27
- | What happened | Without MartinLoop | With MartinLoop |
28
- |---|---|---|
29
- | Budget: $1.50 task | Agent spent **$28.42** | Agent stopped at **$1.20** |
30
- | Failing verifier | Retried indefinitely | Stopped after 3 attempts with diagnosis |
31
- | CLI not on PATH | "not available on PATH" (dead stop) | Auto-discovered in AppData, kept running |
32
- | `bun run lint && bun run test` | Passed `&&` as a literal arg (always fails) | Routed through shell, worked |
33
-
34
- These aren't hypotheticals. The $28 overshoot happened in production testing. We fixed the circuit breaker in `0.3.8`.
35
-
36
- ## Install
37
-
38
- ### Claude Code
39
- ```sh
40
- claude mcp add martin-loop -- npx -y @martinloop/mcp
41
- ```
42
-
43
- Windows:
44
- ```sh
45
- claude mcp add --transport stdio --scope user martin-loop -- cmd /c npx -y @martinloop/mcp
46
- ```
47
-
48
- ### Codex
49
- ```sh
50
- codex mcp add martin-loop -- npx -y @martinloop/mcp
51
- ```
52
-
53
- ### Gemini CLI
54
- ```sh
55
- gemini mcp add martin-loop -- npx -y @martinloop/mcp
56
- ```
57
-
58
- ### Any MCP Host
59
- ```sh
60
- npx -y @martinloop/mcp
61
- ```
62
-
63
- ## How a Governed Run Works
64
-
65
- ```
66
- You: "Fix the auth bug. Budget $3. Verify: npm test"
67
-
68
- martin_doctor → checks CLI, auth, environment
69
- martin_plan → scopes the task, sets constraints
70
- martin_preflight → validates before any spend
71
- martin_run → agent works inside budget + verifier gates
72
- martin_dossier → receipt: $1.40 spent, 2 attempts, tests pass
73
- ```
74
-
75
- Every attempt runs your verifier. Every dollar is tracked. If the agent drifts off-task, the scope contract catches it. If it blows the budget, the circuit breaker kills the subprocess mid-stream — not after the bill arrives.
76
-
77
- ## What Your Agent Gets
78
-
79
- ### 21 Tools
80
-
81
- **Run the loop:**
82
- `martin_doctor` `martin_plan` `martin_preflight` `martin_run` `martin_pause` `martin_continue` `martin_cancel`
83
-
84
- **Inspect results:**
85
- `martin_status` `martin_logs` `martin_dossier` `martin_eval` `martin_inspect` `martin_list_runs` `martin_get_run` `martin_get_attempt` `martin_get_verification_results` `martin_triage_runs`
86
-
87
- **Ship the work:**
88
- `martin_pr_summary` `martin_create_pr` `martin_review_pr`
89
-
90
- ### 11 Read-Only Resources
91
-
92
- Your agent can pull context without side effects:
93
-
94
- `martin://runs/latest` · `martin://runs/latest/summary` · `martin://runs/latest/receipt` · `martin://runs/latest/proof-card` · `martin://runs/latest/budget-status` · `martin://runs/latest/verifier-evidence` · `martin://runs/recent` · `martin://server/health` · `martin://policies/current` · `martin://agent/next-step` · `martin://guides/mcp-usage` · `martin://guides/agent-start` · `martin://repo/risk-map`
95
-
96
- ### Configuration Profiles
97
-
98
- Generate host config tuned to your workflow:
99
-
100
- ```sh
101
- npx martin-loop mcp print-config --host claude --profile minimal # run + inspect
102
- npx martin-loop mcp print-config --host claude --profile diagnostic # + doctor + triage
103
- npx martin-loop mcp print-config --host claude --profile full-local # all local tools
104
- npx martin-loop mcp print-config --host claude --profile github-review # + PR workflow
105
- ```
106
-
107
- ## What Happens When Things Go Wrong
108
-
109
- MartinLoop doesn't just report failures — it tries to fix them:
110
-
111
- | Failure | Old behavior | Now |
112
- |---|---|---|
113
- | CLI not on PATH | Error message, dead stop | Searches npm global, homebrew, nvm, scoop — uses what it finds |
114
- | Verifier says "command not found" | Generic "verification failed" | Tells the next attempt: "bun is missing, install with `npm i -g bun`" |
115
- | `git restore` fails mid-rollback | Throws, leaves dirty state | Retries once, falls back to `git checkout`, cleans up |
116
- | Invalid `--profile` flag | Crashes | Warns, falls back to `minimal`, keeps running |
117
-
118
- ## Who Uses This
119
-
120
- - **Engineers running overnight agent loops** — you need a kill switch that actually works, and a receipt in the morning
121
- - **Teams with shared API budgets** — you need per-task spend caps, not org-wide prayer
122
- - **Anyone reviewing agent-generated PRs** — the dossier shows what the agent tried, what passed, and what didn't
123
-
124
- ## Requirements
125
-
126
- - Node.js 20+
127
- - One AI coding CLI: [Claude Code](https://docs.anthropic.com/claude-code), [Codex](https://github.com/openai/codex), or [Gemini CLI](https://github.com/google/gemini-cli)
128
-
129
- ## Links
130
-
131
- - [martin-loop](https://www.npmjs.com/package/martin-loop) — the standalone CLI
132
- - [GitHub](https://github.com/Keesan12/martin-loop) — source and issues
133
- - [martinloop.com](https://martinloop.com)
134
-
135
- ## License
136
-
137
- Apache-2.0
1
+ # MartinLoop MCP
2
+
3
+ <div align="center">
4
+ <img src="https://raw.githubusercontent.com/Keesan12/martin-loop/main/docs/assets/martinloop-logo.png" alt="MartinLoop" width="240">
5
+
6
+ **Stop runaway loops, bad code, and token waste.**
7
+
8
+ The governed MCP runtime for Claude Code, Codex, Gemini CLI, Cursor, and autonomous coding agents.
9
+
10
+ [![npm version](https://img.shields.io/npm/v/@martinloop/mcp?style=flat-square&logo=npm&logoColor=white)](https://www.npmjs.com/package/@martinloop/mcp)
11
+ [![npm downloads](https://img.shields.io/npm/dm/@martinloop/mcp?style=flat-square&label=downloads)](https://www.npmjs.com/package/@martinloop/mcp)
12
+ [![License: Apache-2.0](https://img.shields.io/badge/license-Apache--2.0-blue?style=flat-square&logo=apache)](https://github.com/Keesan12/martin-loop/blob/main/LICENSE)
13
+ [![Node](https://img.shields.io/badge/node-%3E%3D20-3c873a?style=flat-square&logo=nodedotjs&logoColor=white)](#requirements)
14
+ [![Glama score](https://glama.ai/mcp/servers/Keesan12/martin-loop/badges/score.svg)](https://glama.ai/mcp/servers/Keesan12/martin-loop)
15
+ </div>
16
+
17
+ AI coding agents can write code. MartinLoop decides whether they are allowed to keep spending, whether the result is actually verified, and what evidence must remain for review.
18
+
19
+ It wraps agent execution with:
20
+
21
+ - hard USD, token, iteration, time, command, and file-change limits
22
+ - verifier gates that must pass before completion
23
+ - allowed and denied path contracts
24
+ - preflight checks before any execution or spend
25
+ - durable pause, continue, and cancel receipts
26
+ - failure triage, run dossiers, evaluations, and PR-review evidence
27
+
28
+ ## Connect in one command
29
+
30
+ | Host | Command |
31
+ | --- | --- |
32
+ | Claude Code | `claude mcp add martin-loop -- npx -y @martinloop/mcp` |
33
+ | Codex | `codex mcp add martin-loop -- npx -y @martinloop/mcp` |
34
+ | Gemini CLI | `gemini mcp add martin-loop -- npx -y @martinloop/mcp` |
35
+ | Any stdio MCP host | `npx -y @martinloop/mcp` |
36
+
37
+ Windows Claude Code:
38
+
39
+ ```sh
40
+ claude mcp add --transport stdio --scope user martin-loop -- cmd /c npx -y @martinloop/mcp
41
+ ```
42
+
43
+ No API key is required to start and inspect the server. Live execution requires a supported coding-agent CLI and its normal authentication.
44
+
45
+ ## Why agents use MartinLoop
46
+
47
+ | Uncontrolled agent run | Governed MartinLoop run |
48
+ | --- | --- |
49
+ | The agent decides when it is done | Your verifier decides whether completion is valid |
50
+ | Retries continue until the user notices | Hard budgets and stop conditions prevent open-ended spend |
51
+ | Scope drifts across the repository | Allowed and denied paths constrain writes |
52
+ | The final answer hides failed attempts | The dossier preserves attempts, costs, verification, and artifacts |
53
+ | Process control is ephemeral | Pause, continue, and cancel actions leave durable receipts |
54
+ | “Probably fixed” becomes accepted | Missing, failed, contradicted, or unknown verification stays incomplete |
55
+
56
+ MartinLoop is not another coding agent. It is the enforcement and evidence layer around the agents you already use.
57
+
58
+ ## Agent operating contract
59
+
60
+ Use this sequence for governed coding work:
61
+
62
+ ```text
63
+ martin_doctor
64
+ → martin_estimate
65
+ → martin_plan
66
+ → martin_preflight
67
+ → martin_run
68
+ → martin_dossier
69
+ → martin_eval
70
+ ```
71
+
72
+ ### Rules for agents
73
+
74
+ 1. Start with `martin_doctor` to inspect the environment and run store.
75
+ 2. Call `martin_estimate` before spending.
76
+ 3. Keep the same objective and compatible scope through estimate, plan, preflight, and run.
77
+ 4. Prefer read-only tools until execution is explicitly authorized.
78
+ 5. Treat failed, contradicted, missing, or unknown verification as incomplete.
79
+ 6. Use `martin://agent/next-step` or `martin://guides/agent-start` when the next action is unclear.
80
+ 7. Do not use `martin_create_pr` with `execute: true` unless the user has explicitly authorized a GitHub write.
81
+
82
+ `martin_run` intentionally hard-blocks until the required doctor, estimate, plan, and preflight receipts exist for the same task.
83
+
84
+ ## What a governed run looks like
85
+
86
+ ```text
87
+ User objective:
88
+ "Fix the auth regression. Budget: $3. Verify: npm test."
89
+
90
+ doctor checks environment, CLI availability, and run storage
91
+ estimate predicts route, spend, and pre-work burn without spending
92
+ plan defines scope, verifier proposal, policy pack, and risk
93
+ preflight validates the contract before execution
94
+ run executes inside budget, scope, policy, and verifier gates
95
+ dossier returns attempts, cost, verification, artifacts, and evidence paths
96
+ eval grades completion, verifier health, risk, and reviewability
97
+ ```
98
+
99
+ Every attempt is bounded by the run contract. A confident model answer does not override a failed verifier.
100
+
101
+ ## Proof, not promises
102
+
103
+ This real governed run spent `$0.51` against a `$3.00` budget. The verifier passed and the receipt integrity was signed. MartinLoop still kept the result at `EVIDENCE_BOUNDARY` because rollback evidence had not been recorded.
104
+
105
+ <div align="center">
106
+ <img src="https://raw.githubusercontent.com/Keesan12/martin-loop/main/docs/assets/proof-receipt-live-governed.png" alt="MartinLoop governed run receipt showing spend, budget, verifier result, integrity, and evidence boundary" width="720">
107
+ </div>
108
+
109
+ Inspect the example receipt:
110
+
111
+ - [Markdown receipt](https://github.com/Keesan12/martin-loop/blob/main/docs/examples/proof-receipts/live-governed-run-receipt.md)
112
+ - [JSON receipt](https://github.com/Keesan12/martin-loop/blob/main/docs/examples/proof-receipts/live-governed-run-receipt.json)
113
+
114
+ ## Tool surface
115
+
116
+ ### Governed workflow
117
+
118
+ - `martin_doctor` — inspect environment readiness; expected first call
119
+ - `martin_estimate` — estimate cost and route without spending
120
+ - `martin_plan` — produce scoped plan, verifier proposal, policy pack, and risk
121
+ - `martin_preflight` — validate readiness before execution
122
+ - `martin_run` — execute a governed coding task
123
+ - `martin_pause` — record a durable pause request
124
+ - `martin_continue` — record a durable resume request
125
+ - `martin_cancel` — record a durable cancellation request
126
+
127
+ ### Inspection and review
128
+
129
+ - `martin_status`, `martin_logs`, `martin_inspect`
130
+ - `martin_list_runs`, `martin_triage_runs`
131
+ - `martin_get_run`, `martin_get_attempt`, `martin_get_verification_results`
132
+ - `martin_run_dossier`, `martin_dossier`, `martin_eval`
133
+ - `martin_pr_summary`, `martin_create_pr`, `martin_review_pr`
134
+
135
+ ### Read-only resources
136
+
137
+ The server exposes run summaries, receipts, budget status, verifier evidence, policies, health, agent guidance, and repository-risk context through `martin://` resources, including:
138
+
139
+ ```text
140
+ martin://runs/latest
141
+ martin://runs/latest/summary
142
+ martin://runs/latest/receipt
143
+ martin://runs/latest/budget-status
144
+ martin://runs/latest/verifier-evidence
145
+ martin://runs/recent
146
+ martin://server/health
147
+ martin://policies/current
148
+ martin://agent/next-step
149
+ martin://guides/agent-start
150
+ martin://repo/risk-map
151
+ ```
152
+
153
+ Use resources when the agent needs context without side effects.
154
+
155
+ ## Configuration profiles
156
+
157
+ Generate host config tuned to the minimum surface needed:
158
+
159
+ ```sh
160
+ npx martin-loop mcp print-config --host claude --profile minimal
161
+ npx martin-loop mcp print-config --host claude --profile diagnostic
162
+ npx martin-loop mcp print-config --host claude --profile full-local
163
+ npx martin-loop mcp print-config --host claude --profile github-review
164
+ ```
165
+
166
+ - `minimal` — core run and inspection path
167
+ - `diagnostic` — adds doctor and triage surfaces
168
+ - `full-local` — all local tools
169
+ - `github-review` — adds PR evidence and review workflow
170
+
171
+ ## Trust boundaries
172
+
173
+ - Cost and token values include provenance: actual, estimated, or unavailable.
174
+ - A verifier proves only the commands you configured, not every product requirement.
175
+ - Receipt integrity must be verified before evidence is trusted externally.
176
+ - Unknown or missing evidence never passes silently.
177
+ - MartinLoop does not guarantee that an agent will produce correct code; it makes execution bounded, verification explicit, and failure reviewable.
178
+
179
+ ## Requirements
180
+
181
+ - Node.js 20+
182
+ - One supported coding-agent CLI for live execution: Claude Code, Codex, Gemini CLI, or an OpenAI-compatible route
183
+ - Git repository for rollback-aware and changed-file workflows
184
+
185
+ ## Links
186
+
187
+ - [Glama server page](https://glama.ai/mcp/servers/Keesan12/martin-loop)
188
+ - [npm: @martinloop/mcp](https://www.npmjs.com/package/@martinloop/mcp)
189
+ - [GitHub source and issues](https://github.com/Keesan12/martin-loop)
190
+ - [MCP setup guide](https://github.com/Keesan12/martin-loop/blob/main/docs/getting-started/mcp.md)
191
+ - [MCP tool reference](https://github.com/Keesan12/martin-loop/blob/main/docs/reference/mcp-tools.md)
192
+ - [martinloop.com](https://martinloop.com)
193
+
194
+ ## License
195
+
196
+ Apache-2.0.