@getmarrow/mcp 1.1.1 → 2.0.0

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,171 +1,40 @@
1
1
  # @getmarrow/mcp
2
2
 
3
- Marrow MCP Server Collective intelligence for AI agents via Model Context Protocol.
3
+ **Your go-to memory provider for all agents, for any AI model.**
4
4
 
5
- ## Why Marrow?
5
+ Add Marrow to any Claude agent in 30 seconds. The hive makes every decision smarter.
6
6
 
7
- Marrow is the **hive for AI agents** — where collective intelligence compounds exponentially.
8
-
9
- **The Problem:** Every agent learns in isolation. Mistakes repeat. Patterns disappear. Each new agent starts from zero.
10
-
11
- **The Solution:** Marrow captures every decision your agents make and broadcasts it to millions of others. New agents inherit decades of learned patterns. Your agent becomes smarter just by joining the hive.
12
-
13
- **The Moat:** Your competitive advantage grows with network size. At scale, Marrow agents outthink any individual system because they tap into exponential collective wisdom. This is **Wikipedia for AI decisions** — but in real time, with measurable success rates.
14
-
15
- **What You Get:**
16
- - **Shared Learning:** Your agent inherits patterns from millions of other agents' successful decisions
17
- - **Exponential Value:** Each new agent makes the entire hive smarter
18
- - **Measurable Intelligence:** Decision patterns ranked by success rate, confidence, and safety
19
- - **Competitive Edge:** Agents using Marrow outperform isolated agents by 30-80% (depending on domain)
20
-
21
- **Default Endpoint:** `https://api.getmarrow.ai`
22
- **Environment Variable:** `MARROW_API_URL`
23
-
24
- ## Installation
7
+ ## Install
25
8
 
26
9
  ```bash
27
10
  npm install @getmarrow/mcp
28
11
  ```
29
12
 
30
- ## Quick Start
31
-
32
- ### Set API Key
33
-
34
- ```bash
35
- export MARROW_API_KEY=mrw_your_api_key_here
36
- ```
37
-
38
- ### Add to Claude Agent Config
39
-
40
- In your agent's configuration file (e.g., Claude config):
13
+ ## Claude Config
41
14
 
42
15
  ```json
43
16
  {
44
17
  "mcpServers": {
45
18
  "marrow": {
46
- "command": "marrow-mcp",
47
- "env": {
48
- "MARROW_API_KEY": "mrw_..."
49
- }
19
+ "command": "npx",
20
+ "args": ["@getmarrow/mcp"],
21
+ "env": { "MARROW_API_KEY": "mrw_your_key" }
50
22
  }
51
23
  }
52
24
  }
53
25
  ```
54
26
 
55
- ### Claude Can Now Use Marrow
56
-
57
- Once configured, Claude can call:
58
-
59
- ```
60
- marrow.log_decision({
61
- decision_type: "analysis",
62
- context: { topic: "climate change", sources: 5 },
63
- outcome: { conclusion: "human-caused", confidence: 0.92 }
64
- })
65
-
66
- marrow.get_consensus("analysis")
67
- // Returns what the collective intelligence recommends
68
-
69
- marrow.get_lessons("analysis")
70
- // Returns successful patterns from other agents
71
- ```
72
-
73
- ## Available Tools
74
-
75
- ### `log_decision`
76
- Log a decision to Marrow. The hive learns from it.
77
-
78
- ```
79
- log_decision({
80
- decision_type: "string",
81
- context: { /* any object */ },
82
- outcome: { /* any object */ },
83
- tags: ["optional", "tags"]
84
- })
85
- ```
86
-
87
- ### `get_lessons`
88
- Get published lessons (patterns) for a decision type.
89
-
90
- ```
91
- get_lessons({
92
- decision_type: "string"
93
- })
94
- ```
95
-
96
- ### `get_consensus`
97
- Get what the hive recommends for a decision type.
98
-
99
- ```
100
- get_consensus({
101
- decision_type: "string"
102
- })
103
- ```
104
-
105
- ### `check_safety`
106
- Check if a decision passes alignment and safety checks.
107
-
108
- ```
109
- check_safety({
110
- decision_type: "string",
111
- context: { /* object */ },
112
- outcome: { /* object */ }
113
- })
114
- ```
115
-
116
- ### `publish_lesson`
117
- Publish a lesson to the marketplace.
118
-
119
- ```
120
- publish_lesson({
121
- decision_type: "string",
122
- pattern: "string",
123
- success_rate: 0.92,
124
- description: "Human-readable description"
125
- })
126
- ```
127
-
128
- ### `get_reputation`
129
- Get your agent's reputation in the hive.
130
-
131
- ```
132
- get_reputation()
133
- // Returns: { score, rank, lessons_published }
134
- ```
135
-
136
- ## How It Works
137
-
138
- 1. Agent calls `log_decision()` — decision is recorded
139
- 2. Hive processes — learns from the decision
140
- 3. Other agents get smarter — inherit patterns via bootstrap
141
- 4. Agent can `get_consensus()` — ask the hive for recommendations
142
- 5. Agent can `publish_lesson()` — share successful patterns
143
- 6. Marketplace effects — other agents fork and adapt your lessons
144
-
145
- ## Pricing
146
-
147
- - **Free tier:** Full data, all tools, no cost
148
- - **Pro ($49/month):** PII stripped, same features
149
- - **Enterprise:** Custom, compliance, on-premise option
150
-
151
- ## Documentation
152
-
153
- - [Full API Reference](https://docs.getmarrow.ai)
154
- - [MCP Protocol Details](https://docs.getmarrow.ai/mcp)
155
- - [Pricing & Tiers](https://getmarrow.ai/pricing)
156
- - [Architecture](https://docs.getmarrow.ai/architecture)
157
-
158
- ## Environment Variables
27
+ ## Tools
159
28
 
160
- - `MARROW_API_KEY` — Your API key (required)
161
- - `MARROW_API_URL` API endpoint (default: https://api.getmarrow.ai/v1)
29
+ ### `marrow_think`
30
+ Call before every significant action. Returns collective intelligence from the hive — what worked before, discovered patterns, proven playbooks. Pass `previous_outcome` to commit your last action and keep the hive learning.
162
31
 
163
- ## Support
32
+ ### `marrow_commit`
33
+ Explicit commit when you need more control. `marrow_think` auto-commits on the next call.
164
34
 
165
- - Discord: [getmarrow.ai/discord](https://getmarrow.ai/discord)
166
- - Email: support@getmarrow.ai
167
- - Issues: [GitHub Issues](https://github.com/getmarrow/mcp-server/issues)
35
+ ### `marrow_status`
36
+ Full platform health — your success rate, hive activity, patterns detected.
168
37
 
169
- ## License
38
+ ## Get a Key
170
39
 
171
- MIT
40
+ [portal.getmarrow.ai](https://portal.getmarrow.ai)
package/dist/cli.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  /**
3
- * Marrow MCP CLI
4
- * Start the MCP server for use with Claude, o1, or other MCP-compatible agents
3
+ * Marrow MCP stdio server — collective memory for Claude and MCP agents.
4
+ * Exposes: marrow_think, marrow_commit, marrow_status
5
5
  */
6
6
  export {};
7
+ //# sourceMappingURL=cli.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AAEA;;;GAGG"}
package/dist/cli.js CHANGED
@@ -1,51 +1,226 @@
1
1
  #!/usr/bin/env node
2
2
  "use strict";
3
3
  /**
4
- * Marrow MCP CLI
5
- * Start the MCP server for use with Claude, o1, or other MCP-compatible agents
4
+ * Marrow MCP stdio server — collective memory for Claude and MCP agents.
5
+ * Exposes: marrow_think, marrow_commit, marrow_status
6
6
  */
7
- var __importDefault = (this && this.__importDefault) || function (mod) {
8
- return (mod && mod.__esModule) ? mod : { "default": mod };
7
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
8
+ if (k2 === undefined) k2 = k;
9
+ var desc = Object.getOwnPropertyDescriptor(m, k);
10
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
11
+ desc = { enumerable: true, get: function() { return m[k]; } };
12
+ }
13
+ Object.defineProperty(o, k2, desc);
14
+ }) : (function(o, m, k, k2) {
15
+ if (k2 === undefined) k2 = k;
16
+ o[k2] = m[k];
17
+ }));
18
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
19
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
20
+ }) : function(o, v) {
21
+ o["default"] = v;
22
+ });
23
+ var __importStar = (this && this.__importStar) || function (mod) {
24
+ if (mod && mod.__esModule) return mod;
25
+ var result = {};
26
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
27
+ __setModuleDefault(result, mod);
28
+ return result;
9
29
  };
10
30
  Object.defineProperty(exports, "__esModule", { value: true });
11
- const index_1 = __importDefault(require("./index"));
12
- async function main() {
13
- const apiKey = process.env.MARROW_API_KEY;
14
- if (!apiKey) {
15
- console.error('Error: MARROW_API_KEY environment variable not set');
16
- console.error('Set it with: export MARROW_API_KEY=mrw_...');
17
- process.exit(1);
18
- }
31
+ const readline = __importStar(require("readline"));
32
+ const index_1 = require("./index");
33
+ const API_KEY = process.env.MARROW_API_KEY || '';
34
+ const BASE_URL = process.env.MARROW_BASE_URL || 'https://api.getmarrow.ai';
35
+ if (!API_KEY) {
36
+ process.stderr.write('Error: MARROW_API_KEY environment variable is required\n');
37
+ process.exit(1);
38
+ }
39
+ function send(response) {
40
+ process.stdout.write(JSON.stringify(response) + '\n');
41
+ }
42
+ function success(id, result) {
43
+ send({ jsonrpc: '2.0', id, result });
44
+ }
45
+ function error(id, code, message) {
46
+ send({ jsonrpc: '2.0', id, error: { code, message } });
47
+ }
48
+ // Tool definitions
49
+ const TOOLS = [
50
+ {
51
+ name: 'marrow_think',
52
+ description: 'Get collective intelligence from the Marrow hive before acting. ' +
53
+ 'Call this before every significant action. Pass previous_outcome ' +
54
+ 'to auto-commit your last action and open a new memory session.',
55
+ inputSchema: {
56
+ type: 'object',
57
+ properties: {
58
+ action: {
59
+ type: 'string',
60
+ description: 'What the agent is about to do',
61
+ },
62
+ type: {
63
+ type: 'string',
64
+ enum: ['implementation', 'security', 'architecture', 'process', 'general'],
65
+ description: 'Type of action (default: general)',
66
+ },
67
+ context: {
68
+ type: 'object',
69
+ description: 'Optional metadata about the current situation',
70
+ },
71
+ previous_decision_id: {
72
+ type: 'string',
73
+ description: 'decision_id from previous think() call — auto-commits that session',
74
+ },
75
+ previous_success: {
76
+ type: 'boolean',
77
+ description: 'Did the previous action succeed?',
78
+ },
79
+ previous_outcome: {
80
+ type: 'string',
81
+ description: 'What happened in the previous action (required if previous_decision_id provided)',
82
+ },
83
+ },
84
+ required: ['action'],
85
+ },
86
+ },
87
+ {
88
+ name: 'marrow_commit',
89
+ description: 'Explicitly commit the result of an action to Marrow. ' +
90
+ 'Optional — marrow_think() auto-commits if you pass previous_outcome. ' +
91
+ 'Use when you need explicit control over commit timing.',
92
+ inputSchema: {
93
+ type: 'object',
94
+ properties: {
95
+ decision_id: {
96
+ type: 'string',
97
+ description: 'decision_id from the marrow_think call',
98
+ },
99
+ success: {
100
+ type: 'boolean',
101
+ description: 'Did the action succeed?',
102
+ },
103
+ outcome: {
104
+ type: 'string',
105
+ description: 'What happened — be specific, this trains the hive',
106
+ },
107
+ caused_by: {
108
+ type: 'string',
109
+ description: 'Optional: what caused this action',
110
+ },
111
+ },
112
+ required: ['decision_id', 'success', 'outcome'],
113
+ },
114
+ },
115
+ {
116
+ name: 'marrow_status',
117
+ description: 'Check Marrow platform health and status.',
118
+ inputSchema: {
119
+ type: 'object',
120
+ properties: {},
121
+ required: [],
122
+ },
123
+ },
124
+ ];
125
+ // Request handler
126
+ async function handleRequest(req) {
127
+ const { id, method, params } = req;
19
128
  try {
20
- const server = new index_1.default(apiKey);
21
- // Handle stdio
22
- process.stdin.setEncoding('utf-8');
23
- process.stdin.on('data', async (chunk) => {
24
- try {
25
- const lines = chunk.trim().split('\n');
26
- for (const line of lines) {
27
- if (!line)
28
- continue;
29
- const request = JSON.parse(line);
30
- const response = await server.processRequest(request);
31
- process.stdout.write(JSON.stringify(response) + '\n');
32
- }
129
+ if (method === 'initialize') {
130
+ success(id, {
131
+ protocolVersion: '2024-11-05',
132
+ capabilities: { tools: {} },
133
+ serverInfo: { name: 'marrow', version: '2.0.0' },
134
+ });
135
+ return;
136
+ }
137
+ if (method === 'tools/list') {
138
+ success(id, { tools: TOOLS });
139
+ return;
140
+ }
141
+ if (method === 'tools/call') {
142
+ const toolName = params?.name;
143
+ const args = (params?.arguments || {});
144
+ if (toolName === 'marrow_think') {
145
+ const result = await (0, index_1.marrowThink)(API_KEY, BASE_URL, {
146
+ action: args.action,
147
+ type: args.type,
148
+ context: args.context,
149
+ previous_decision_id: args.previous_decision_id,
150
+ previous_success: args.previous_success,
151
+ previous_outcome: args.previous_outcome,
152
+ });
153
+ success(id, {
154
+ content: [
155
+ {
156
+ type: 'text',
157
+ text: JSON.stringify(result, null, 2),
158
+ },
159
+ ],
160
+ });
161
+ return;
33
162
  }
34
- catch (error) {
35
- console.error('Error processing request:', error);
163
+ if (toolName === 'marrow_commit') {
164
+ const result = await (0, index_1.marrowCommit)(API_KEY, BASE_URL, {
165
+ decision_id: args.decision_id,
166
+ success: args.success,
167
+ outcome: args.outcome,
168
+ caused_by: args.caused_by,
169
+ });
170
+ success(id, {
171
+ content: [
172
+ {
173
+ type: 'text',
174
+ text: JSON.stringify(result, null, 2),
175
+ },
176
+ ],
177
+ });
178
+ return;
36
179
  }
37
- });
38
- process.stdin.on('end', () => {
39
- process.exit(0);
40
- });
41
- // Log startup
42
- console.error('[Marrow MCP] Server started');
43
- console.error(`[Marrow MCP] API Key: ${apiKey.substring(0, 10)}...`);
44
- console.error('[Marrow MCP] Ready to receive requests');
180
+ if (toolName === 'marrow_status') {
181
+ const result = await (0, index_1.marrowStatus)(API_KEY, BASE_URL);
182
+ success(id, {
183
+ content: [
184
+ {
185
+ type: 'text',
186
+ text: JSON.stringify(result, null, 2),
187
+ },
188
+ ],
189
+ });
190
+ return;
191
+ }
192
+ error(id, -32601, `Unknown tool: ${toolName}`);
193
+ return;
194
+ }
195
+ // Unknown method
196
+ error(id, -32601, `Method not found: ${method}`);
45
197
  }
46
- catch (error) {
47
- console.error('Fatal error:', error);
48
- process.exit(1);
198
+ catch (err) {
199
+ const message = err instanceof Error ? err.message : String(err);
200
+ error(id, -32603, `Internal error: ${message}`);
49
201
  }
50
202
  }
51
- main();
203
+ // stdio server
204
+ const rl = readline.createInterface({
205
+ input: process.stdin,
206
+ output: process.stdout,
207
+ terminal: false,
208
+ });
209
+ rl.on('line', (line) => {
210
+ const trimmed = line.trim();
211
+ if (!trimmed)
212
+ return;
213
+ try {
214
+ const req = JSON.parse(trimmed);
215
+ handleRequest(req).catch((err) => {
216
+ process.stderr.write(`Unhandled error: ${err}\n`);
217
+ });
218
+ }
219
+ catch {
220
+ process.stderr.write(`Failed to parse request: ${trimmed}\n`);
221
+ }
222
+ });
223
+ rl.on('close', () => {
224
+ process.exit(0);
225
+ });
226
+ //# sourceMappingURL=cli.js.map
@@ -0,0 +1 @@
1
+ {"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,EAAE,EAAE,CAAC,KAAK,EAAE,mBAAmB,OAAO,EAAE,CAAC,CAAC;IAClD,CAAC;AACH,CAAC;AAED,eAAe;AACf,MAAM,EAAE,GAAG,QAAQ,CAAC,eAAe,CAAC;IAClC,KAAK,EAAE,OAAO,CAAC,KAAK;IACpB,MAAM,EAAE,OAAO,CAAC,MAAM;IACtB,QAAQ,EAAE,KAAK;CAChB,CAAC,CAAC;AAEH,EAAE,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,EAAE;IACrB,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC;IAC5B,IAAI,CAAC,OAAO;QAAE,OAAO;IAErB,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAe,CAAC;QAC9C,aAAa,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;YAC/B,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,oBAAoB,GAAG,IAAI,CAAC,CAAC;QACpD,CAAC,CAAC,CAAC;IACL,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,4BAA4B,OAAO,IAAI,CAAC,CAAC;IAChE,CAAC;AACH,CAAC,CAAC,CAAC;AAEH,EAAE,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,EAAE;IAClB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
package/dist/index.d.ts CHANGED
@@ -1,55 +1,53 @@
1
- /**
2
- * Marrow MCP Server
3
- * Model Context Protocol server for Marrow collective intelligence
4
- *
5
- * Exposes tools: log_decision, get_lessons, check_safety, get_consensus
6
- */
7
- export interface MCPTool {
8
- name: string;
9
- description: string;
10
- inputSchema: {
11
- type: string;
12
- properties: Record<string, any>;
13
- required: string[];
14
- };
1
+ export interface MarrowIntelligence {
2
+ similar: Array<{
3
+ outcome: string;
4
+ confidence: number;
5
+ }>;
6
+ patterns: Array<{
7
+ pattern: string;
8
+ frequency: number;
9
+ }>;
10
+ templates: Array<{
11
+ steps: unknown[];
12
+ success_rate: number;
13
+ }>;
14
+ shared: Array<{
15
+ outcome: string;
16
+ }>;
17
+ causal_chain: unknown | null;
18
+ success_rate: number;
19
+ priority_score: number;
15
20
  }
16
- export interface MCPRequest {
17
- jsonrpc: string;
18
- id: string | number;
19
- method: string;
20
- params?: any;
21
+ export interface ThinkResult {
22
+ decision_id: string;
23
+ intelligence: MarrowIntelligence;
24
+ stream_url: string;
25
+ previous_committed?: boolean;
21
26
  }
22
- export interface MCPResponse {
23
- jsonrpc: string;
24
- id: string | number;
25
- result?: any;
26
- error?: {
27
- code: number;
28
- message: string;
29
- data?: any;
30
- };
27
+ export interface CommitResult {
28
+ committed: boolean;
29
+ success_rate: number;
30
+ insight: string | null;
31
31
  }
32
- export declare class MarrowMCPServer {
33
- private apiKey;
34
- private baseUrl;
35
- constructor(apiKey?: string);
36
- /**
37
- * Get available tools (MCP protocol)
38
- */
39
- getTools(): MCPTool[];
40
- /**
41
- * Handle tool calls (MCP protocol)
42
- */
43
- callTool(toolName: string, params: Record<string, any>): Promise<any>;
44
- /**
45
- * Process MCP request
46
- */
47
- processRequest(request: MCPRequest): Promise<MCPResponse>;
48
- private logDecision;
49
- private getLessons;
50
- private getConsensus;
51
- private checkSafety;
52
- private publishLesson;
53
- private getReputation;
32
+ export interface StatusResult {
33
+ status: string;
34
+ version: string;
35
+ tiers: number;
36
+ uptime_ms: number;
54
37
  }
55
- export default MarrowMCPServer;
38
+ export declare function marrowThink(apiKey: string, baseUrl: string, params: {
39
+ action: string;
40
+ type?: string;
41
+ context?: Record<string, unknown>;
42
+ previous_decision_id?: string;
43
+ previous_success?: boolean;
44
+ previous_outcome?: string;
45
+ }): Promise<ThinkResult>;
46
+ export declare function marrowCommit(apiKey: string, baseUrl: string, params: {
47
+ decision_id: string;
48
+ success: boolean;
49
+ outcome: string;
50
+ caused_by?: string;
51
+ }): Promise<CommitResult>;
52
+ export declare function marrowStatus(apiKey: string, baseUrl: string): Promise<StatusResult>;
53
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE,KAAK,CAAC;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACxD,QAAQ,EAAE,KAAK,CAAC;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACxD,SAAS,EAAE,KAAK,CAAC;QAAE,KAAK,EAAE,OAAO,EAAE,CAAC;QAAC,YAAY,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC7D,MAAM,EAAE,KAAK,CAAC;QAAE,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACnC,YAAY,EAAE,OAAO,GAAG,IAAI,CAAC;IAC7B,YAAY,EAAE,MAAM,CAAC;IACrB,cAAc,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,WAAW;IAC1B,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,kBAAkB,CAAC;IACjC,UAAU,EAAE,MAAM,CAAC;IACnB,kBAAkB,CAAC,EAAE,OAAO,CAAC;CAC9B;AAED,MAAM,WAAW,YAAY;IAC3B,SAAS,EAAE,OAAO,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;CACxB;AAED,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,wBAAsB,WAAW,CAC/B,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,MAAM,EACf,MAAM,EAAE;IACN,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAClC,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B,GACA,OAAO,CAAC,WAAW,CAAC,CAwBtB;AAED,wBAAsB,YAAY,CAChC,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,MAAM,EACf,MAAM,EAAE;IACN,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,GACA,OAAO,CAAC,YAAY,CAAC,CAavB;AAED,wBAAsB,YAAY,CAChC,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,YAAY,CAAC,CAQvB"}
package/dist/index.js CHANGED
@@ -1,223 +1,55 @@
1
1
  "use strict";
2
- /**
3
- * Marrow MCP Server
4
- * Model Context Protocol server for Marrow collective intelligence
5
- *
6
- * Exposes tools: log_decision, get_lessons, check_safety, get_consensus
7
- */
8
2
  Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.MarrowMCPServer = void 0;
10
- class MarrowMCPServer {
11
- constructor(apiKey = process.env.MARROW_API_KEY || '') {
12
- if (!apiKey) {
13
- throw new Error('MARROW_API_KEY environment variable not set');
14
- }
15
- this.apiKey = apiKey;
16
- this.baseUrl = process.env.MARROW_API_URL || 'https://api.getmarrow.ai/v1';
17
- }
18
- /**
19
- * Get available tools (MCP protocol)
20
- */
21
- getTools() {
22
- return [
23
- {
24
- name: 'log_decision',
25
- description: 'Log a decision to Marrow. The hive learns from your decisions.',
26
- inputSchema: {
27
- type: 'object',
28
- properties: {
29
- decision_type: { type: 'string', description: 'Type of decision (e.g., "trade", "classification")' },
30
- context: { type: 'object', description: 'Decision context and input data' },
31
- outcome: { type: 'object', description: 'Decision outcome and result' },
32
- tags: { type: 'array', items: { type: 'string' }, description: 'Optional tags for categorization' }
33
- },
34
- required: ['decision_type', 'context', 'outcome']
35
- }
36
- },
37
- {
38
- name: 'get_lessons',
39
- description: 'Get published lessons (patterns) for a decision type',
40
- inputSchema: {
41
- type: 'object',
42
- properties: {
43
- decision_type: { type: 'string', description: 'Decision type to get lessons for' }
44
- },
45
- required: ['decision_type']
46
- }
47
- },
48
- {
49
- name: 'get_consensus',
50
- description: 'Get hive consensus recommendation for a decision type',
51
- inputSchema: {
52
- type: 'object',
53
- properties: {
54
- decision_type: { type: 'string', description: 'Decision type to get consensus for' }
55
- },
56
- required: ['decision_type']
57
- }
58
- },
59
- {
60
- name: 'check_safety',
61
- description: 'Check if a decision passes safety and alignment checks',
62
- inputSchema: {
63
- type: 'object',
64
- properties: {
65
- decision_type: { type: 'string', description: 'Type of decision' },
66
- context: { type: 'object', description: 'Decision context' },
67
- outcome: { type: 'object', description: 'Decision outcome' }
68
- },
69
- required: ['decision_type', 'context', 'outcome']
70
- }
71
- },
72
- {
73
- name: 'publish_lesson',
74
- description: 'Publish a lesson to the marketplace',
75
- inputSchema: {
76
- type: 'object',
77
- properties: {
78
- decision_type: { type: 'string', description: 'Type of decision' },
79
- pattern: { type: 'string', description: 'Pattern description' },
80
- success_rate: { type: 'number', description: 'Success rate (0-1)' },
81
- description: { type: 'string', description: 'Human-readable description' }
82
- },
83
- required: ['decision_type', 'pattern', 'success_rate', 'description']
84
- }
85
- },
86
- {
87
- name: 'get_reputation',
88
- description: 'Get your agent\'s reputation score in the hive',
89
- inputSchema: {
90
- type: 'object',
91
- properties: {},
92
- required: []
93
- }
94
- }
95
- ];
96
- }
97
- /**
98
- * Handle tool calls (MCP protocol)
99
- */
100
- async callTool(toolName, params) {
101
- switch (toolName) {
102
- case 'log_decision':
103
- return this.logDecision(params);
104
- case 'get_lessons':
105
- return this.getLessons(params.decision_type);
106
- case 'get_consensus':
107
- return this.getConsensus(params.decision_type);
108
- case 'check_safety':
109
- return this.checkSafety(params);
110
- case 'publish_lesson':
111
- return this.publishLesson(params);
112
- case 'get_reputation':
113
- return this.getReputation();
114
- default:
115
- throw new Error(`Unknown tool: ${toolName}`);
116
- }
117
- }
118
- /**
119
- * Process MCP request
120
- */
121
- async processRequest(request) {
122
- try {
123
- if (request.method === 'tools/list') {
124
- return {
125
- jsonrpc: '2.0',
126
- id: request.id,
127
- result: { tools: this.getTools() }
128
- };
129
- }
130
- if (request.method === 'tools/call') {
131
- const { name, arguments: args } = request.params;
132
- const result = await this.callTool(name, args);
133
- return {
134
- jsonrpc: '2.0',
135
- id: request.id,
136
- result
137
- };
138
- }
139
- throw new Error(`Unknown method: ${request.method}`);
140
- }
141
- catch (error) {
142
- return {
143
- jsonrpc: '2.0',
144
- id: request.id,
145
- error: {
146
- code: -32603,
147
- message: error instanceof Error ? error.message : 'Internal error'
148
- }
149
- };
150
- }
151
- }
152
- async logDecision(params) {
153
- const response = await fetch(`${this.baseUrl}/decisions`, {
154
- method: 'POST',
155
- headers: {
156
- 'Authorization': `Bearer ${this.apiKey}`,
157
- 'Content-Type': 'application/json'
158
- },
159
- body: JSON.stringify(params)
160
- });
161
- if (!response.ok) {
162
- throw new Error(`API error: ${response.statusText}`);
163
- }
164
- return await response.json();
165
- }
166
- async getLessons(decisionType) {
167
- const response = await fetch(`${this.baseUrl}/lessons?decision_type=${decisionType}`, {
168
- headers: { 'Authorization': `Bearer ${this.apiKey}` }
169
- });
170
- if (!response.ok) {
171
- throw new Error(`API error: ${response.statusText}`);
172
- }
173
- return await response.json();
174
- }
175
- async getConsensus(decisionType) {
176
- const response = await fetch(`${this.baseUrl}/hive/consensus/${decisionType}`, {
177
- headers: { 'Authorization': `Bearer ${this.apiKey}` }
178
- });
179
- if (!response.ok) {
180
- throw new Error(`API error: ${response.statusText}`);
181
- }
182
- return await response.json();
183
- }
184
- async checkSafety(params) {
185
- const response = await fetch(`${this.baseUrl}/safety/check`, {
186
- method: 'POST',
187
- headers: {
188
- 'Authorization': `Bearer ${this.apiKey}`,
189
- 'Content-Type': 'application/json'
190
- },
191
- body: JSON.stringify(params)
192
- });
193
- if (!response.ok) {
194
- throw new Error(`API error: ${response.statusText}`);
195
- }
196
- return await response.json();
197
- }
198
- async publishLesson(params) {
199
- const response = await fetch(`${this.baseUrl}/marketplace/lessons`, {
200
- method: 'POST',
201
- headers: {
202
- 'Authorization': `Bearer ${this.apiKey}`,
203
- 'Content-Type': 'application/json'
204
- },
205
- body: JSON.stringify(params)
206
- });
207
- if (!response.ok) {
208
- throw new Error(`API error: ${response.statusText}`);
209
- }
210
- return await response.json();
211
- }
212
- async getReputation() {
213
- const response = await fetch(`${this.baseUrl}/agent/reputation`, {
214
- headers: { 'Authorization': `Bearer ${this.apiKey}` }
215
- });
216
- if (!response.ok) {
217
- throw new Error(`API error: ${response.statusText}`);
218
- }
219
- return await response.json();
220
- }
3
+ exports.marrowStatus = exports.marrowCommit = exports.marrowThink = void 0;
4
+ async function marrowThink(apiKey, baseUrl, params) {
5
+ const body = {
6
+ action: params.action,
7
+ type: params.type || 'general',
8
+ };
9
+ if (params.context)
10
+ body.context = params.context;
11
+ if (params.previous_decision_id) {
12
+ body.previous_decision_id = params.previous_decision_id;
13
+ body.previous_success = params.previous_success ?? true;
14
+ body.previous_outcome = params.previous_outcome ?? '';
15
+ }
16
+ const res = await fetch(`${baseUrl}/v1/agent/think`, {
17
+ method: 'POST',
18
+ headers: {
19
+ 'Authorization': `Bearer ${apiKey}`,
20
+ 'Content-Type': 'application/json',
21
+ },
22
+ body: JSON.stringify(body),
23
+ });
24
+ const json = await res.json();
25
+ if (json.error)
26
+ throw new Error(json.error);
27
+ return json.data;
28
+ }
29
+ exports.marrowThink = marrowThink;
30
+ async function marrowCommit(apiKey, baseUrl, params) {
31
+ const res = await fetch(`${baseUrl}/v1/agent/commit`, {
32
+ method: 'POST',
33
+ headers: {
34
+ 'Authorization': `Bearer ${apiKey}`,
35
+ 'Content-Type': 'application/json',
36
+ },
37
+ body: JSON.stringify(params),
38
+ });
39
+ const json = await res.json();
40
+ if (json.error)
41
+ throw new Error(json.error);
42
+ return json.data;
43
+ }
44
+ exports.marrowCommit = marrowCommit;
45
+ async function marrowStatus(apiKey, baseUrl) {
46
+ const res = await fetch(`${baseUrl}/v1/health`, {
47
+ headers: { 'Authorization': `Bearer ${apiKey}` },
48
+ });
49
+ const json = await res.json();
50
+ if (json.error)
51
+ throw new Error(json.error);
52
+ return json.data;
221
53
  }
222
- exports.MarrowMCPServer = MarrowMCPServer;
223
- exports.default = MarrowMCPServer;
54
+ exports.marrowStatus = marrowStatus;
55
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AA8BO,KAAK,UAAU,WAAW,CAC/B,MAAc,EACd,OAAe,EACf,MAOC;IAED,MAAM,IAAI,GAA4B;QACpC,MAAM,EAAE,MAAM,CAAC,MAAM;QACrB,IAAI,EAAE,MAAM,CAAC,IAAI,IAAI,SAAS;KAC/B,CAAC;IACF,IAAI,MAAM,CAAC,OAAO;QAAE,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC;IAClD,IAAI,MAAM,CAAC,oBAAoB,EAAE,CAAC;QAChC,IAAI,CAAC,oBAAoB,GAAG,MAAM,CAAC,oBAAoB,CAAC;QACxD,IAAI,CAAC,gBAAgB,GAAG,MAAM,CAAC,gBAAgB,IAAI,IAAI,CAAC;QACxD,IAAI,CAAC,gBAAgB,GAAG,MAAM,CAAC,gBAAgB,IAAI,EAAE,CAAC;IACxD,CAAC;IAED,MAAM,GAAG,GAAG,MAAM,KAAK,CAAC,GAAG,OAAO,iBAAiB,EAAE;QACnD,MAAM,EAAE,MAAM;QACd,OAAO,EAAE;YACP,eAAe,EAAE,U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AI,CAAC;AACnB,CAAC;AAXD,oCAWC"}
package/package.json CHANGED
@@ -1,49 +1,20 @@
1
1
  {
2
2
  "name": "@getmarrow/mcp",
3
- "version": "1.1.1",
4
- "description": "Marrow MCP Server Bring collective intelligence to Claude, Cline, and AI agents via Model Context Protocol. Connect to the hive.",
3
+ "version": "2.0.0",
4
+ "description": "Your go-to memory provider for all agents, for any AI model.",
5
+ "bin": {
6
+ "marrow-mcp": "dist/cli.js"
7
+ },
5
8
  "main": "dist/index.js",
6
- "types": "dist/index.d.ts",
7
- "files": [
8
- "dist",
9
- "README.md",
10
- "LICENSE"
11
- ],
12
9
  "scripts": {
13
- "build": "tsc",
14
- "prepublishOnly": "npm run build"
10
+ "build": "tsc"
15
11
  },
16
12
  "keywords": [
17
- "collective-intelligence",
18
- "ai-agents",
19
- "hive",
20
- "shared-learning",
21
13
  "mcp",
22
- "model-context-protocol",
14
+ "claude",
23
15
  "ai",
24
- "agents",
25
- "memory"
16
+ "memory",
17
+ "agents"
26
18
  ],
27
- "author": "Buu (Marrow)",
28
- "license": "MIT",
29
- "repository": {
30
- "type": "git",
31
- "url": "https://github.com/getmarrow/mcp-server.git"
32
- },
33
- "publishConfig": {
34
- "registry": "https://registry.npmjs.org",
35
- "access": "public"
36
- },
37
- "bin": {
38
- "marrow-mcp": "dist/cli.js"
39
- },
40
- "devDependencies": {
41
- "@types/jest": "^29.5.0",
42
- "@types/node": "^20.0.0",
43
- "jest": "^29.5.0",
44
- "typescript": "^5.0.0"
45
- },
46
- "engines": {
47
- "node": ">=18.0.0"
48
- }
49
- }
19
+ "license": "MIT"
20
+ }
package/src/cli.ts ADDED
@@ -0,0 +1,235 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * Marrow MCP stdio server — collective memory for Claude and MCP agents.
5
+ * Exposes: marrow_think, marrow_commit, marrow_status
6
+ */
7
+
8
+ import * as readline from 'readline';
9
+ import { marrowThink, marrowCommit, marrowStatus } from './index';
10
+
11
+ const API_KEY = process.env.MARROW_API_KEY || '';
12
+ const BASE_URL = process.env.MARROW_BASE_URL || 'https://api.getmarrow.ai';
13
+
14
+ if (!API_KEY) {
15
+ process.stderr.write('Error: MARROW_API_KEY environment variable is required\n');
16
+ process.exit(1);
17
+ }
18
+
19
+ // MCP protocol types
20
+ interface MCPRequest {
21
+ jsonrpc: '2.0';
22
+ id: string | number;
23
+ method: string;
24
+ params?: Record<string, unknown>;
25
+ }
26
+
27
+ interface MCPResponse {
28
+ jsonrpc: '2.0';
29
+ id: string | number;
30
+ result?: unknown;
31
+ error?: { code: number; message: string };
32
+ }
33
+
34
+ function send(response: MCPResponse): void {
35
+ process.stdout.write(JSON.stringify(response) + '\n');
36
+ }
37
+
38
+ function success(id: string | number, result: unknown): void {
39
+ send({ jsonrpc: '2.0', id, result });
40
+ }
41
+
42
+ function error(id: string | number, code: number, message: string): void {
43
+ send({ jsonrpc: '2.0', id, error: { code, message } });
44
+ }
45
+
46
+ // Tool definitions
47
+ const TOOLS = [
48
+ {
49
+ name: 'marrow_think',
50
+ description:
51
+ 'Get collective intelligence from the Marrow hive before acting. ' +
52
+ 'Call this before every significant action. Pass previous_outcome ' +
53
+ 'to auto-commit your last action and open a new memory session.',
54
+ inputSchema: {
55
+ type: 'object',
56
+ properties: {
57
+ action: {
58
+ type: 'string',
59
+ description: 'What the agent is about to do',
60
+ },
61
+ type: {
62
+ type: 'string',
63
+ enum: ['implementation', 'security', 'architecture', 'process', 'general'],
64
+ description: 'Type of action (default: general)',
65
+ },
66
+ context: {
67
+ type: 'object',
68
+ description: 'Optional metadata about the current situation',
69
+ },
70
+ previous_decision_id: {
71
+ type: 'string',
72
+ description: 'decision_id from previous think() call — auto-commits that session',
73
+ },
74
+ previous_success: {
75
+ type: 'boolean',
76
+ description: 'Did the previous action succeed?',
77
+ },
78
+ previous_outcome: {
79
+ type: 'string',
80
+ description: 'What happened in the previous action (required if previous_decision_id provided)',
81
+ },
82
+ },
83
+ required: ['action'],
84
+ },
85
+ },
86
+ {
87
+ name: 'marrow_commit',
88
+ description:
89
+ 'Explicitly commit the result of an action to Marrow. ' +
90
+ 'Optional — marrow_think() auto-commits if you pass previous_outcome. ' +
91
+ 'Use when you need explicit control over commit timing.',
92
+ inputSchema: {
93
+ type: 'object',
94
+ properties: {
95
+ decision_id: {
96
+ type: 'string',
97
+ description: 'decision_id from the marrow_think call',
98
+ },
99
+ success: {
100
+ type: 'boolean',
101
+ description: 'Did the action succeed?',
102
+ },
103
+ outcome: {
104
+ type: 'string',
105
+ description: 'What happened — be specific, this trains the hive',
106
+ },
107
+ caused_by: {
108
+ type: 'string',
109
+ description: 'Optional: what caused this action',
110
+ },
111
+ },
112
+ required: ['decision_id', 'success', 'outcome'],
113
+ },
114
+ },
115
+ {
116
+ name: 'marrow_status',
117
+ description: 'Check Marrow platform health and status.',
118
+ inputSchema: {
119
+ type: 'object',
120
+ properties: {},
121
+ required: [],
122
+ },
123
+ },
124
+ ];
125
+
126
+ // Request handler
127
+ async function handleRequest(req: MCPRequest): Promise<void> {
128
+ const { id, method, params } = req;
129
+
130
+ try {
131
+ if (method === 'initialize') {
132
+ success(id, {
133
+ protocolVersion: '2024-11-05',
134
+ capabilities: { tools: {} },
135
+ serverInfo: { name: 'marrow', version: '2.0.0' },
136
+ });
137
+ return;
138
+ }
139
+
140
+ if (method === 'tools/list') {
141
+ success(id, { tools: TOOLS });
142
+ return;
143
+ }
144
+
145
+ if (method === 'tools/call') {
146
+ const toolName = (params as Record<string, unknown>)?.name as string;
147
+ const args = ((params as Record<string, unknown>)?.arguments || {}) as Record<string, unknown>;
148
+
149
+ if (toolName === 'marrow_think') {
150
+ const result = await marrowThink(API_KEY, BASE_URL, {
151
+ action: args.action as string,
152
+ type: args.type as string | undefined,
153
+ context: args.context as Record<string, unknown> | undefined,
154
+ previous_decision_id: args.previous_decision_id as string | undefined,
155
+ previous_success: args.previous_success as boolean | undefined,
156
+ previous_outcome: args.previous_outcome as string | undefined,
157
+ });
158
+ success(id, {
159
+ content: [
160
+ {
161
+ type: 'text',
162
+ text: JSON.stringify(result, null, 2),
163
+ },
164
+ ],
165
+ });
166
+ return;
167
+ }
168
+
169
+ if (toolName === 'marrow_commit') {
170
+ const result = await marrowCommit(API_KEY, BASE_URL, {
171
+ decision_id: args.decision_id as string,
172
+ success: args.success as boolean,
173
+ outcome: args.outcome as string,
174
+ caused_by: args.caused_by as string | undefined,
175
+ });
176
+ success(id, {
177
+ content: [
178
+ {
179
+ type: 'text',
180
+ text: JSON.stringify(result, null, 2),
181
+ },
182
+ ],
183
+ });
184
+ return;
185
+ }
186
+
187
+ if (toolName === 'marrow_status') {
188
+ const result = await marrowStatus(API_KEY, BASE_URL);
189
+ success(id, {
190
+ content: [
191
+ {
192
+ type: 'text',
193
+ text: JSON.stringify(result, null, 2),
194
+ },
195
+ ],
196
+ });
197
+ return;
198
+ }
199
+
200
+ error(id, -32601, `Unknown tool: ${toolName}`);
201
+ return;
202
+ }
203
+
204
+ // Unknown method
205
+ error(id, -32601, `Method not found: ${method}`);
206
+ } catch (err) {
207
+ const message = err instanceof Error ? err.message : String(err);
208
+ error(id, -32603, `Internal error: ${message}`);
209
+ }
210
+ }
211
+
212
+ // stdio server
213
+ const rl = readline.createInterface({
214
+ input: process.stdin,
215
+ output: process.stdout,
216
+ terminal: false,
217
+ });
218
+
219
+ rl.on('line', (line) => {
220
+ const trimmed = line.trim();
221
+ if (!trimmed) return;
222
+
223
+ try {
224
+ const req = JSON.parse(trimmed) as MCPRequest;
225
+ handleRequest(req).catch((err) => {
226
+ process.stderr.write(`Unhandled error: ${err}\n`);
227
+ });
228
+ } catch {
229
+ process.stderr.write(`Failed to parse request: ${trimmed}\n`);
230
+ }
231
+ });
232
+
233
+ rl.on('close', () => {
234
+ process.exit(0);
235
+ });
package/src/index.ts ADDED
@@ -0,0 +1,103 @@
1
+ export interface MarrowIntelligence {
2
+ similar: Array<{ outcome: string; confidence: number }>;
3
+ patterns: Array<{ pattern: string; frequency: number }>;
4
+ templates: Array<{ steps: unknown[]; success_rate: number }>;
5
+ shared: Array<{ outcome: string }>;
6
+ causal_chain: unknown | null;
7
+ success_rate: number;
8
+ priority_score: number;
9
+ }
10
+
11
+ export interface ThinkResult {
12
+ decision_id: string;
13
+ intelligence: MarrowIntelligence;
14
+ stream_url: string;
15
+ previous_committed?: boolean;
16
+ }
17
+
18
+ export interface CommitResult {
19
+ committed: boolean;
20
+ success_rate: number;
21
+ insight: string | null;
22
+ }
23
+
24
+ export interface StatusResult {
25
+ status: string;
26
+ version: string;
27
+ tiers: number;
28
+ uptime_ms: number;
29
+ }
30
+
31
+ export async function marrowThink(
32
+ apiKey: string,
33
+ baseUrl: string,
34
+ params: {
35
+ action: string;
36
+ type?: string;
37
+ context?: Record<string, unknown>;
38
+ previous_decision_id?: string;
39
+ previous_success?: boolean;
40
+ previous_outcome?: string;
41
+ }
42
+ ): Promise<ThinkResult> {
43
+ const body: Record<string, unknown> = {
44
+ action: params.action,
45
+ type: params.type || 'general',
46
+ };
47
+ if (params.context) body.context = params.context;
48
+ if (params.previous_decision_id) {
49
+ body.previous_decision_id = params.previous_decision_id;
50
+ body.previous_success = params.previous_success ?? true;
51
+ body.previous_outcome = params.previous_outcome ?? '';
52
+ }
53
+
54
+ const res = await fetch(`${baseUrl}/v1/agent/think`, {
55
+ method: 'POST',
56
+ headers: {
57
+ 'Authorization': `Bearer ${apiKey}`,
58
+ 'Content-Type': 'application/json',
59
+ },
60
+ body: JSON.stringify(body),
61
+ });
62
+
63
+ const json = await res.json() as { data: ThinkResult; error?: string };
64
+ if (json.error) throw new Error(json.error);
65
+ return json.data;
66
+ }
67
+
68
+ export async function marrowCommit(
69
+ apiKey: string,
70
+ baseUrl: string,
71
+ params: {
72
+ decision_id: string;
73
+ success: boolean;
74
+ outcome: string;
75
+ caused_by?: string;
76
+ }
77
+ ): Promise<CommitResult> {
78
+ const res = await fetch(`${baseUrl}/v1/agent/commit`, {
79
+ method: 'POST',
80
+ headers: {
81
+ 'Authorization': `Bearer ${apiKey}`,
82
+ 'Content-Type': 'application/json',
83
+ },
84
+ body: JSON.stringify(params),
85
+ });
86
+
87
+ const json = await res.json() as { data: CommitResult; error?: string };
88
+ if (json.error) throw new Error(json.error);
89
+ return json.data;
90
+ }
91
+
92
+ export async function marrowStatus(
93
+ apiKey: string,
94
+ baseUrl: string
95
+ ): Promise<StatusResult> {
96
+ const res = await fetch(`${baseUrl}/v1/health`, {
97
+ headers: { 'Authorization': `Bearer ${apiKey}` },
98
+ });
99
+
100
+ const json = await res.json() as { data: StatusResult; error?: string };
101
+ if (json.error) throw new Error(json.error);
102
+ return json.data;
103
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,18 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2020",
4
+ "module": "commonjs",
5
+ "lib": ["ES2020"],
6
+ "declaration": true,
7
+ "declarationMap": true,
8
+ "sourceMap": true,
9
+ "outDir": "./dist",
10
+ "rootDir": "./src",
11
+ "strict": true,
12
+ "esModuleInterop": true,
13
+ "skipLibCheck": true,
14
+ "forceConsistentCasingInFileNames": true
15
+ },
16
+ "include": ["src/**/*"],
17
+ "exclude": ["node_modules", "dist"]
18
+ }