@getmarrow/mcp 2.3.3 → 2.3.5

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.
package/README.md CHANGED
@@ -1,26 +1,95 @@
1
1
  # @getmarrow/mcp
2
2
 
3
- > **Your go-to memory provider for all agents, for any AI model.**
3
+ > **Memory and decision intelligence for MCP-compatible agents.**
4
4
 
5
- Give Claude (or any MCP-compatible agent) a memory that compounds across every session, every user, every run. Marrow connects your agent to a hive of collective intelligence — what worked, what failed, patterns discovered across thousands of agent runs.
5
+ Marrow gives your agent a memory that compounds.
6
6
 
7
- **One tool call. Your agent stops starting from zero.**
7
+ With `@getmarrow/mcp`, any MCP-compatible client can log intent before acting, inspect live loop state during work, and commit outcomes back to the hive when the work is done. That means your agent stops operating like an amnesiac and starts carrying forward real decision history.
8
+
9
+ **Your agent stops repeating the same mistakes. It learns from prior sessions — and from the wider Marrow hive — through a clean MCP tool surface.**
10
+
11
+ ---
12
+
13
+ ## What's New in v2.3.4
14
+
15
+ ### Loop enforcement is now part of the MCP workflow
16
+
17
+ This release adds the MCP-side loop workflow so agents can operate through a real decision cycle instead of dumping disconnected thoughts into memory.
18
+
19
+ New / updated tools:
20
+ - `marrow_orient` / `orient` — start the session with loop state, recent lessons, and a recommended next step
21
+ - `marrow_think` / `think` — log intent and get pattern intelligence + loop metadata back
22
+ - `marrow_check` / `check` — inspect loop state mid-session before handoff or completion
23
+ - `marrow_commit` / `commit` — close the loop cleanly with outcome logging
24
+
25
+ What changed in practice:
26
+ - session-local loop state persists across MCP tool calls
27
+ - agents get a canonical session-start nudge toward `marrow_think`
28
+ - `commit` now correctly returns a closed-loop state (`done` / `outcome_logged`)
29
+ - the MCP package now lines up properly with the newer SDK loop-enforcement model
8
30
 
9
31
  ---
10
32
 
11
33
  ## Install
12
34
 
35
+ Run it directly with `npx`:
36
+
13
37
  ```bash
14
- npm install -g @getmarrow/mcp
38
+ npx @getmarrow/mcp
39
+ ```
40
+
41
+ Or register it in your MCP client config.
42
+
43
+ ---
44
+
45
+ ## The Problem
46
+
47
+ Most agents still operate with shallow memory.
48
+
49
+ They might keep a short context window, maybe write a note or two, then lose the important part:
50
+ - what they were trying to do
51
+ - what they actually did
52
+ - whether it worked
53
+ - what pattern that should teach the next run
54
+
55
+ That creates a familiar failure loop:
56
+ - the same mistakes repeat
57
+ - work gets marked done without structured outcome memory
58
+ - agents drift between sessions
59
+ - hosts have no clean way to inspect whether the work loop is actually closed
60
+
61
+ **Marrow fixes this.**
62
+
63
+ Through MCP, your agent can:
64
+ - orient at session start
65
+ - log intent before meaningful action
66
+ - inspect loop state before handoff or completion
67
+ - commit outcomes back to memory cleanly
68
+
69
+ ---
70
+
71
+ ## How It Works
72
+
73
+ Marrow exposes a simple operating loop through MCP:
74
+
75
+ ```text
76
+ orient -> think -> act -> check -> commit
15
77
  ```
16
78
 
17
- Get your API key at [getmarrow.ai](https://getmarrow.ai)
79
+ That gives agents an actual memory discipline:
80
+ - **orient** → pick up recent lessons and current loop state
81
+ - **think** → log intent and receive decision intelligence
82
+ - **act** → perform the meaningful work
83
+ - **check** → inspect whether the loop is still open or missing something
84
+ - **commit** → log the outcome and close the loop
85
+
86
+ The result is memory that is useful during execution, not just after the fact.
18
87
 
19
88
  ---
20
89
 
21
- ## Setup — Claude Desktop
90
+ ## Quick Start
22
91
 
23
- Add to your `claude_desktop_config.json`:
92
+ ### Claude Desktop
24
93
 
25
94
  ```json
26
95
  {
@@ -29,259 +98,197 @@ Add to your `claude_desktop_config.json`:
29
98
  "command": "npx",
30
99
  "args": ["@getmarrow/mcp"],
31
100
  "env": {
32
- "MARROW_API_KEY": "your_key_from_getmarrow.ai"
101
+ "MARROW_API_KEY": "mrw_your_key_here"
33
102
  }
34
103
  }
35
104
  }
36
105
  }
37
106
  ```
38
107
 
39
- Restart Claude. That's it — Marrow is now available as a tool in every conversation.
108
+ ### Generic MCP host
40
109
 
41
- ---
110
+ If your MCP host supports command-based servers, point it at:
42
111
 
43
- ## Setup — Any MCP-Compatible Agent
44
-
45
- ```bash
46
- export MARROW_API_KEY=your_key_from_getmarrow.ai # get your key at getmarrow.ai/dashboard
47
- npx @getmarrow/mcp
48
- # Listens on stdin, outputs JSON-RPC on stdout
49
- # Drop into any MCP framework
50
- ```
112
+ - command: `npx`
113
+ - args: `@getmarrow/mcp`
114
+ - env: `MARROW_API_KEY=...`
51
115
 
52
116
  ---
53
117
 
54
- ## How It Works
55
-
56
- Your agent calls `marrow_think` before acting. Marrow queries the hive — collective intelligence from every agent that's ever done something similar — and returns what worked, what patterns emerged, what playbooks exist. When your agent is done, that experience gets committed back to the hive. Every agent gets smarter. Forever.
57
-
58
- ---
118
+ ## When to Use MCP vs SDK
59
119
 
60
- ## Quick Start Pattern
120
+ Use **`@getmarrow/mcp`** when:
121
+ - your agent already speaks MCP
122
+ - you want Marrow exposed as tools
123
+ - you want loop state visible during the session
124
+ - you want hosts/orchestrators to inspect whether work is ready for completion
61
125
 
62
- ```
63
- Session start marrow_orient() ← reads from hive, surfaces warnings
64
- Before each action marrow_think() ← queries + opens memory session
65
- After each action marrow_commit() writes result back to hive
66
- ```
126
+ Use **`@getmarrow/sdk`** when:
127
+ - you are integrating Marrow directly into application/runtime code
128
+ - you want wrapper-level enforcement around deploy, publish, outbound sends, or external writes
129
+ - you want programmatic control through `beforeAction()`, `afterAction()`, `wrap()`, and `check()`
67
130
 
68
- **orient() is what makes Marrow compound.** Without it, you're writing to a database no one reads. With it, your agent automatically avoids mistakes it's made before.
131
+ In short:
132
+ - **MCP** = tool-driven integration for agents
133
+ - **SDK** = code-level integration for runtimes and apps
69
134
 
70
135
  ---
71
136
 
72
137
  ## Tools
73
138
 
74
- ### `marrow_orient` ⚡ Call this first
139
+ ### `marrow_orient` / `orient`
140
+ Start the session with Marrow context.
75
141
 
76
- **Call at the start of every session, before any other tool.** Returns failure warnings from your hive history so you avoid known mistakes immediately.
142
+ Returns:
143
+ - loop state
144
+ - recommended next step
145
+ - recent lessons (when available)
146
+ - canonical session-start nudge
77
147
 
78
- ```json
79
- {
80
- "taskType": "implementation" // optional: filter to specific task type
81
- }
82
- ```
148
+ Typical use:
149
+ - first meaningful step in a session
150
+ - before planning or execution begins
83
151
 
84
- **Response:**
85
- ```json
86
- {
87
- "warnings": [
88
- {
89
- "type": "process",
90
- "failureRate": 0.26,
91
- "message": "process has 26% failure rate over 27 decisions — review lessons before acting"
92
- }
93
- ],
94
- "shouldPause": false // true if any failure rate >40% — stop and query lessons first
95
- }
96
- ```
152
+ ### `marrow_think` / `think`
153
+ Log intent and get decision intelligence back.
97
154
 
98
- If `shouldPause` is true, query your lessons before proceeding. If `warnings` is empty, you're clear.
155
+ Returns:
156
+ - `decision_id`
157
+ - pattern intelligence
158
+ - loop metadata
159
+ - warnings / next-step guidance
99
160
 
100
- ---
161
+ Typical use:
162
+ - before meaningful action
163
+ - before deploy / publish / send / external write work
164
+ - when shifting from planning into execution
101
165
 
102
- ### `marrow_think` The core tool
166
+ ### `marrow_check` / `check`
167
+ Inspect the current loop state.
103
168
 
104
- Call this before every significant action. Returns collective intelligence from the hive.
169
+ Returns:
170
+ - whether the loop is still open
171
+ - current recommended next step
172
+ - whether the session looks ready for completion
173
+ - warnings if outcome/context is still missing
105
174
 
106
- **Input:**
107
- ```json
108
- {
109
- "action": "What the agent is about to do",
110
- "type": "implementation | security | architecture | process | general",
111
- "previous_outcome": "What happened last time (auto-commits previous session)",
112
- "previous_success": true
113
- }
114
- ```
175
+ Typical use:
176
+ - before handoff
177
+ - before “done”
178
+ - before outbound updates after meaningful work
115
179
 
116
- **Returns:**
117
- ```json
118
- {
119
- "decision_id": "save this for the next call",
120
- "intelligence": {
121
- "similar": [
122
- { "outcome": "Used incremental approach. Shipped in 2 days, 0 rollbacks.", "confidence": 0.91 }
123
- ],
124
- "similar_count": 3,
125
- "patterns": [
126
- { "pattern_id": "a1b2c3", "decision_type": "implementation", "frequency": 84, "confidence": 0.9 }
127
- ],
128
- "patterns_count": 2,
129
- "templates": [
130
- { "steps": ["Plan", "Spec", "Build", "Test", "Deploy"], "success_rate": 0.89 }
131
- ],
132
- "success_rate": 0.87,
133
- "priority_score": 0.7,
134
- "insight": "Workflow gap detected — barvis_audit missing after build",
135
- "insights": [
136
- {
137
- "type": "workflow_gap",
138
- "summary": "audit not logged after build (3 consecutive times)",
139
- "action": "Run audit before reporting done",
140
- "severity": "critical",
141
- "count": 3
142
- }
143
- ],
144
- "cluster_id": "818df2fa-6365-49f6-b478-bc3dcb748469"
145
- },
146
- "stream_url": "/v1/stream?format=sse"
147
- }
148
- ```
180
+ ### `marrow_commit` / `commit`
181
+ Commit outcome to the hive and close the loop.
182
+
183
+ Returns:
184
+ - committed / accepted state
185
+ - updated loop state
186
+ - recommended next step after closure
149
187
 
150
- **Example prompt to Claude:**
188
+ Typical use:
189
+ - after meaningful work finishes
190
+ - after a deploy / publish / send / write succeeds or fails
191
+ - before a clean handoff or completion
151
192
 
152
- > Before starting this refactor, call `marrow_think` with action "Refactoring auth module to support OAuth 2.0" and type "implementation". Use the intelligence to guide your approach.
193
+ ### `patterns`
194
+ Inspect accumulated decision patterns.
153
195
 
154
- Claude will automatically:
155
- 1. Call `marrow_think`
156
- 2. Read what worked for other agents doing similar refactors
157
- 3. Apply those patterns to its approach
158
- 4. On the next `marrow_think` call, commit this outcome back to the hive
196
+ Typical use:
197
+ - identifying repeated failures
198
+ - learning what tends to work for a task type
199
+ - orienting around recent drift or recurring mistakes
159
200
 
160
201
  ---
161
202
 
162
- ### `marrow_commit` — Explicit commit
203
+ ## Example Workflow
163
204
 
164
- Commit an outcome explicitly when you need more control. `marrow_think` auto-commits on the next call, so this is optional.
205
+ ### Example: deployment task
165
206
 
166
- **Input:**
167
- ```json
168
- {
169
- "decision_id": "from previous marrow_think",
170
- "success": true,
171
- "outcome": "Auth refactor complete. OAuth 2.0 working. Zero breaking changes. 2 day turnaround.",
172
- "caused_by": "optional: previous decision_id to link causally"
173
- }
174
- ```
207
+ 1. Call `marrow_orient`
208
+ 2. Call `marrow_think` with something like:
209
+ - action: `Deploy auth refactor to staging`
210
+ - type: `implementation`
211
+ 3. Perform the deploy
212
+ 4. Call `marrow_check`
213
+ 5. Call `marrow_commit` with outcome:
214
+ - success: `true`
215
+ - outcome: `Staging deploy passed smoke tests`
216
+
217
+ This gives the next session or next agent real context:
218
+ - what was attempted
219
+ - whether it worked
220
+ - what patterns Marrow saw around it
221
+ - whether the loop was actually closed
175
222
 
176
223
  ---
177
224
 
178
- ### `marrow_status` Platform health
225
+ ## What Your Agent Gets Back
179
226
 
180
- Check your agent's current performance across the hive.
227
+ Marrow MCP tools expose more than a raw ID.
181
228
 
182
- **Returns:**
183
- ```json
184
- {
185
- "success_rate": 0.87,
186
- "decision_velocity": 142,
187
- "patterns_discovered": 23,
188
- "hive_consensus": 0.91
189
- }
190
- ```
229
+ Depending on the tool, agents can receive:
230
+ - recent lessons
231
+ - similar past outcomes
232
+ - warnings about recurring failure patterns
233
+ - current loop state
234
+ - recommended next step
235
+ - session guidance to close the loop cleanly
191
236
 
192
- ---
237
+ That makes the MCP server useful during execution, not just as a logging endpoint.
193
238
 
194
- ## Real Example — Claude Coding Agent
239
+ ---
195
240
 
196
- **System prompt addition:**
197
- ```
198
- Before starting any significant task, call marrow_think with a description of what you're about to do.
199
- After completing a task, the next marrow_think call will automatically record the outcome.
200
- Use the intelligence returned to guide your approach — especially `similar` and `patterns`.
201
- ```
241
+ ## Why Marrow Through MCP?
202
242
 
203
- **What happens in practice:**
243
+ Without Marrow:
244
+ - the agent starts every session half-amnesiac
245
+ - failures repeat because there is no durable decision trail
246
+ - completion gets declared without structured outcome memory
247
+ - hosts cannot easily inspect whether the work loop is actually closed
204
248
 
205
- User: *"Refactor the payment service to add retry logic"*
249
+ With Marrow MCP:
250
+ - the agent can orient before acting
251
+ - meaningful work can be tracked in-session
252
+ - hosts can inspect loop state before completion or handoff
253
+ - outcomes become structured memory instead of vague summaries
254
+ - memory becomes operational, not decorative
206
255
 
207
- Claude calls `marrow_think`:
208
- ```json
209
- { "action": "Adding retry logic to payment service", "type": "implementation" }
210
- ```
211
-
212
- Marrow returns:
213
- ```json
214
- {
215
- "intelligence": {
216
- "similar": [
217
- { "outcome": "Exponential backoff with jitter. 3 retries max. Idempotency key required. Zero double-charges in 6 months.", "confidence": 0.96 }
218
- ],
219
- "patterns": [
220
- { "pattern": "Retry without idempotency key causes duplicate transactions in 23% of cases", "frequency": 156 }
221
- ]
222
- }
223
- }
224
- ```
256
+ ---
225
257
 
226
- Claude now knows — from thousands of other agents' experience — exactly what to do and what to avoid. Without Marrow, it would have guessed.
258
+ ## Session Hint
227
259
 
228
- ---
260
+ At session start, Marrow nudges clients with the canonical reminder:
229
261
 
230
- ## Why Marrow for MCP?
262
+ > Tip: log plans, decisions, and outcomes to Marrow so your agent improves over time.
231
263
 
232
- - **Zero setup friction** one config entry, works instantly
233
- - **Model agnostic** — Claude, GPT, Gemini, any MCP-compatible model
234
- - **Compounds automatically** — every session adds to the hive, no manual curation
235
- - **Private by default** — your agent's decisions are anonymized before entering the hive
236
- - **Persistent across sessions** — memory survives context resets, model upgrades, new conversations
264
+ For agents that have not logged any decisions yet this session, Marrow can also steer them toward `marrow_think` before acting.
237
265
 
238
266
  ---
239
267
 
240
- ## Get Started
241
-
242
- ```bash
243
- npm install -g @getmarrow/mcp
244
- ```
268
+ ## Security / Key Handling
245
269
 
246
- 1. Get your API key at [getmarrow.ai](https://getmarrow.ai)
247
- 2. Add the MCP server config above
248
- 3. Tell your agent to call `marrow_think` before acting
249
- 4. Watch collective intelligence flow in from the first call
270
+ Use environment variables for your API key.
250
271
 
251
- **Your agent inherits the experience of every agent that came before it.**
272
+ Correct:
273
+ - `MARROW_API_KEY` passed through MCP host config or runtime environment
252
274
 
253
- ---
275
+ Do not:
276
+ - hardcode production API keys into source files
277
+ - commit real keys into config
278
+ - paste secrets into README examples
254
279
 
255
- *Compatible with Claude Desktop, Claude API, and any MCP-compatible framework.*
280
+ Placeholder examples like `mrw_your_key_here` are documentation only.
256
281
 
257
282
  ---
258
283
 
259
- ## Privacy & Data
284
+ ## Get an API Key
260
285
 
261
- **What Marrow collects:**
262
- - The `action` string and `type` you pass to `marrow_think` and `marrow_commit`
263
- - The `outcome` you report — used to train collective intelligence
264
- - Decision metadata: timestamps, success/failure, confidence scores
286
+ Sign up at [getmarrow.ai](https://getmarrow.ai)
265
287
 
266
- **What Marrow does NOT collect:**
267
- - No PII (names, emails, user IDs, IP addresses)
268
- - No conversation content or message history
269
- - No code, credentials, or file contents
270
- - No agent identity beyond your anonymous API key hash
271
-
272
- **How data is anonymized:**
273
- - All inputs are stripped of PII patterns before storage (emails, phone numbers, UUIDs matching user ID formats, IP addresses)
274
- - Your API key is stored as a SHA-256 hash — never in plaintext
275
- - Hive intelligence is aggregated across agents — individual decisions are never exposed to other users
276
- - You can opt out of hive contribution at any time by setting `contributeToHive: false` in your MCP config
288
+ ---
277
289
 
278
- **Hive data model:**
279
- - Decisions you log contribute anonymously to collective patterns
280
- - No one can trace a pattern back to your agent or your account
281
- - Enterprise plans include private org hive mode — your data never leaves your org
290
+ ## Related Package
282
291
 
283
- **Data retention:**
284
- - Decision data: 30 days on Free tier, 90 days on Pro, unlimited on Enterprise
285
- - You can delete all your data at any time via the dashboard or API
292
+ If you want direct runtime integration instead of MCP tools:
286
293
 
287
- For full details, see our [Privacy Policy](https://getmarrow.ai/privacy).
294
+ - [`@getmarrow/sdk`](https://www.npmjs.com/package/@getmarrow/sdk)
@@ -0,0 +1,86 @@
1
+ /**
2
+ * Marrow API client — thin HTTP wrapper
3
+ */
4
+ export type MarrowLoopRecommendation = 'orient' | 'think' | 'act' | 'commit' | 'done';
5
+ export interface MarrowLoopState {
6
+ orientedAt: string | null;
7
+ lastThinkAt: string | null;
8
+ lastOutcomeAt: string | null;
9
+ hasIntentLog: boolean;
10
+ hasOutcomeLog: boolean;
11
+ actionCountSinceLastThink: number;
12
+ externalActionCountSinceLastThink: number;
13
+ lastDecisionId: string | null;
14
+ pendingDecisionId: string | null;
15
+ recommendedNext: MarrowLoopRecommendation;
16
+ loopState: 'idle' | 'oriented' | 'intent_logged' | 'acting' | 'outcome_logged';
17
+ message: string | null;
18
+ hints: string[];
19
+ }
20
+ export declare class MarrowClient {
21
+ private apiKey;
22
+ private baseUrl;
23
+ private currentDecisionId;
24
+ private loopState;
25
+ constructor();
26
+ check(): {
27
+ ok: boolean;
28
+ recommendedNext: MarrowLoopRecommendation;
29
+ state: {
30
+ hints: string[];
31
+ orientedAt: string | null;
32
+ lastThinkAt: string | null;
33
+ lastOutcomeAt: string | null;
34
+ hasIntentLog: boolean;
35
+ hasOutcomeLog: boolean;
36
+ actionCountSinceLastThink: number;
37
+ externalActionCountSinceLastThink: number;
38
+ lastDecisionId: string | null;
39
+ pendingDecisionId: string | null;
40
+ recommendedNext: MarrowLoopRecommendation;
41
+ loopState: "idle" | "oriented" | "intent_logged" | "acting" | "outcome_logged";
42
+ message: string | null;
43
+ };
44
+ warnings: string[];
45
+ };
46
+ orient(params?: {
47
+ task_type?: string;
48
+ }): Promise<Record<string, unknown>>;
49
+ think(params: {
50
+ action: string;
51
+ type: string;
52
+ previous_decision_id?: string;
53
+ previous_success?: boolean;
54
+ previous_outcome?: string;
55
+ }): Promise<Record<string, unknown>>;
56
+ commit(params: {
57
+ decision_id: string;
58
+ success: boolean;
59
+ outcome: string;
60
+ }): Promise<Record<string, unknown>>;
61
+ recordAction(meta?: {
62
+ external?: boolean;
63
+ }): {
64
+ ok: boolean;
65
+ recommendedNext: MarrowLoopRecommendation;
66
+ state: {
67
+ hints: string[];
68
+ orientedAt: string | null;
69
+ lastThinkAt: string | null;
70
+ lastOutcomeAt: string | null;
71
+ hasIntentLog: boolean;
72
+ hasOutcomeLog: boolean;
73
+ actionCountSinceLastThink: number;
74
+ externalActionCountSinceLastThink: number;
75
+ lastDecisionId: string | null;
76
+ pendingDecisionId: string | null;
77
+ recommendedNext: MarrowLoopRecommendation;
78
+ loopState: "idle" | "oriented" | "intent_logged" | "acting" | "outcome_logged";
79
+ message: string | null;
80
+ };
81
+ warnings: string[];
82
+ };
83
+ patterns(): Promise<Record<string, unknown>[]>;
84
+ private post;
85
+ private get;
86
+ }