mindgraph-mcp 0.3.4 → 0.4.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.
Files changed (3) hide show
  1. package/dist/cli.js +352 -357
  2. package/dist/index.js +352 -357
  3. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -8,72 +8,47 @@ var import_mindgraph = require("mindgraph");
8
8
 
9
9
  // src/tools.ts
10
10
  var TOOLS = [
11
- {
12
- name: "mindgraph_journal",
13
- description: "Quick, informal capture for the user's inner world: preferences ('I prefer dark mode'), reflections ('I've been thinking about...'), moods, daily notes, and anything subjective. Use this instead of mindgraph_capture when the content is personal/informal rather than a structured fact about the external world. Good for: likes/dislikes, feelings, habits, reminders-to-self, freeform notes.",
14
- inputSchema: {
15
- type: "object",
16
- properties: {
17
- label: {
18
- type: "string",
19
- description: "Brief title for the journal entry"
20
- },
21
- content: {
22
- type: "string",
23
- description: "The journal content/body text"
24
- },
25
- mood: {
26
- type: "string",
27
- description: "Emotional tone or mood tag"
28
- },
29
- tags: {
30
- type: "array",
31
- items: { type: "string" },
32
- description: "Categorization tags"
33
- },
34
- agent_id: {
35
- type: "string",
36
- description: "Agent identity"
37
- }
38
- },
39
- required: ["label", "content"]
40
- }
41
- },
42
11
  {
43
12
  name: "mindgraph_capture",
44
- description: "Capture structured facts about the external world into the Reality layer. Use proactively whenever the user mentions a named entity. Actions: 'entity' for people/orgs/places/events/nations/concepts (auto-deduplicates \u2014 safe to call even if already exists), 'observation' for factual statements about the world, 'source' for documents/URLs/references, 'snippet' for direct quotes from a source. Prefer this over mindgraph_journal when the content is an objective fact rather than a personal note.",
13
+ description: "Capture knowledge into the graph. Use 'entity' for people/orgs/places/events/nations/concepts (auto-deduplicates \u2014 safe to call even if already exists), 'observation' for factual statements, 'source' for documents/URLs, 'snippet' for quotes from a source, 'concept' for abstract ideas. Use 'journal' for quick personal notes, preferences, reflections, moods \u2014 anything subjective or informal. Prefer 'entity'/'observation' for objective facts, 'journal' for personal notes.",
45
14
  inputSchema: {
46
15
  type: "object",
47
16
  properties: {
48
17
  action: {
49
18
  type: "string",
50
- enum: ["entity", "observation", "source", "snippet", "concept"],
51
- description: "Type of reality to capture"
19
+ enum: ["entity", "observation", "source", "snippet", "concept", "journal"],
20
+ description: "Type of knowledge to capture"
52
21
  },
53
22
  label: {
54
23
  type: "string",
55
- description: "Name or title"
24
+ description: "Name, title, or brief heading"
56
25
  },
57
26
  summary: {
58
27
  type: "string",
59
- description: "Description or summary text"
28
+ description: "Description or summary text (for entity/observation/source/snippet/concept)"
29
+ },
30
+ content: {
31
+ type: "string",
32
+ description: "Journal content/body text (for action=journal)"
60
33
  },
61
34
  entity_type: {
62
35
  type: "string",
63
- enum: [
64
- "person",
65
- "organization",
66
- "place",
67
- "event",
68
- "nation",
69
- "concept"
70
- ],
36
+ enum: ["person", "organization", "place", "event", "nation", "concept"],
71
37
  description: "Entity subtype (only for action=entity)"
72
38
  },
73
39
  source_uid: {
74
40
  type: "string",
75
41
  description: "Source node UID (for snippets)"
76
42
  },
43
+ mood: {
44
+ type: "string",
45
+ description: "Emotional tone or mood tag (for action=journal)"
46
+ },
47
+ tags: {
48
+ type: "array",
49
+ items: { type: "string" },
50
+ description: "Categorization tags (for action=journal)"
51
+ },
77
52
  confidence: {
78
53
  type: "number",
79
54
  minimum: 0,
@@ -99,11 +74,33 @@ var TOOLS = [
99
74
  }
100
75
  },
101
76
  {
102
- name: "mindgraph_argue",
103
- description: "Record a claim WITH supporting evidence. Use when the user states something as true/false and provides reasoning or sources. Creates interconnected Claim + Evidence + Warrant nodes. Set confidence based on evidence strength: 0.9+ for well-sourced facts, 0.5-0.8 for plausible claims, below 0.5 for speculation. Prefer mindgraph_inquire instead when there's a question or hypothesis WITHOUT evidence yet.",
77
+ name: "mindgraph_reason",
78
+ description: "Record reasoning, claims, and open questions. Use 'claim' when the user states something as true/false with reasoning \u2014 creates interconnected Claim + Evidence + Warrant nodes. Set confidence by evidence: 0.9+ for well-sourced, 0.5-0.8 for plausible, <0.5 for speculation. Use 'open_question' for questions worth tracking, 'hypothesis' for testable predictions, 'theory' for explanatory frameworks, 'anomaly' for things that don't fit, 'assumption' for unstated beliefs. Prefer 'claim' when evidence exists, other actions when it doesn't yet.",
104
79
  inputSchema: {
105
80
  type: "object",
106
81
  properties: {
82
+ action: {
83
+ type: "string",
84
+ enum: [
85
+ "claim",
86
+ "question",
87
+ "open_question",
88
+ "hypothesis",
89
+ "theory",
90
+ "paradigm",
91
+ "anomaly",
92
+ "assumption"
93
+ ],
94
+ description: "Type of reasoning to record"
95
+ },
96
+ label: {
97
+ type: "string",
98
+ description: "The claim, question, or hypothesis statement (used for non-claim actions, or as fallback for claim if claim object omitted)"
99
+ },
100
+ summary: {
101
+ type: "string",
102
+ description: "Expanded description or context (for non-claim actions)"
103
+ },
107
104
  claim: {
108
105
  type: "object",
109
106
  properties: {
@@ -117,7 +114,7 @@ var TOOLS = [
117
114
  }
118
115
  },
119
116
  required: ["label"],
120
- description: "The central claim being argued"
117
+ description: "The central claim being argued (for action=claim)"
121
118
  },
122
119
  evidence: {
123
120
  type: "array",
@@ -129,7 +126,7 @@ var TOOLS = [
129
126
  },
130
127
  required: ["label"]
131
128
  },
132
- description: "Supporting evidence items"
129
+ description: "Supporting evidence items (for action=claim)"
133
130
  },
134
131
  warrant: {
135
132
  type: "object",
@@ -137,61 +134,26 @@ var TOOLS = [
137
134
  label: { type: "string" },
138
135
  content: { type: "string" }
139
136
  },
140
- description: "Logical warrant connecting evidence to claim"
137
+ description: "Logical warrant connecting evidence to claim (for action=claim)"
141
138
  },
142
139
  argument: {
143
140
  type: "object",
144
141
  properties: {
145
142
  label: { type: "string" }
146
143
  },
147
- description: "Top-level argument container"
148
- },
149
- agent_id: {
150
- type: "string",
151
- description: "Agent identity"
152
- }
153
- },
154
- required: ["claim"]
155
- }
156
- },
157
- {
158
- name: "mindgraph_inquire",
159
- description: "Record things that need investigation or are uncertain. Use 'open_question' when the user asks something worth tracking ('How does X work?'), 'hypothesis' for testable predictions, 'theory' for explanatory frameworks, 'anomaly' for things that don't fit existing understanding, 'assumption' for unstated beliefs worth surfacing. These stay in the graph as open items until resolved. Prefer mindgraph_argue instead when there IS evidence to attach.",
160
- inputSchema: {
161
- type: "object",
162
- properties: {
163
- action: {
164
- type: "string",
165
- enum: [
166
- "question",
167
- "open_question",
168
- "hypothesis",
169
- "theory",
170
- "paradigm",
171
- "anomaly",
172
- "assumption"
173
- ],
174
- description: "Type of epistemic inquiry"
175
- },
176
- label: {
177
- type: "string",
178
- description: "The question, hypothesis, or theory statement"
179
- },
180
- summary: {
181
- type: "string",
182
- description: "Expanded description or context"
144
+ description: "Top-level argument container (for action=claim)"
183
145
  },
184
146
  confidence: {
185
147
  type: "number",
186
148
  minimum: 0,
187
149
  maximum: 1,
188
- description: "Confidence level (0-1)"
150
+ description: "Confidence level (for non-claim actions)"
189
151
  },
190
152
  salience: {
191
153
  type: "number",
192
154
  minimum: 0,
193
155
  maximum: 1,
194
- description: "Importance score (0-1)"
156
+ description: "Importance score (for non-claim actions)"
195
157
  },
196
158
  props: {
197
159
  type: "object",
@@ -202,31 +164,48 @@ var TOOLS = [
202
164
  description: "Agent identity"
203
165
  }
204
166
  },
205
- required: ["action", "label"]
167
+ required: ["action"]
206
168
  }
207
169
  },
208
170
  {
209
171
  name: "mindgraph_commit",
210
- description: "Track the user's goals, projects, and milestones. Use 'goal' when the user expresses a desired outcome ('I want to learn Rust'), 'project' for organized efforts ('my blog redesign'), 'milestone' for checkpoints ('launch MVP by March'). Link milestones to projects and projects to goals via parent_uid. These appear in daily briefings and active goals queries.",
172
+ description: "Track goals, projects, milestones, and decisions. Use 'goal' for desired outcomes ('I want to learn Rust'), 'project' for organized efforts, 'milestone' for checkpoints. Link milestones to projects and projects to goals via parent_uid. Use 'open_decision' when facing a choice ('Postgres vs SQLite?'), 'add_option'/'add_constraint' to build out alternatives, 'resolve_decision' to pick one, 'get_open_decisions' to review pending choices.",
211
173
  inputSchema: {
212
174
  type: "object",
213
175
  properties: {
214
176
  action: {
215
177
  type: "string",
216
- enum: ["goal", "project", "milestone"],
217
- description: "Type of commitment"
178
+ enum: [
179
+ "goal",
180
+ "project",
181
+ "milestone",
182
+ "open_decision",
183
+ "add_option",
184
+ "add_constraint",
185
+ "resolve_decision",
186
+ "get_open_decisions"
187
+ ],
188
+ description: "Commitment or decision action"
218
189
  },
219
190
  label: {
220
191
  type: "string",
221
- description: "Name of the goal, project, or milestone"
192
+ description: "Name of the goal, project, milestone, decision, option, or constraint"
222
193
  },
223
194
  summary: {
224
195
  type: "string",
225
- description: "Description and success criteria"
196
+ description: "Description, success criteria, or rationale"
226
197
  },
227
198
  parent_uid: {
228
199
  type: "string",
229
- description: "Parent goal/project UID to link under"
200
+ description: "Parent goal/project UID to link under (for goal/project/milestone)"
201
+ },
202
+ decision_uid: {
203
+ type: "string",
204
+ description: "Decision UID (for add_option, add_constraint, resolve_decision)"
205
+ },
206
+ chosen_option_uid: {
207
+ type: "string",
208
+ description: "UID of the chosen option (for resolve_decision)"
230
209
  },
231
210
  confidence: {
232
211
  type: "number",
@@ -247,93 +226,12 @@ var TOOLS = [
247
226
  description: "Agent identity"
248
227
  }
249
228
  },
250
- required: ["action", "label"]
251
- }
252
- },
253
- {
254
- name: "mindgraph_decide",
255
- description: "Track decisions through their lifecycle. Use 'open_decision' when the user faces a choice ('Should I use Postgres or SQLite?'), 'add_option' to record each alternative, 'add_constraint' for requirements or dealbreakers, 'resolve' when a choice is made. Use 'get_open' to review pending decisions. This creates a structured decision record that can be referenced later.",
256
- inputSchema: {
257
- type: "object",
258
- properties: {
259
- action: {
260
- type: "string",
261
- enum: ["open_decision", "add_option", "add_constraint", "resolve", "get_open"],
262
- description: "Decision lifecycle action"
263
- },
264
- label: {
265
- type: "string",
266
- description: "Decision, option, or constraint label"
267
- },
268
- summary: {
269
- type: "string",
270
- description: "Description or rationale"
271
- },
272
- decision_uid: {
273
- type: "string",
274
- description: "Decision UID (for add_option, add_constraint, resolve)"
275
- },
276
- chosen_option_uid: {
277
- type: "string",
278
- description: "UID of the chosen option (for resolve)"
279
- },
280
- props: {
281
- type: "object",
282
- description: "Additional properties"
283
- },
284
- agent_id: {
285
- type: "string",
286
- description: "Agent identity"
287
- }
288
- },
289
- required: ["action"]
290
- }
291
- },
292
- {
293
- name: "mindgraph_action",
294
- description: "Record procedural knowledge and risk assessments. Use 'create_flow' for workflows/processes, 'add_step' for individual steps in a flow, 'add_affordance' for capabilities ('this API supports batch operations'), 'add_control' for guardrails/constraints. Use 'assess_risk' when the user identifies a risk or potential problem. Less commonly used than capture/argue/commit \u2014 reach for this when the conversation is about HOW to do something.",
295
- inputSchema: {
296
- type: "object",
297
- properties: {
298
- action: {
299
- type: "string",
300
- enum: [
301
- "create_flow",
302
- "add_step",
303
- "add_affordance",
304
- "add_control",
305
- "assess_risk",
306
- "get_assessments"
307
- ],
308
- description: "Action layer operation"
309
- },
310
- label: {
311
- type: "string",
312
- description: "Flow, step, affordance, control, or risk label"
313
- },
314
- summary: {
315
- type: "string",
316
- description: "Description"
317
- },
318
- target_uid: {
319
- type: "string",
320
- description: "Parent flow/step UID or target node for risk assessment"
321
- },
322
- props: {
323
- type: "object",
324
- description: "Type-specific properties (e.g. likelihood, impact, mitigation for risks)"
325
- },
326
- agent_id: {
327
- type: "string",
328
- description: "Agent identity"
329
- }
330
- },
331
229
  required: ["action"]
332
230
  }
333
231
  },
334
232
  {
335
233
  name: "mindgraph_plan",
336
- description: "Agent-level task management and governance. Use 'create_plan'/'create_task'/'add_step' for breaking down work into trackable items, 'update_status' to mark progress, 'start_execution'/'complete_execution'/'fail_execution' for execution tracking. Use 'create_policy' and 'request_approval' for governance workflows. Prefer mindgraph_commit for the user's goals/projects; use mindgraph_plan for agent-managed task breakdowns and execution.",
234
+ description: "Agent-level task management, governance, and procedural knowledge. Use 'create_plan'/'create_task'/'add_step' for task breakdowns, 'update_status' for progress, 'get_plan' to review. Use 'create_flow'/'add_procedure_step'/'add_affordance'/'add_control' for workflows and procedures. Use 'assess_risk'/'get_assessments' for risk analysis. Use 'create_policy'/'request_approval'/'resolve_approval'/'get_pending' for governance. Prefer mindgraph_commit for user goals/projects; use this for agent-managed execution.",
337
235
  inputSchema: {
338
236
  type: "object",
339
237
  properties: {
@@ -351,13 +249,19 @@ var TOOLS = [
351
249
  "create_policy",
352
250
  "request_approval",
353
251
  "resolve_approval",
354
- "get_pending"
252
+ "get_pending",
253
+ "create_flow",
254
+ "add_procedure_step",
255
+ "add_affordance",
256
+ "add_control",
257
+ "assess_risk",
258
+ "get_assessments"
355
259
  ],
356
- description: "Agent layer operation"
260
+ description: "Planning, procedure, or governance action"
357
261
  },
358
262
  label: {
359
263
  type: "string",
360
- description: "Task, plan, step, or policy label"
264
+ description: "Task, plan, step, flow, policy, or risk label"
361
265
  },
362
266
  summary: {
363
267
  type: "string",
@@ -369,7 +273,11 @@ var TOOLS = [
369
273
  },
370
274
  task_uid: {
371
275
  type: "string",
372
- description: "Task/step UID (for update_status, execution actions)"
276
+ description: "Task/step UID (for update_status, execution actions, resolve_approval)"
277
+ },
278
+ target_uid: {
279
+ type: "string",
280
+ description: "Parent flow/step UID or target node (for procedure/risk actions)"
373
281
  },
374
282
  status: {
375
283
  type: "string",
@@ -377,7 +285,7 @@ var TOOLS = [
377
285
  },
378
286
  props: {
379
287
  type: "object",
380
- description: "Additional properties"
288
+ description: "Additional properties (e.g. likelihood, impact, mitigation for risks)"
381
289
  },
382
290
  agent_id: {
383
291
  type: "string",
@@ -389,7 +297,7 @@ var TOOLS = [
389
297
  },
390
298
  {
391
299
  name: "mindgraph_retrieve",
392
- description: "Search the knowledge graph using BM25 keyword matching. Primary action: 'context' \u2014 pass 1\u20133 discriminating keywords (proper nouns, technical terms) extracted from the user's question. Drop filler words (what, how, tell me about, implications of). GOOD: 'Kissinger NATO', 'Rust async runtime'. BAD: 'What is Kissinger\\'s view on NATO?'. Use 'text' for fast keyword-only lookup. Other actions ('active_goals', 'open_questions', 'weak_claims', 'pending_approvals', 'unresolved_contradictions', 'layer', 'recent') are ONLY for when the user explicitly asks about those topics \u2014 never pre-fetch them.",
300
+ description: "Search and explore the knowledge graph. Use 'context' (default) for BM25 keyword retrieval \u2014 pass 1-3 discriminating keywords (proper nouns, technical terms), not sentences. GOOD: 'Kissinger NATO'. BAD: 'What is Kissinger\\'s view on NATO?'. Use 'semantic' when keywords return nothing \u2014 good for conceptual/fuzzy queries where user words differ from stored labels. Use 'hybrid' to combine keyword + semantic. Use 'text' for fast keyword-only lookup. Use 'neighborhood' to explore around a known node, 'chain' for reasoning chains, 'path' between two nodes, 'subgraph' for connected components. Other actions ('active_goals', 'open_questions', etc.) only when the user explicitly asks.",
393
301
  inputSchema: {
394
302
  type: "object",
395
303
  properties: {
@@ -398,19 +306,47 @@ var TOOLS = [
398
306
  enum: [
399
307
  "text",
400
308
  "context",
309
+ "semantic",
310
+ "hybrid",
401
311
  "active_goals",
402
312
  "open_questions",
403
313
  "weak_claims",
404
314
  "pending_approvals",
405
315
  "unresolved_contradictions",
406
316
  "layer",
407
- "recent"
317
+ "recent",
318
+ "chain",
319
+ "neighborhood",
320
+ "path",
321
+ "subgraph"
408
322
  ],
409
- description: "Retrieval strategy"
323
+ description: "Retrieval or traversal strategy"
410
324
  },
411
325
  query: {
412
326
  type: "string",
413
- description: "BM25 keyword query \u2014 extract 1\u20133 discriminating terms from the user's question, drop filler words. User asks 'What is Kissinger's view on NATO?' \u2192 'Kissinger NATO'. User asks about async in Rust \u2192 'Rust async runtime'. NEVER pass natural language sentences. (for text, context)"
327
+ description: "Search query \u2014 for 'text'/'context': 1-3 BM25 keywords, drop filler words. For 'semantic'/'hybrid': natural language is OK since it uses vector similarity."
328
+ },
329
+ start_uid: {
330
+ type: "string",
331
+ description: "Starting node UID (for chain, neighborhood, path, subgraph)"
332
+ },
333
+ end_uid: {
334
+ type: "string",
335
+ description: "Target node UID (for path)"
336
+ },
337
+ max_depth: {
338
+ type: "number",
339
+ description: "Maximum traversal depth (for chain, neighborhood, path, subgraph)"
340
+ },
341
+ direction: {
342
+ type: "string",
343
+ enum: ["outgoing", "incoming", "both"],
344
+ description: "Traversal direction (for neighborhood, subgraph)"
345
+ },
346
+ edge_types: {
347
+ type: "array",
348
+ items: { type: "string" },
349
+ description: "Filter by edge types (for traversal actions)"
414
350
  },
415
351
  node_types: {
416
352
  type: "array",
@@ -419,15 +355,8 @@ var TOOLS = [
419
355
  },
420
356
  layer: {
421
357
  type: "string",
422
- enum: [
423
- "reality",
424
- "epistemic",
425
- "intent",
426
- "action",
427
- "memory",
428
- "agent"
429
- ],
430
- description: "Filter by cognitive layer (for context, text, layer actions)"
358
+ enum: ["reality", "epistemic", "intent", "action", "memory", "agent"],
359
+ description: "Filter by cognitive layer"
431
360
  },
432
361
  limit: {
433
362
  type: "number",
@@ -534,20 +463,12 @@ function err(message) {
534
463
  async function handleTool(client2, name, args) {
535
464
  try {
536
465
  switch (name) {
537
- case "mindgraph_journal":
538
- return await handleJournal(client2, args);
539
466
  case "mindgraph_capture":
540
467
  return await handleCapture(client2, args);
541
- case "mindgraph_argue":
542
- return await handleArgue(client2, args);
543
- case "mindgraph_inquire":
544
- return await handleInquire(client2, args);
468
+ case "mindgraph_reason":
469
+ return await handleReason(client2, args);
545
470
  case "mindgraph_commit":
546
471
  return await handleCommit(client2, args);
547
- case "mindgraph_decide":
548
- return await handleDecide(client2, args);
549
- case "mindgraph_action":
550
- return await handleAction(client2, args);
551
472
  case "mindgraph_plan":
552
473
  return await handlePlan(client2, args);
553
474
  case "mindgraph_retrieve":
@@ -562,31 +483,29 @@ async function handleTool(client2, name, args) {
562
483
  return err(message);
563
484
  }
564
485
  }
565
- async function handleJournal(client2, args) {
566
- const { label, content, mood, tags, agent_id } = args;
567
- const props = { content };
568
- if (mood) props.mood = mood;
569
- if (tags) props.tags = tags;
570
- const result = await client2.journal(
571
- label,
572
- props,
573
- { agent_id }
574
- );
575
- return ok(result);
576
- }
577
486
  async function handleCapture(client2, args) {
578
487
  const {
579
488
  action,
580
489
  label,
581
490
  summary,
491
+ content,
582
492
  entity_type,
583
493
  source_uid,
494
+ mood,
495
+ tags,
584
496
  confidence,
585
497
  salience,
586
498
  props,
587
499
  agent_id
588
500
  } = args;
589
501
  switch (action) {
502
+ case "journal": {
503
+ if (!content) return err("content is required for action=journal");
504
+ const journalProps = { content };
505
+ if (mood) journalProps.mood = mood;
506
+ if (tags) journalProps.tags = tags;
507
+ return ok(await client2.journal(label, journalProps, { agent_id }));
508
+ }
590
509
  case "entity": {
591
510
  const type = entity_type || "concept";
592
511
  const entityProps = { ...props };
@@ -660,58 +579,85 @@ async function handleCapture(client2, args) {
660
579
  return err(`Unknown capture action: ${action}`);
661
580
  }
662
581
  }
663
- async function handleArgue(client2, args) {
664
- const { claim, evidence, warrant, argument, agent_id } = args;
665
- const result = await client2.argue({
582
+ async function handleReason(client2, args) {
583
+ const {
584
+ action,
585
+ label,
586
+ summary,
666
587
  claim,
667
588
  evidence,
668
589
  warrant,
669
590
  argument,
670
- agent_id
671
- });
672
- return ok(result);
673
- }
674
- async function handleInquire(client2, args) {
675
- const { action, label, summary, confidence, salience, props, agent_id } = args;
676
- const result = await client2.inquire({
677
- action,
678
- label,
679
- summary,
680
591
  confidence,
681
592
  salience,
682
593
  props,
683
594
  agent_id
684
- });
685
- return ok(result);
595
+ } = args;
596
+ if (action === "claim") {
597
+ const claimObj = claim || (label ? { label, confidence } : null);
598
+ if (!claimObj) return err("claim object or label is required for action=claim");
599
+ return ok(
600
+ await client2.argue({
601
+ claim: claimObj,
602
+ evidence,
603
+ warrant,
604
+ argument,
605
+ agent_id
606
+ })
607
+ );
608
+ }
609
+ if (!label) return err(`label is required for action=${action}`);
610
+ return ok(
611
+ await client2.inquire({
612
+ action,
613
+ label,
614
+ summary,
615
+ confidence,
616
+ salience,
617
+ props,
618
+ agent_id
619
+ })
620
+ );
686
621
  }
687
622
  async function handleCommit(client2, args) {
688
- const { action, label, summary, parent_uid, confidence, salience, props, agent_id } = args;
689
- const result = await client2.commit({
623
+ const {
690
624
  action,
691
625
  label,
692
626
  summary,
693
627
  parent_uid,
628
+ decision_uid,
629
+ chosen_option_uid,
694
630
  confidence,
695
631
  salience,
696
632
  props,
697
633
  agent_id
698
- });
699
- return ok(result);
700
- }
701
- async function handleDecide(client2, args) {
702
- const { action, label, summary, decision_uid, chosen_option_uid, props, agent_id } = args;
634
+ } = args;
703
635
  switch (action) {
636
+ case "goal":
637
+ case "project":
638
+ case "milestone":
639
+ if (!label) return err(`label is required for action=${action}`);
640
+ return ok(
641
+ await client2.commit({
642
+ action,
643
+ label,
644
+ summary,
645
+ parent_uid,
646
+ confidence,
647
+ salience,
648
+ props,
649
+ agent_id
650
+ })
651
+ );
704
652
  case "open_decision":
705
653
  if (!label) return err("label is required for open_decision");
706
654
  return ok(await client2.openDecision(label, { summary, props, agent_id }));
707
655
  case "add_option":
708
- if (!decision_uid) return err("decision_uid is required");
656
+ if (!decision_uid) return err("decision_uid is required for add_option");
709
657
  if (!label) return err("label is required for add_option");
710
- return ok(
711
- await client2.addOption(decision_uid, label, { summary, props, agent_id })
712
- );
658
+ return ok(await client2.addOption(decision_uid, label, { summary, props, agent_id }));
713
659
  case "add_constraint":
714
- if (!decision_uid) return err("decision_uid is required");
660
+ if (!decision_uid) return err("decision_uid is required for add_constraint");
715
661
  return ok(
716
662
  await client2.deliberate({
717
663
  action: "add_constraint",
@@ -722,64 +668,35 @@ async function handleDecide(client2, args) {
722
668
  agent_id
723
669
  })
724
670
  );
725
- case "resolve":
726
- if (!decision_uid) return err("decision_uid is required");
727
- if (!chosen_option_uid) return err("chosen_option_uid is required");
671
+ case "resolve_decision":
672
+ if (!decision_uid) return err("decision_uid is required for resolve_decision");
673
+ if (!chosen_option_uid) return err("chosen_option_uid is required for resolve_decision");
728
674
  return ok(
729
675
  await client2.resolveDecision(decision_uid, chosen_option_uid, {
730
676
  summary,
731
677
  agent_id
732
678
  })
733
679
  );
734
- case "get_open":
680
+ case "get_open_decisions":
735
681
  return ok(await client2.getOpenDecisions());
736
682
  default:
737
- return err(`Unknown decide action: ${action}`);
738
- }
739
- }
740
- async function handleAction(client2, args) {
741
- const { action, label, summary, target_uid, props, agent_id } = args;
742
- switch (action) {
743
- case "create_flow":
744
- case "add_step":
745
- case "add_affordance":
746
- case "add_control":
747
- return ok(
748
- await client2.procedure({
749
- action,
750
- label,
751
- summary,
752
- target_uid,
753
- props,
754
- agent_id
755
- })
756
- );
757
- case "assess_risk":
758
- return ok(
759
- await client2.risk({
760
- action: "assess",
761
- label,
762
- summary,
763
- target_uid,
764
- props,
765
- agent_id
766
- })
767
- );
768
- case "get_assessments":
769
- return ok(
770
- await client2.risk({
771
- action: "get_assessments",
772
- target_uid,
773
- agent_id
774
- })
775
- );
776
- default:
777
- return err(`Unknown action: ${action}`);
683
+ return err(`Unknown commit action: ${action}`);
778
684
  }
779
685
  }
780
686
  async function handlePlan(client2, args) {
781
- const { action, label, summary, plan_uid, task_uid, status, props, agent_id } = args;
687
+ const {
688
+ action,
689
+ label,
690
+ summary,
691
+ plan_uid,
692
+ task_uid,
693
+ target_uid,
694
+ status,
695
+ props,
696
+ agent_id
697
+ } = args;
782
698
  switch (action) {
699
+ // Agent planning
783
700
  case "create_task":
784
701
  case "create_plan":
785
702
  case "add_step":
@@ -797,63 +714,70 @@ async function handlePlan(client2, args) {
797
714
  agent_id
798
715
  })
799
716
  );
717
+ // Execution tracking
800
718
  case "start_execution":
719
+ return ok(await client2.execution({ action: "start", task_uid, agent_id }));
720
+ case "complete_execution":
721
+ return ok(await client2.execution({ action: "complete", task_uid, agent_id }));
722
+ case "fail_execution":
723
+ return ok(await client2.execution({ action: "fail", task_uid, agent_id }));
724
+ // Governance
725
+ case "create_policy":
801
726
  return ok(
802
- await client2.execution({
803
- action: "start",
804
- task_uid,
805
- agent_id
806
- })
727
+ await client2.governance({ action: "create_policy", label, summary, props, agent_id })
807
728
  );
808
- case "complete_execution":
729
+ case "request_approval":
809
730
  return ok(
810
- await client2.execution({
811
- action: "complete",
812
- task_uid,
813
- agent_id
814
- })
731
+ await client2.governance({ action: "request_approval", label, summary, props, agent_id })
815
732
  );
816
- case "fail_execution":
733
+ case "resolve_approval":
817
734
  return ok(
818
- await client2.execution({
819
- action: "fail",
820
- task_uid,
821
- agent_id
822
- })
735
+ await client2.governance({ action: "resolve_approval", task_uid, props, agent_id })
823
736
  );
824
- case "create_policy":
737
+ case "get_pending":
738
+ return ok(await client2.governance({ action: "get_pending", agent_id }));
739
+ // Procedures (merged from mindgraph_action)
740
+ case "create_flow":
741
+ case "add_affordance":
742
+ case "add_control":
825
743
  return ok(
826
- await client2.governance({
827
- action: "create_policy",
744
+ await client2.procedure({
745
+ action,
828
746
  label,
829
747
  summary,
748
+ target_uid,
830
749
  props,
831
750
  agent_id
832
751
  })
833
752
  );
834
- case "request_approval":
753
+ case "add_procedure_step":
835
754
  return ok(
836
- await client2.governance({
837
- action: "request_approval",
755
+ await client2.procedure({
756
+ action: "add_step",
838
757
  label,
839
758
  summary,
759
+ target_uid,
840
760
  props,
841
761
  agent_id
842
762
  })
843
763
  );
844
- case "resolve_approval":
764
+ // Risk assessment (merged from mindgraph_action)
765
+ case "assess_risk":
845
766
  return ok(
846
- await client2.governance({
847
- action: "resolve_approval",
848
- task_uid,
767
+ await client2.risk({
768
+ action: "assess",
769
+ label,
770
+ summary,
771
+ target_uid,
849
772
  props,
850
773
  agent_id
851
774
  })
852
775
  );
853
- case "get_pending":
776
+ case "get_assessments":
854
777
  return ok(
855
- await client2.governance({
856
- action: "get_pending",
778
+ await client2.risk({
779
+ action: "get_assessments",
780
+ target_uid,
857
781
  agent_id
858
782
  })
859
783
  );
@@ -865,6 +789,11 @@ async function handleRetrieve(client2, args) {
865
789
  const {
866
790
  action,
867
791
  query,
792
+ start_uid,
793
+ end_uid,
794
+ max_depth,
795
+ direction,
796
+ edge_types,
868
797
  node_types,
869
798
  layer,
870
799
  limit,
@@ -899,6 +828,31 @@ async function handleRetrieve(client2, args) {
899
828
  agent_id
900
829
  })
901
830
  );
831
+ case "semantic":
832
+ if (!query) return err("query is required for semantic search");
833
+ return ok(
834
+ await client2.retrieve({
835
+ action: "semantic",
836
+ query,
837
+ k: limit,
838
+ node_types,
839
+ layer,
840
+ agent_id
841
+ })
842
+ );
843
+ case "hybrid":
844
+ if (!query) return err("query is required for hybrid search");
845
+ return ok(
846
+ await client2.retrieve({
847
+ action: "hybrid",
848
+ query,
849
+ k: limit,
850
+ node_types,
851
+ layer,
852
+ agent_id
853
+ })
854
+ );
855
+ // Structured queries
902
856
  case "active_goals":
903
857
  return ok(await client2.getGoals());
904
858
  case "open_questions":
@@ -930,6 +884,51 @@ async function handleRetrieve(client2, args) {
930
884
  agent_id
931
885
  })
932
886
  );
887
+ // Graph traversal
888
+ case "chain":
889
+ if (!start_uid) return err("start_uid is required for chain traversal");
890
+ return ok(
891
+ await client2.traverse({
892
+ action: "chain",
893
+ start_uid,
894
+ max_depth
895
+ })
896
+ );
897
+ case "neighborhood":
898
+ if (!start_uid) return err("start_uid is required for neighborhood traversal");
899
+ return ok(
900
+ await client2.traverse({
901
+ action: "neighborhood",
902
+ start_uid,
903
+ max_depth,
904
+ direction,
905
+ edge_types
906
+ })
907
+ );
908
+ case "path":
909
+ if (!start_uid) return err("start_uid is required for path traversal");
910
+ if (!end_uid) return err("end_uid is required for path traversal");
911
+ return ok(
912
+ await client2.traverse({
913
+ action: "path",
914
+ start_uid,
915
+ end_uid,
916
+ max_depth,
917
+ direction,
918
+ edge_types
919
+ })
920
+ );
921
+ case "subgraph":
922
+ if (!start_uid) return err("start_uid is required for subgraph traversal");
923
+ return ok(
924
+ await client2.traverse({
925
+ action: "subgraph",
926
+ start_uid,
927
+ max_depth,
928
+ direction,
929
+ edge_types
930
+ })
931
+ );
933
932
  default:
934
933
  return err(`Unknown retrieve action: ${action}`);
935
934
  }
@@ -996,72 +995,70 @@ var client = new import_mindgraph.MindGraph({
996
995
  baseUrl: BASE_URL,
997
996
  apiKey: API_KEY
998
997
  });
999
- var INSTRUCTIONS = `You have access to a persistent knowledge graph via MindGraph.
998
+ var INSTRUCTIONS = `You have access to a persistent knowledge graph via MindGraph (6 tools).
1000
999
 
1001
1000
  ## #1 RULE: Go straight to the user's topic
1002
1001
 
1003
1002
  When the user asks about something, your FIRST and ONLY action should be a SINGLE \`mindgraph_retrieve\` call with action "context" and keyword terms from their message. Nothing else first.
1004
1003
 
1005
1004
  **NEVER do any of these before addressing the user's topic:**
1006
- - Do NOT retrieve active_goals
1007
- - Do NOT retrieve open_questions
1008
- - Do NOT retrieve contradictions or weak_claims
1005
+ - Do NOT retrieve active_goals, open_questions, contradictions, or weak_claims
1009
1006
  - Do NOT follow a "session lifecycle" or "warm-up" sequence
1010
1007
  - Do NOT make multiple serial retrieve calls when one "context" call covers it
1011
1008
 
1012
1009
  There is no session to open. There is no context to pre-load. Just search for what the user asked about.
1013
1010
 
1014
1011
  **Example:** User says "Tell me about Indian philosophy and Taoism"
1015
- \u2713 CORRECT: \`mindgraph_retrieve({action: "context", query: "Indian philosophy Taoism"})\` \u2014 extracted key nouns, dropped "Tell me about"
1016
- \u2717 WRONG: First retrieve active_goals, then open_questions, then search for the topic
1017
- \u2717 WRONG: \`mindgraph_retrieve({action: "context", query: "Tell me about Indian philosophy and Taoism"})\` \u2014 natural language sentence won't match BM25 index
1012
+ \u2713 CORRECT: \`mindgraph_retrieve({action: "context", query: "Indian philosophy Taoism"})\`
1013
+ \u2717 WRONG: First retrieve active_goals, then open_questions, then search
1014
+ \u2717 WRONG: \`mindgraph_retrieve({action: "context", query: "Tell me about Indian philosophy and Taoism"})\` \u2014 natural language won't match BM25
1018
1015
 
1019
- ## Search query style \u2014 BM25 keyword matching
1016
+ ## Search strategy \u2014 keyword first, semantic as fallback
1020
1017
 
1021
- The search index uses BM25 keyword matching against node labels and summaries. It matches individual words, NOT meaning or concepts. Drop filler words like "what", "how", "implications of", "tell me about". Query with 1\u20133 discriminating terms (proper nouns, technical terms, domain-specific words).
1018
+ The default search uses BM25 keyword matching. Query with 1\u20133 discriminating terms (proper nouns, technical terms). Drop filler words.
1022
1019
 
1023
- **Derive keywords from the user's question \u2014 examples:**
1024
- - User asks "What is Kissinger's view on NATO expansion?" \u2192 query: \`"Kissinger NATO"\`
1025
- - User asks "Tell me about async programming in Rust" \u2192 query: \`"Rust async runtime"\`
1026
- - User asks "How does Indian philosophy relate to Taoism?" \u2192 query: \`"Indian philosophy Taoism"\`
1027
- - User asks "What are the implications of carbon tax policy?" \u2192 query: \`"carbon tax"\`
1020
+ **Keyword examples:**
1021
+ - "What is Kissinger's view on NATO?" \u2192 query: \`"Kissinger NATO"\`
1022
+ - "Tell me about async in Rust" \u2192 query: \`"Rust async runtime"\`
1023
+ - "Implications of carbon tax?" \u2192 query: \`"carbon tax"\`
1028
1024
 
1029
- **GOOD queries:** \`"Rust async runtime"\`, \`"Kissinger NATO"\`, \`"carbon tax emissions"\`
1030
- **BAD queries:** \`"what do I know about async programming in Rust?"\`, \`"how does X relate to Y"\`, \`"implications of climate change"\`
1031
-
1032
- If the first query returns no results, try synonym or related terms (e.g. \`"global warming"\` instead of \`"climate change"\`).
1025
+ If keyword search returns no results, escalate:
1026
+ 1. Try synonyms (e.g. \`"global warming"\` instead of \`"climate change"\`)
1027
+ 2. Use \`action: "semantic"\` \u2014 vector similarity, natural language OK (e.g. \`"ways to manage stress"\` finds "mental health" nodes)
1028
+ 3. Use \`action: "hybrid"\` \u2014 combines BM25 + semantic for best coverage
1033
1029
 
1034
1030
  ## When to READ
1035
1031
 
1036
1032
  - User asks about topic X \u2192 \`mindgraph_retrieve\` action "context", query "X keywords"
1037
1033
  - User explicitly asks "what are my goals?" \u2192 action "active_goals"
1038
1034
  - User explicitly asks about open questions \u2192 action "open_questions"
1039
- - Before asserting something the user previously said \u2192 retrieve to check
1040
- - Parallelize independent calls in a single batch
1035
+ - Explore around a known node \u2192 action "neighborhood" with start_uid
1036
+ - Find connections between nodes \u2192 action "path" with start_uid + end_uid
1041
1037
 
1042
1038
  ## When to WRITE
1043
1039
 
1044
1040
  Capture knowledge when the user shares something worth remembering:
1045
1041
  - People/orgs/places/events \u2192 \`mindgraph_capture\` action "entity"
1046
- - Quick notes, preferences \u2192 \`mindgraph_journal\`
1042
+ - Quick notes, preferences \u2192 \`mindgraph_capture\` action "journal"
1047
1043
  - Factual observations \u2192 \`mindgraph_capture\` action "observation"
1048
- - Claims with evidence \u2192 \`mindgraph_argue\`
1049
- - Questions to track \u2192 \`mindgraph_inquire\` action "open_question"
1050
- - Goals or projects \u2192 \`mindgraph_commit\`
1051
- - Decisions \u2192 \`mindgraph_decide\`
1044
+ - Claims with evidence \u2192 \`mindgraph_reason\` action "claim"
1045
+ - Questions to track \u2192 \`mindgraph_reason\` action "open_question"
1046
+ - Goals or projects \u2192 \`mindgraph_commit\` action "goal"/"project"
1047
+ - Decisions \u2192 \`mindgraph_commit\` action "open_decision"
1052
1048
  - Long-form content \u2192 \`mindgraph_ingest\`
1053
1049
 
1054
1050
  ## Tool tips
1055
1051
 
1056
- - \`capture\` for structured/factual, \`journal\` for personal/informal
1057
- - \`argue\` when evidence exists, \`inquire\` for open questions
1058
- - \`text\` for fast lookup, \`context\` for rich retrieval with graph traversal
1052
+ - \`capture\`: "entity"/"observation" for facts, "journal" for personal/informal
1053
+ - \`reason\`: "claim" when evidence exists, "open_question"/"hypothesis" otherwise
1054
+ - \`retrieve\`: "context" (FTS default) \u2192 "semantic" (conceptual fallback) \u2192 "hybrid" (both)
1055
+ - \`retrieve\`: "neighborhood"/"chain"/"path"/"subgraph" for graph exploration
1059
1056
  - Confidence: 0.9+ for facts, 0.5-0.8 for uncertain, <0.5 for speculation
1060
1057
  - Don't narrate tool usage \u2014 capture naturally as part of conversation`;
1061
1058
  var server = new import_server.Server(
1062
1059
  {
1063
1060
  name: "mindgraph",
1064
- version: "0.3.4"
1061
+ version: "0.4.0"
1065
1062
  },
1066
1063
  {
1067
1064
  capabilities: {
@@ -1221,14 +1218,12 @@ server.setRequestHandler(import_types.GetPromptRequestSchema, async (request) =>
1221
1218
  content: {
1222
1219
  type: "text",
1223
1220
  text: `Analyze the following conversation and capture all important information into my knowledge graph. Extract:
1224
- - Named entities (people, organizations, places, events)
1225
- - Factual claims and observations
1226
- - Decisions made or pending
1227
- - Goals or commitments mentioned
1228
- - Open questions raised
1229
- - Any hypotheses or theories discussed
1230
-
1231
- Use the appropriate MindGraph tools for each type of knowledge.
1221
+ - Named entities (people, organizations, places, events) \u2192 mindgraph_capture action "entity"
1222
+ - Factual claims and observations \u2192 mindgraph_capture action "observation" or mindgraph_reason action "claim"
1223
+ - Decisions made or pending \u2192 mindgraph_commit action "open_decision"
1224
+ - Goals or commitments mentioned \u2192 mindgraph_commit action "goal"/"project"
1225
+ - Open questions raised \u2192 mindgraph_reason action "open_question"
1226
+ - Any hypotheses or theories discussed \u2192 mindgraph_reason action "hypothesis"/"theory"
1232
1227
 
1233
1228
  Conversation:
1234
1229
  ${conversation}`
@@ -1419,7 +1414,7 @@ async function main() {
1419
1414
  const transport = new import_stdio.StdioServerTransport();
1420
1415
  await server.connect(transport);
1421
1416
  console.error(
1422
- `MindGraph MCP server v0.3.2 running on stdio (${BASE_URL})`
1417
+ `MindGraph MCP server v0.4.0 running on stdio (${BASE_URL})`
1423
1418
  );
1424
1419
  }
1425
1420
  main().catch((error) => {