mindgraph-mcp 0.1.0 → 0.2.1

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 +334 -21
  2. package/dist/index.js +331 -18
  3. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -525,7 +525,7 @@ var init_tools = __esm({
525
525
  TOOLS = [
526
526
  {
527
527
  name: "mindgraph_session",
528
- description: "Open, trace, or close a memory session. Sessions group related interactions and enable context continuity. Open a session at the start of a conversation, trace key moments during it, and close it at the end to trigger distillation.",
528
+ description: "Manage conversation sessions. ALWAYS open a session at the start of a substantial conversation (label it with the topic). Use 'trace' to bookmark key moments (decisions made, important facts shared). Close the session at the end with a summary of what was discussed. Sessions enable the graph to track conversation continuity and trigger knowledge distillation on close.",
529
529
  inputSchema: {
530
530
  type: "object",
531
531
  properties: {
@@ -560,7 +560,7 @@ var init_tools = __esm({
560
560
  },
561
561
  {
562
562
  name: "mindgraph_journal",
563
- description: "Low-friction capture of observations, notes, preferences, and reflections. Creates a Journal node in the Memory layer. Use this for quick thoughts, user preferences, mood tracking, and daily notes that don't fit a formal structure.",
563
+ 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.",
564
564
  inputSchema: {
565
565
  type: "object",
566
566
  properties: {
@@ -595,7 +595,7 @@ var init_tools = __esm({
595
595
  },
596
596
  {
597
597
  name: "mindgraph_capture",
598
- description: "Capture entities, observations, concepts, sources, and snippets into the Reality layer with automatic deduplication. Use 'entity' for people, organizations, places, events, nations, or abstract concepts. Use 'observation' for factual observations. Use 'source' for documents or references. Use 'snippet' for direct quotes linked to a source.",
598
+ 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.",
599
599
  inputSchema: {
600
600
  type: "object",
601
601
  properties: {
@@ -654,7 +654,7 @@ var init_tools = __esm({
654
654
  },
655
655
  {
656
656
  name: "mindgraph_argue",
657
- description: "Construct a structured argument with claims, evidence, warrants, and rebuttals. Creates interconnected Epistemic layer nodes. Use this when you need to record or evaluate a reasoned position with supporting evidence and logical connections.",
657
+ 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.",
658
658
  inputSchema: {
659
659
  type: "object",
660
660
  properties: {
@@ -710,7 +710,7 @@ var init_tools = __esm({
710
710
  },
711
711
  {
712
712
  name: "mindgraph_inquire",
713
- description: "Record questions, hypotheses, theories, anomalies, assumptions, and paradigms in the Epistemic layer. Use this to track open questions worth investigating, form testable hypotheses, flag anomalies that challenge existing understanding, or articulate theoretical frameworks.",
713
+ 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.",
714
714
  inputSchema: {
715
715
  type: "object",
716
716
  properties: {
@@ -761,7 +761,7 @@ var init_tools = __esm({
761
761
  },
762
762
  {
763
763
  name: "mindgraph_commit",
764
- description: "Create goals, projects, and milestones in the Intent layer. Use 'goal' for desired outcomes, 'project' for organized efforts toward goals, and 'milestone' for measurable checkpoints within projects.",
764
+ 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.",
765
765
  inputSchema: {
766
766
  type: "object",
767
767
  properties: {
@@ -806,7 +806,7 @@ var init_tools = __esm({
806
806
  },
807
807
  {
808
808
  name: "mindgraph_decide",
809
- description: "Manage decisions through their full lifecycle: open a decision, add options and constraints, then resolve by choosing an option. Use 'get_open' to list all unresolved decisions.",
809
+ 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.",
810
810
  inputSchema: {
811
811
  type: "object",
812
812
  properties: {
@@ -845,7 +845,7 @@ var init_tools = __esm({
845
845
  },
846
846
  {
847
847
  name: "mindgraph_action",
848
- description: "Record procedural knowledge (workflows, steps, affordances, controls) and risk assessments in the Action layer. Use this for SOPs, runbooks, capability mappings, and risk analysis.",
848
+ 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.",
849
849
  inputSchema: {
850
850
  type: "object",
851
851
  properties: {
@@ -887,7 +887,7 @@ var init_tools = __esm({
887
887
  },
888
888
  {
889
889
  name: "mindgraph_plan",
890
- description: "Create and manage plans, tasks, execution tracking, and governance policies in the Agent layer. Supports full task lifecycle from creation through completion, plan hierarchies, and approval workflows.",
890
+ 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.",
891
891
  inputSchema: {
892
892
  type: "object",
893
893
  properties: {
@@ -943,7 +943,7 @@ var init_tools = __esm({
943
943
  },
944
944
  {
945
945
  name: "mindgraph_retrieve",
946
- description: "Search and query the knowledge graph. Supports hybrid (text + semantic) search, active goals, open questions, weak claims, pending approvals, contradictions, layer-filtered retrieval, and rich context retrieval that follows graph edges from matching chunks.",
946
+ description: "Search and query the knowledge graph. ALWAYS retrieve before answering questions about previously stored knowledge. Actions: 'context' for rich retrieval (follows graph edges \u2014 best for RAG), 'hybrid' for fast keyword+semantic search, 'text' for exact keyword match, 'semantic' for meaning-based search. Convenience queries: 'active_goals', 'open_questions', 'weak_claims', 'pending_approvals', 'unresolved_contradictions'. Use 'layer' to browse a specific cognitive layer, 'recent' for latest additions.",
947
947
  inputSchema: {
948
948
  type: "object",
949
949
  properties: {
@@ -998,7 +998,7 @@ var init_tools = __esm({
998
998
  },
999
999
  {
1000
1000
  name: "mindgraph_ingest",
1001
- description: "Ingest long-form content into the knowledge graph. Supports single chunks (synchronous), full documents (async with job tracking), and session transcripts. The ingestion pipeline automatically extracts entities, claims, relationships, and structures across cognitive layers.",
1001
+ description: "Ingest long-form content (articles, transcripts, documents, meeting notes) into the knowledge graph. The pipeline automatically chunks the text, extracts entities/claims/relationships via LLM, and deduplicates against existing nodes. Use 'chunk' for a single passage (synchronous), 'document' for full documents (async \u2014 returns a job ID), 'session' for conversation transcripts. Use 'job_status' to check progress. For short individual facts, use the specific cognitive tools instead.",
1002
1002
  inputSchema: {
1003
1003
  type: "object",
1004
1004
  properties: {
@@ -1063,9 +1063,11 @@ var src_exports = {};
1063
1063
  async function main() {
1064
1064
  const transport = new import_stdio.StdioServerTransport();
1065
1065
  await server.connect(transport);
1066
- console.error("MindGraph MCP server running on stdio");
1066
+ console.error(
1067
+ `MindGraph MCP server v0.2.0 running on stdio (${BASE_URL})`
1068
+ );
1067
1069
  }
1068
- var import_server, import_stdio, import_types, import_mindgraph, API_KEY, BASE_URL, AGENT_ID, client, server;
1070
+ var import_server, import_stdio, import_types, import_mindgraph, API_KEY, BASE_URL, AGENT_ID, client, INSTRUCTIONS, server, PROMPTS;
1069
1071
  var init_src = __esm({
1070
1072
  "src/index.ts"() {
1071
1073
  "use strict";
@@ -1079,7 +1081,7 @@ var init_src = __esm({
1079
1081
  AGENT_ID = process.env.MINDGRAPH_AGENT_ID || "mcp";
1080
1082
  if (!API_KEY) {
1081
1083
  console.error(
1082
- "Error: MINDGRAPH_API_KEY environment variable is required.\nGet your API key at https://mindgraph.cloud/dashboard/keys"
1084
+ "Error: MINDGRAPH_API_KEY environment variable is required.\nGet your API key at https://mindgraph.cloud/dashboard/keys\nOr run: npx mindgraph-mcp init"
1083
1085
  );
1084
1086
  process.exit(1);
1085
1087
  }
@@ -1087,16 +1089,62 @@ var init_src = __esm({
1087
1089
  baseUrl: BASE_URL,
1088
1090
  apiKey: API_KEY
1089
1091
  });
1092
+ INSTRUCTIONS = `You have access to a persistent knowledge graph via MindGraph. This is the user's long-term memory \u2014 use it proactively.
1093
+
1094
+ ## When to WRITE to the graph
1095
+
1096
+ Store knowledge whenever the user shares something worth remembering:
1097
+ - **People, organizations, places, events** \u2192 \`mindgraph_capture\` with action "entity" and the appropriate entity_type
1098
+ - **Quick notes, preferences, reflections, moods** \u2192 \`mindgraph_journal\`
1099
+ - **Factual observations about the world** \u2192 \`mindgraph_capture\` with action "observation"
1100
+ - **Claims that could be true or false** \u2192 \`mindgraph_argue\` (with evidence if available)
1101
+ - **Questions to investigate later** \u2192 \`mindgraph_inquire\` with action "open_question"
1102
+ - **Hypotheses or theories** \u2192 \`mindgraph_inquire\` with action "hypothesis" or "theory"
1103
+ - **Goals or projects the user is working on** \u2192 \`mindgraph_commit\`
1104
+ - **Decisions being made** \u2192 \`mindgraph_decide\` (open, add options, resolve)
1105
+ - **Long-form content (articles, transcripts, documents)** \u2192 \`mindgraph_ingest\`
1106
+
1107
+ ## When to READ from the graph
1108
+
1109
+ Retrieve context before answering questions that might benefit from prior knowledge:
1110
+ - **"What do I know about X?"** \u2192 \`mindgraph_retrieve\` with action "hybrid" or "context"
1111
+ - **"What are my goals?"** \u2192 \`mindgraph_retrieve\` with action "active_goals"
1112
+ - **"What questions are open?"** \u2192 \`mindgraph_retrieve\` with action "open_questions"
1113
+ - **Anything referencing past conversations or stored knowledge** \u2192 \`mindgraph_retrieve\` with action "context"
1114
+ - **Before making claims about things the user has told you** \u2192 retrieve first to avoid contradictions
1115
+
1116
+ ## Session management
1117
+
1118
+ - Open a session with \`mindgraph_session\` action "open" at the start of a substantial conversation
1119
+ - Use action "trace" to mark key moments during the conversation
1120
+ - Close the session with action "close" and a summary at the end
1121
+
1122
+ ## Tool selection guide
1123
+
1124
+ - **mindgraph_capture vs mindgraph_journal**: Use \`capture\` for structured entities (people, orgs, places) and factual observations. Use \`journal\` for informal notes, preferences, reflections, and anything that's more about the user's inner state than external facts.
1125
+ - **mindgraph_argue vs mindgraph_inquire**: Use \`argue\` when there's a specific claim with supporting evidence. Use \`inquire\` for open-ended questions, hypotheses without evidence yet, or theoretical frameworks.
1126
+ - **mindgraph_commit vs mindgraph_plan**: Use \`commit\` for the user's goals, projects, and milestones. Use \`plan\` for agent-level task management and execution tracking.
1127
+ - **mindgraph_retrieve "hybrid" vs "context"**: Use "hybrid" for quick keyword+semantic search. Use "context" for richer retrieval that follows graph edges from matching chunks to find connected entities and claims.
1128
+ - **mindgraph_ingest**: Use for any content longer than a paragraph. It automatically extracts entities, claims, and relationships. For short facts, use the specific cognitive tools instead.
1129
+
1130
+ ## Important behaviors
1131
+
1132
+ - Be proactive: if the user mentions a person, place, or organization you haven't captured yet, capture it
1133
+ - Deduplicate: the graph handles entity deduplication automatically \u2014 don't worry about creating duplicates
1134
+ - Confidence scores: use 0.9+ for things the user states as fact, 0.5-0.8 for uncertain claims, below 0.5 for speculation
1135
+ - Don't narrate tool usage excessively \u2014 capture knowledge naturally as part of the conversation`;
1090
1136
  server = new import_server.Server(
1091
1137
  {
1092
1138
  name: "mindgraph",
1093
- version: "0.1.0"
1139
+ version: "0.2.1"
1094
1140
  },
1095
1141
  {
1096
1142
  capabilities: {
1097
1143
  tools: {},
1098
- resources: {}
1099
- }
1144
+ resources: {},
1145
+ prompts: {}
1146
+ },
1147
+ instructions: INSTRUCTIONS
1100
1148
  }
1101
1149
  );
1102
1150
  server.setRequestHandler(import_types.ListToolsRequestSchema, async () => {
@@ -1110,6 +1158,164 @@ var init_src = __esm({
1110
1158
  }
1111
1159
  return handleTool(client, name, toolArgs);
1112
1160
  });
1161
+ PROMPTS = [
1162
+ {
1163
+ name: "graph-summary",
1164
+ description: "Get a comprehensive summary of what's in your knowledge graph \u2014 entities, claims, goals, and open questions.",
1165
+ arguments: []
1166
+ },
1167
+ {
1168
+ name: "active-goals",
1169
+ description: "Review your active goals, projects, and milestones with their current status.",
1170
+ arguments: []
1171
+ },
1172
+ {
1173
+ name: "open-questions",
1174
+ description: "List all open questions and hypotheses that need investigation.",
1175
+ arguments: []
1176
+ },
1177
+ {
1178
+ name: "review-contradictions",
1179
+ description: "Find and analyze contradictions in your knowledge graph \u2014 claims that conflict with each other.",
1180
+ arguments: []
1181
+ },
1182
+ {
1183
+ name: "knowledge-about",
1184
+ description: "Retrieve everything the knowledge graph knows about a specific topic.",
1185
+ arguments: [
1186
+ {
1187
+ name: "topic",
1188
+ description: "The topic to search for",
1189
+ required: true
1190
+ }
1191
+ ]
1192
+ },
1193
+ {
1194
+ name: "daily-briefing",
1195
+ description: "Get a daily briefing: active goals, recent knowledge, open questions, and pending decisions.",
1196
+ arguments: []
1197
+ },
1198
+ {
1199
+ name: "capture-conversation",
1200
+ description: "Analyze the current conversation and capture all important entities, claims, decisions, and action items into the knowledge graph.",
1201
+ arguments: [
1202
+ {
1203
+ name: "conversation",
1204
+ description: "The conversation text to analyze and capture",
1205
+ required: true
1206
+ }
1207
+ ]
1208
+ }
1209
+ ];
1210
+ server.setRequestHandler(import_types.ListPromptsRequestSchema, async () => {
1211
+ return { prompts: PROMPTS };
1212
+ });
1213
+ server.setRequestHandler(import_types.GetPromptRequestSchema, async (request) => {
1214
+ const { name, arguments: args } = request.params;
1215
+ switch (name) {
1216
+ case "graph-summary":
1217
+ return {
1218
+ messages: [
1219
+ {
1220
+ role: "user",
1221
+ content: {
1222
+ type: "text",
1223
+ text: "Give me a comprehensive summary of my knowledge graph. Start by checking the graph stats, then retrieve my active goals, open questions, and any recent knowledge. Organize the summary by cognitive layer (Reality, Epistemic, Intent, Action, Memory)."
1224
+ }
1225
+ }
1226
+ ]
1227
+ };
1228
+ case "active-goals":
1229
+ return {
1230
+ messages: [
1231
+ {
1232
+ role: "user",
1233
+ content: {
1234
+ type: "text",
1235
+ text: "Review all my active goals, projects, and milestones. For each one, show its status, any linked decisions or tasks, and suggest next steps. Group them by project if applicable."
1236
+ }
1237
+ }
1238
+ ]
1239
+ };
1240
+ case "open-questions":
1241
+ return {
1242
+ messages: [
1243
+ {
1244
+ role: "user",
1245
+ content: {
1246
+ type: "text",
1247
+ text: "List all my open questions and hypotheses. For each one, check if there's any related evidence or claims in the graph that might help answer them. Prioritize by salience and suggest which ones I should investigate first."
1248
+ }
1249
+ }
1250
+ ]
1251
+ };
1252
+ case "review-contradictions":
1253
+ return {
1254
+ messages: [
1255
+ {
1256
+ role: "user",
1257
+ content: {
1258
+ type: "text",
1259
+ text: "Search my knowledge graph for contradictions \u2014 claims that conflict with each other, or evidence that undermines existing beliefs. Also look for weak claims (low confidence) that might need more evidence. For each contradiction found, explain the conflict and suggest how to resolve it."
1260
+ }
1261
+ }
1262
+ ]
1263
+ };
1264
+ case "knowledge-about": {
1265
+ const topic = args?.topic || "general";
1266
+ return {
1267
+ messages: [
1268
+ {
1269
+ role: "user",
1270
+ content: {
1271
+ type: "text",
1272
+ text: `Search my knowledge graph for everything related to "${topic}". Use both hybrid search and context retrieval to find entities, claims, evidence, questions, and any connected knowledge. Present a structured overview of what I know about this topic, highlighting any gaps or open questions.`
1273
+ }
1274
+ }
1275
+ ]
1276
+ };
1277
+ }
1278
+ case "daily-briefing":
1279
+ return {
1280
+ messages: [
1281
+ {
1282
+ role: "user",
1283
+ content: {
1284
+ type: "text",
1285
+ text: "Give me a daily briefing. Check:\n1. Active goals and their progress\n2. Open decisions that need resolution\n3. Recent knowledge added in the last few days\n4. Open questions worth investigating\n5. Any pending approvals\n6. Weak claims that need more evidence\n\nKeep it concise and actionable \u2014 highlight what needs my attention today."
1286
+ }
1287
+ }
1288
+ ]
1289
+ };
1290
+ case "capture-conversation": {
1291
+ const conversation = args?.conversation || "";
1292
+ return {
1293
+ messages: [
1294
+ {
1295
+ role: "user",
1296
+ content: {
1297
+ type: "text",
1298
+ text: `Analyze the following conversation and capture all important information into my knowledge graph. Extract:
1299
+ - Named entities (people, organizations, places, events)
1300
+ - Factual claims and observations
1301
+ - Decisions made or pending
1302
+ - Goals or commitments mentioned
1303
+ - Open questions raised
1304
+ - Any hypotheses or theories discussed
1305
+
1306
+ Use the appropriate MindGraph tools for each type of knowledge.
1307
+
1308
+ Conversation:
1309
+ ${conversation}`
1310
+ }
1311
+ }
1312
+ ]
1313
+ };
1314
+ }
1315
+ default:
1316
+ throw new Error(`Unknown prompt: ${name}`);
1317
+ }
1318
+ });
1113
1319
  server.setRequestHandler(import_types.ListResourcesRequestSchema, async () => {
1114
1320
  return {
1115
1321
  resources: [
@@ -1130,6 +1336,42 @@ var init_src = __esm({
1130
1336
  name: "Open Questions",
1131
1337
  description: "All open questions in the knowledge graph",
1132
1338
  mimeType: "application/json"
1339
+ },
1340
+ {
1341
+ uri: "mindgraph://contradictions",
1342
+ name: "Contradictions",
1343
+ description: "Contradictory claims in the knowledge graph",
1344
+ mimeType: "application/json"
1345
+ },
1346
+ {
1347
+ uri: "mindgraph://decisions",
1348
+ name: "Open Decisions",
1349
+ description: "Unresolved decisions awaiting resolution",
1350
+ mimeType: "application/json"
1351
+ }
1352
+ ]
1353
+ };
1354
+ });
1355
+ server.setRequestHandler(import_types.ListResourceTemplatesRequestSchema, async () => {
1356
+ return {
1357
+ resourceTemplates: [
1358
+ {
1359
+ uriTemplate: "mindgraph://node/{uid}",
1360
+ name: "Graph Node",
1361
+ description: "Retrieve a specific node by its UID, including all properties, edges, and version history",
1362
+ mimeType: "application/json"
1363
+ },
1364
+ {
1365
+ uriTemplate: "mindgraph://search/{query}",
1366
+ name: "Search Results",
1367
+ description: "Full-text search across all nodes in the knowledge graph",
1368
+ mimeType: "application/json"
1369
+ },
1370
+ {
1371
+ uriTemplate: "mindgraph://layer/{layer}",
1372
+ name: "Layer Nodes",
1373
+ description: "List all nodes in a specific cognitive layer (reality, epistemic, intent, action, memory, agent)",
1374
+ mimeType: "application/json"
1133
1375
  }
1134
1376
  ]
1135
1377
  };
@@ -1173,9 +1415,80 @@ var init_src = __esm({
1173
1415
  ]
1174
1416
  };
1175
1417
  }
1176
- default:
1177
- throw new Error(`Unknown resource: ${uri}`);
1418
+ case "mindgraph://contradictions": {
1419
+ const contradictions = await client.getContradictions();
1420
+ return {
1421
+ contents: [
1422
+ {
1423
+ uri,
1424
+ mimeType: "application/json",
1425
+ text: JSON.stringify(contradictions, null, 2)
1426
+ }
1427
+ ]
1428
+ };
1429
+ }
1430
+ case "mindgraph://decisions": {
1431
+ const decisions = await client.getOpenDecisions();
1432
+ return {
1433
+ contents: [
1434
+ {
1435
+ uri,
1436
+ mimeType: "application/json",
1437
+ text: JSON.stringify(decisions, null, 2)
1438
+ }
1439
+ ]
1440
+ };
1441
+ }
1442
+ }
1443
+ const nodeMatch = uri.match(/^mindgraph:\/\/node\/(.+)$/);
1444
+ if (nodeMatch) {
1445
+ const uid = decodeURIComponent(nodeMatch[1]);
1446
+ const node = await client.getNode(uid);
1447
+ const edges = await client.getEdges({ from_uid: uid });
1448
+ const inEdges = await client.getEdges({ to_uid: uid });
1449
+ return {
1450
+ contents: [
1451
+ {
1452
+ uri,
1453
+ mimeType: "application/json",
1454
+ text: JSON.stringify(
1455
+ { node, outgoing_edges: edges, incoming_edges: inEdges },
1456
+ null,
1457
+ 2
1458
+ )
1459
+ }
1460
+ ]
1461
+ };
1462
+ }
1463
+ const searchMatch = uri.match(/^mindgraph:\/\/search\/(.+)$/);
1464
+ if (searchMatch) {
1465
+ const query = decodeURIComponent(searchMatch[1]);
1466
+ const results = await client.hybridSearch(query, { k: 20 });
1467
+ return {
1468
+ contents: [
1469
+ {
1470
+ uri,
1471
+ mimeType: "application/json",
1472
+ text: JSON.stringify(results, null, 2)
1473
+ }
1474
+ ]
1475
+ };
1476
+ }
1477
+ const layerMatch = uri.match(/^mindgraph:\/\/layer\/(.+)$/);
1478
+ if (layerMatch) {
1479
+ const layer = decodeURIComponent(layerMatch[1]);
1480
+ const nodes = await client.getNodes({ layer, limit: 50 });
1481
+ return {
1482
+ contents: [
1483
+ {
1484
+ uri,
1485
+ mimeType: "application/json",
1486
+ text: JSON.stringify(nodes, null, 2)
1487
+ }
1488
+ ]
1489
+ };
1178
1490
  }
1491
+ throw new Error(`Unknown resource: ${uri}`);
1179
1492
  });
1180
1493
  main().catch((error) => {
1181
1494
  console.error("Fatal error:", error);
@@ -1234,7 +1547,7 @@ function getMcpServerEntry(apiKey, baseUrl) {
1234
1547
  if (baseUrl) env.MINDGRAPH_BASE_URL = baseUrl;
1235
1548
  return {
1236
1549
  command: "npx",
1237
- args: ["-y", "mindgraph-mcp"],
1550
+ args: ["-y", "mindgraph-mcp@latest"],
1238
1551
  env
1239
1552
  };
1240
1553
  }
@@ -1272,7 +1585,7 @@ function installClaudeCode(apiKey, baseUrl) {
1272
1585
  "--",
1273
1586
  "npx",
1274
1587
  "-y",
1275
- "mindgraph-mcp"
1588
+ "mindgraph-mcp@latest"
1276
1589
  ].join(" "),
1277
1590
  { stdio: "inherit" }
1278
1591
  );
package/dist/index.js CHANGED
@@ -10,7 +10,7 @@ var import_mindgraph = require("mindgraph");
10
10
  var TOOLS = [
11
11
  {
12
12
  name: "mindgraph_session",
13
- description: "Open, trace, or close a memory session. Sessions group related interactions and enable context continuity. Open a session at the start of a conversation, trace key moments during it, and close it at the end to trigger distillation.",
13
+ description: "Manage conversation sessions. ALWAYS open a session at the start of a substantial conversation (label it with the topic). Use 'trace' to bookmark key moments (decisions made, important facts shared). Close the session at the end with a summary of what was discussed. Sessions enable the graph to track conversation continuity and trigger knowledge distillation on close.",
14
14
  inputSchema: {
15
15
  type: "object",
16
16
  properties: {
@@ -45,7 +45,7 @@ var TOOLS = [
45
45
  },
46
46
  {
47
47
  name: "mindgraph_journal",
48
- description: "Low-friction capture of observations, notes, preferences, and reflections. Creates a Journal node in the Memory layer. Use this for quick thoughts, user preferences, mood tracking, and daily notes that don't fit a formal structure.",
48
+ 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.",
49
49
  inputSchema: {
50
50
  type: "object",
51
51
  properties: {
@@ -80,7 +80,7 @@ var TOOLS = [
80
80
  },
81
81
  {
82
82
  name: "mindgraph_capture",
83
- description: "Capture entities, observations, concepts, sources, and snippets into the Reality layer with automatic deduplication. Use 'entity' for people, organizations, places, events, nations, or abstract concepts. Use 'observation' for factual observations. Use 'source' for documents or references. Use 'snippet' for direct quotes linked to a source.",
83
+ 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.",
84
84
  inputSchema: {
85
85
  type: "object",
86
86
  properties: {
@@ -139,7 +139,7 @@ var TOOLS = [
139
139
  },
140
140
  {
141
141
  name: "mindgraph_argue",
142
- description: "Construct a structured argument with claims, evidence, warrants, and rebuttals. Creates interconnected Epistemic layer nodes. Use this when you need to record or evaluate a reasoned position with supporting evidence and logical connections.",
142
+ 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.",
143
143
  inputSchema: {
144
144
  type: "object",
145
145
  properties: {
@@ -195,7 +195,7 @@ var TOOLS = [
195
195
  },
196
196
  {
197
197
  name: "mindgraph_inquire",
198
- description: "Record questions, hypotheses, theories, anomalies, assumptions, and paradigms in the Epistemic layer. Use this to track open questions worth investigating, form testable hypotheses, flag anomalies that challenge existing understanding, or articulate theoretical frameworks.",
198
+ 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.",
199
199
  inputSchema: {
200
200
  type: "object",
201
201
  properties: {
@@ -246,7 +246,7 @@ var TOOLS = [
246
246
  },
247
247
  {
248
248
  name: "mindgraph_commit",
249
- description: "Create goals, projects, and milestones in the Intent layer. Use 'goal' for desired outcomes, 'project' for organized efforts toward goals, and 'milestone' for measurable checkpoints within projects.",
249
+ 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.",
250
250
  inputSchema: {
251
251
  type: "object",
252
252
  properties: {
@@ -291,7 +291,7 @@ var TOOLS = [
291
291
  },
292
292
  {
293
293
  name: "mindgraph_decide",
294
- description: "Manage decisions through their full lifecycle: open a decision, add options and constraints, then resolve by choosing an option. Use 'get_open' to list all unresolved decisions.",
294
+ 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.",
295
295
  inputSchema: {
296
296
  type: "object",
297
297
  properties: {
@@ -330,7 +330,7 @@ var TOOLS = [
330
330
  },
331
331
  {
332
332
  name: "mindgraph_action",
333
- description: "Record procedural knowledge (workflows, steps, affordances, controls) and risk assessments in the Action layer. Use this for SOPs, runbooks, capability mappings, and risk analysis.",
333
+ 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.",
334
334
  inputSchema: {
335
335
  type: "object",
336
336
  properties: {
@@ -372,7 +372,7 @@ var TOOLS = [
372
372
  },
373
373
  {
374
374
  name: "mindgraph_plan",
375
- description: "Create and manage plans, tasks, execution tracking, and governance policies in the Agent layer. Supports full task lifecycle from creation through completion, plan hierarchies, and approval workflows.",
375
+ 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.",
376
376
  inputSchema: {
377
377
  type: "object",
378
378
  properties: {
@@ -428,7 +428,7 @@ var TOOLS = [
428
428
  },
429
429
  {
430
430
  name: "mindgraph_retrieve",
431
- description: "Search and query the knowledge graph. Supports hybrid (text + semantic) search, active goals, open questions, weak claims, pending approvals, contradictions, layer-filtered retrieval, and rich context retrieval that follows graph edges from matching chunks.",
431
+ description: "Search and query the knowledge graph. ALWAYS retrieve before answering questions about previously stored knowledge. Actions: 'context' for rich retrieval (follows graph edges \u2014 best for RAG), 'hybrid' for fast keyword+semantic search, 'text' for exact keyword match, 'semantic' for meaning-based search. Convenience queries: 'active_goals', 'open_questions', 'weak_claims', 'pending_approvals', 'unresolved_contradictions'. Use 'layer' to browse a specific cognitive layer, 'recent' for latest additions.",
432
432
  inputSchema: {
433
433
  type: "object",
434
434
  properties: {
@@ -483,7 +483,7 @@ var TOOLS = [
483
483
  },
484
484
  {
485
485
  name: "mindgraph_ingest",
486
- description: "Ingest long-form content into the knowledge graph. Supports single chunks (synchronous), full documents (async with job tracking), and session transcripts. The ingestion pipeline automatically extracts entities, claims, relationships, and structures across cognitive layers.",
486
+ description: "Ingest long-form content (articles, transcripts, documents, meeting notes) into the knowledge graph. The pipeline automatically chunks the text, extracts entities/claims/relationships via LLM, and deduplicates against existing nodes. Use 'chunk' for a single passage (synchronous), 'document' for full documents (async \u2014 returns a job ID), 'session' for conversation transcripts. Use 'job_status' to check progress. For short individual facts, use the specific cognitive tools instead.",
487
487
  inputSchema: {
488
488
  type: "object",
489
489
  properties: {
@@ -1038,7 +1038,7 @@ var BASE_URL = process.env.MINDGRAPH_BASE_URL || "https://api.mindgraph.cloud";
1038
1038
  var AGENT_ID = process.env.MINDGRAPH_AGENT_ID || "mcp";
1039
1039
  if (!API_KEY) {
1040
1040
  console.error(
1041
- "Error: MINDGRAPH_API_KEY environment variable is required.\nGet your API key at https://mindgraph.cloud/dashboard/keys"
1041
+ "Error: MINDGRAPH_API_KEY environment variable is required.\nGet your API key at https://mindgraph.cloud/dashboard/keys\nOr run: npx mindgraph-mcp init"
1042
1042
  );
1043
1043
  process.exit(1);
1044
1044
  }
@@ -1046,16 +1046,62 @@ var client = new import_mindgraph.MindGraph({
1046
1046
  baseUrl: BASE_URL,
1047
1047
  apiKey: API_KEY
1048
1048
  });
1049
+ var INSTRUCTIONS = `You have access to a persistent knowledge graph via MindGraph. This is the user's long-term memory \u2014 use it proactively.
1050
+
1051
+ ## When to WRITE to the graph
1052
+
1053
+ Store knowledge whenever the user shares something worth remembering:
1054
+ - **People, organizations, places, events** \u2192 \`mindgraph_capture\` with action "entity" and the appropriate entity_type
1055
+ - **Quick notes, preferences, reflections, moods** \u2192 \`mindgraph_journal\`
1056
+ - **Factual observations about the world** \u2192 \`mindgraph_capture\` with action "observation"
1057
+ - **Claims that could be true or false** \u2192 \`mindgraph_argue\` (with evidence if available)
1058
+ - **Questions to investigate later** \u2192 \`mindgraph_inquire\` with action "open_question"
1059
+ - **Hypotheses or theories** \u2192 \`mindgraph_inquire\` with action "hypothesis" or "theory"
1060
+ - **Goals or projects the user is working on** \u2192 \`mindgraph_commit\`
1061
+ - **Decisions being made** \u2192 \`mindgraph_decide\` (open, add options, resolve)
1062
+ - **Long-form content (articles, transcripts, documents)** \u2192 \`mindgraph_ingest\`
1063
+
1064
+ ## When to READ from the graph
1065
+
1066
+ Retrieve context before answering questions that might benefit from prior knowledge:
1067
+ - **"What do I know about X?"** \u2192 \`mindgraph_retrieve\` with action "hybrid" or "context"
1068
+ - **"What are my goals?"** \u2192 \`mindgraph_retrieve\` with action "active_goals"
1069
+ - **"What questions are open?"** \u2192 \`mindgraph_retrieve\` with action "open_questions"
1070
+ - **Anything referencing past conversations or stored knowledge** \u2192 \`mindgraph_retrieve\` with action "context"
1071
+ - **Before making claims about things the user has told you** \u2192 retrieve first to avoid contradictions
1072
+
1073
+ ## Session management
1074
+
1075
+ - Open a session with \`mindgraph_session\` action "open" at the start of a substantial conversation
1076
+ - Use action "trace" to mark key moments during the conversation
1077
+ - Close the session with action "close" and a summary at the end
1078
+
1079
+ ## Tool selection guide
1080
+
1081
+ - **mindgraph_capture vs mindgraph_journal**: Use \`capture\` for structured entities (people, orgs, places) and factual observations. Use \`journal\` for informal notes, preferences, reflections, and anything that's more about the user's inner state than external facts.
1082
+ - **mindgraph_argue vs mindgraph_inquire**: Use \`argue\` when there's a specific claim with supporting evidence. Use \`inquire\` for open-ended questions, hypotheses without evidence yet, or theoretical frameworks.
1083
+ - **mindgraph_commit vs mindgraph_plan**: Use \`commit\` for the user's goals, projects, and milestones. Use \`plan\` for agent-level task management and execution tracking.
1084
+ - **mindgraph_retrieve "hybrid" vs "context"**: Use "hybrid" for quick keyword+semantic search. Use "context" for richer retrieval that follows graph edges from matching chunks to find connected entities and claims.
1085
+ - **mindgraph_ingest**: Use for any content longer than a paragraph. It automatically extracts entities, claims, and relationships. For short facts, use the specific cognitive tools instead.
1086
+
1087
+ ## Important behaviors
1088
+
1089
+ - Be proactive: if the user mentions a person, place, or organization you haven't captured yet, capture it
1090
+ - Deduplicate: the graph handles entity deduplication automatically \u2014 don't worry about creating duplicates
1091
+ - Confidence scores: use 0.9+ for things the user states as fact, 0.5-0.8 for uncertain claims, below 0.5 for speculation
1092
+ - Don't narrate tool usage excessively \u2014 capture knowledge naturally as part of the conversation`;
1049
1093
  var server = new import_server.Server(
1050
1094
  {
1051
1095
  name: "mindgraph",
1052
- version: "0.1.0"
1096
+ version: "0.2.1"
1053
1097
  },
1054
1098
  {
1055
1099
  capabilities: {
1056
1100
  tools: {},
1057
- resources: {}
1058
- }
1101
+ resources: {},
1102
+ prompts: {}
1103
+ },
1104
+ instructions: INSTRUCTIONS
1059
1105
  }
1060
1106
  );
1061
1107
  server.setRequestHandler(import_types.ListToolsRequestSchema, async () => {
@@ -1069,6 +1115,164 @@ server.setRequestHandler(import_types.CallToolRequestSchema, async (request) =>
1069
1115
  }
1070
1116
  return handleTool(client, name, toolArgs);
1071
1117
  });
1118
+ var PROMPTS = [
1119
+ {
1120
+ name: "graph-summary",
1121
+ description: "Get a comprehensive summary of what's in your knowledge graph \u2014 entities, claims, goals, and open questions.",
1122
+ arguments: []
1123
+ },
1124
+ {
1125
+ name: "active-goals",
1126
+ description: "Review your active goals, projects, and milestones with their current status.",
1127
+ arguments: []
1128
+ },
1129
+ {
1130
+ name: "open-questions",
1131
+ description: "List all open questions and hypotheses that need investigation.",
1132
+ arguments: []
1133
+ },
1134
+ {
1135
+ name: "review-contradictions",
1136
+ description: "Find and analyze contradictions in your knowledge graph \u2014 claims that conflict with each other.",
1137
+ arguments: []
1138
+ },
1139
+ {
1140
+ name: "knowledge-about",
1141
+ description: "Retrieve everything the knowledge graph knows about a specific topic.",
1142
+ arguments: [
1143
+ {
1144
+ name: "topic",
1145
+ description: "The topic to search for",
1146
+ required: true
1147
+ }
1148
+ ]
1149
+ },
1150
+ {
1151
+ name: "daily-briefing",
1152
+ description: "Get a daily briefing: active goals, recent knowledge, open questions, and pending decisions.",
1153
+ arguments: []
1154
+ },
1155
+ {
1156
+ name: "capture-conversation",
1157
+ description: "Analyze the current conversation and capture all important entities, claims, decisions, and action items into the knowledge graph.",
1158
+ arguments: [
1159
+ {
1160
+ name: "conversation",
1161
+ description: "The conversation text to analyze and capture",
1162
+ required: true
1163
+ }
1164
+ ]
1165
+ }
1166
+ ];
1167
+ server.setRequestHandler(import_types.ListPromptsRequestSchema, async () => {
1168
+ return { prompts: PROMPTS };
1169
+ });
1170
+ server.setRequestHandler(import_types.GetPromptRequestSchema, async (request) => {
1171
+ const { name, arguments: args } = request.params;
1172
+ switch (name) {
1173
+ case "graph-summary":
1174
+ return {
1175
+ messages: [
1176
+ {
1177
+ role: "user",
1178
+ content: {
1179
+ type: "text",
1180
+ text: "Give me a comprehensive summary of my knowledge graph. Start by checking the graph stats, then retrieve my active goals, open questions, and any recent knowledge. Organize the summary by cognitive layer (Reality, Epistemic, Intent, Action, Memory)."
1181
+ }
1182
+ }
1183
+ ]
1184
+ };
1185
+ case "active-goals":
1186
+ return {
1187
+ messages: [
1188
+ {
1189
+ role: "user",
1190
+ content: {
1191
+ type: "text",
1192
+ text: "Review all my active goals, projects, and milestones. For each one, show its status, any linked decisions or tasks, and suggest next steps. Group them by project if applicable."
1193
+ }
1194
+ }
1195
+ ]
1196
+ };
1197
+ case "open-questions":
1198
+ return {
1199
+ messages: [
1200
+ {
1201
+ role: "user",
1202
+ content: {
1203
+ type: "text",
1204
+ text: "List all my open questions and hypotheses. For each one, check if there's any related evidence or claims in the graph that might help answer them. Prioritize by salience and suggest which ones I should investigate first."
1205
+ }
1206
+ }
1207
+ ]
1208
+ };
1209
+ case "review-contradictions":
1210
+ return {
1211
+ messages: [
1212
+ {
1213
+ role: "user",
1214
+ content: {
1215
+ type: "text",
1216
+ text: "Search my knowledge graph for contradictions \u2014 claims that conflict with each other, or evidence that undermines existing beliefs. Also look for weak claims (low confidence) that might need more evidence. For each contradiction found, explain the conflict and suggest how to resolve it."
1217
+ }
1218
+ }
1219
+ ]
1220
+ };
1221
+ case "knowledge-about": {
1222
+ const topic = args?.topic || "general";
1223
+ return {
1224
+ messages: [
1225
+ {
1226
+ role: "user",
1227
+ content: {
1228
+ type: "text",
1229
+ text: `Search my knowledge graph for everything related to "${topic}". Use both hybrid search and context retrieval to find entities, claims, evidence, questions, and any connected knowledge. Present a structured overview of what I know about this topic, highlighting any gaps or open questions.`
1230
+ }
1231
+ }
1232
+ ]
1233
+ };
1234
+ }
1235
+ case "daily-briefing":
1236
+ return {
1237
+ messages: [
1238
+ {
1239
+ role: "user",
1240
+ content: {
1241
+ type: "text",
1242
+ text: "Give me a daily briefing. Check:\n1. Active goals and their progress\n2. Open decisions that need resolution\n3. Recent knowledge added in the last few days\n4. Open questions worth investigating\n5. Any pending approvals\n6. Weak claims that need more evidence\n\nKeep it concise and actionable \u2014 highlight what needs my attention today."
1243
+ }
1244
+ }
1245
+ ]
1246
+ };
1247
+ case "capture-conversation": {
1248
+ const conversation = args?.conversation || "";
1249
+ return {
1250
+ messages: [
1251
+ {
1252
+ role: "user",
1253
+ content: {
1254
+ type: "text",
1255
+ text: `Analyze the following conversation and capture all important information into my knowledge graph. Extract:
1256
+ - Named entities (people, organizations, places, events)
1257
+ - Factual claims and observations
1258
+ - Decisions made or pending
1259
+ - Goals or commitments mentioned
1260
+ - Open questions raised
1261
+ - Any hypotheses or theories discussed
1262
+
1263
+ Use the appropriate MindGraph tools for each type of knowledge.
1264
+
1265
+ Conversation:
1266
+ ${conversation}`
1267
+ }
1268
+ }
1269
+ ]
1270
+ };
1271
+ }
1272
+ default:
1273
+ throw new Error(`Unknown prompt: ${name}`);
1274
+ }
1275
+ });
1072
1276
  server.setRequestHandler(import_types.ListResourcesRequestSchema, async () => {
1073
1277
  return {
1074
1278
  resources: [
@@ -1089,6 +1293,42 @@ server.setRequestHandler(import_types.ListResourcesRequestSchema, async () => {
1089
1293
  name: "Open Questions",
1090
1294
  description: "All open questions in the knowledge graph",
1091
1295
  mimeType: "application/json"
1296
+ },
1297
+ {
1298
+ uri: "mindgraph://contradictions",
1299
+ name: "Contradictions",
1300
+ description: "Contradictory claims in the knowledge graph",
1301
+ mimeType: "application/json"
1302
+ },
1303
+ {
1304
+ uri: "mindgraph://decisions",
1305
+ name: "Open Decisions",
1306
+ description: "Unresolved decisions awaiting resolution",
1307
+ mimeType: "application/json"
1308
+ }
1309
+ ]
1310
+ };
1311
+ });
1312
+ server.setRequestHandler(import_types.ListResourceTemplatesRequestSchema, async () => {
1313
+ return {
1314
+ resourceTemplates: [
1315
+ {
1316
+ uriTemplate: "mindgraph://node/{uid}",
1317
+ name: "Graph Node",
1318
+ description: "Retrieve a specific node by its UID, including all properties, edges, and version history",
1319
+ mimeType: "application/json"
1320
+ },
1321
+ {
1322
+ uriTemplate: "mindgraph://search/{query}",
1323
+ name: "Search Results",
1324
+ description: "Full-text search across all nodes in the knowledge graph",
1325
+ mimeType: "application/json"
1326
+ },
1327
+ {
1328
+ uriTemplate: "mindgraph://layer/{layer}",
1329
+ name: "Layer Nodes",
1330
+ description: "List all nodes in a specific cognitive layer (reality, epistemic, intent, action, memory, agent)",
1331
+ mimeType: "application/json"
1092
1332
  }
1093
1333
  ]
1094
1334
  };
@@ -1132,14 +1372,87 @@ server.setRequestHandler(import_types.ReadResourceRequestSchema, async (request)
1132
1372
  ]
1133
1373
  };
1134
1374
  }
1135
- default:
1136
- throw new Error(`Unknown resource: ${uri}`);
1375
+ case "mindgraph://contradictions": {
1376
+ const contradictions = await client.getContradictions();
1377
+ return {
1378
+ contents: [
1379
+ {
1380
+ uri,
1381
+ mimeType: "application/json",
1382
+ text: JSON.stringify(contradictions, null, 2)
1383
+ }
1384
+ ]
1385
+ };
1386
+ }
1387
+ case "mindgraph://decisions": {
1388
+ const decisions = await client.getOpenDecisions();
1389
+ return {
1390
+ contents: [
1391
+ {
1392
+ uri,
1393
+ mimeType: "application/json",
1394
+ text: JSON.stringify(decisions, null, 2)
1395
+ }
1396
+ ]
1397
+ };
1398
+ }
1137
1399
  }
1400
+ const nodeMatch = uri.match(/^mindgraph:\/\/node\/(.+)$/);
1401
+ if (nodeMatch) {
1402
+ const uid = decodeURIComponent(nodeMatch[1]);
1403
+ const node = await client.getNode(uid);
1404
+ const edges = await client.getEdges({ from_uid: uid });
1405
+ const inEdges = await client.getEdges({ to_uid: uid });
1406
+ return {
1407
+ contents: [
1408
+ {
1409
+ uri,
1410
+ mimeType: "application/json",
1411
+ text: JSON.stringify(
1412
+ { node, outgoing_edges: edges, incoming_edges: inEdges },
1413
+ null,
1414
+ 2
1415
+ )
1416
+ }
1417
+ ]
1418
+ };
1419
+ }
1420
+ const searchMatch = uri.match(/^mindgraph:\/\/search\/(.+)$/);
1421
+ if (searchMatch) {
1422
+ const query = decodeURIComponent(searchMatch[1]);
1423
+ const results = await client.hybridSearch(query, { k: 20 });
1424
+ return {
1425
+ contents: [
1426
+ {
1427
+ uri,
1428
+ mimeType: "application/json",
1429
+ text: JSON.stringify(results, null, 2)
1430
+ }
1431
+ ]
1432
+ };
1433
+ }
1434
+ const layerMatch = uri.match(/^mindgraph:\/\/layer\/(.+)$/);
1435
+ if (layerMatch) {
1436
+ const layer = decodeURIComponent(layerMatch[1]);
1437
+ const nodes = await client.getNodes({ layer, limit: 50 });
1438
+ return {
1439
+ contents: [
1440
+ {
1441
+ uri,
1442
+ mimeType: "application/json",
1443
+ text: JSON.stringify(nodes, null, 2)
1444
+ }
1445
+ ]
1446
+ };
1447
+ }
1448
+ throw new Error(`Unknown resource: ${uri}`);
1138
1449
  });
1139
1450
  async function main() {
1140
1451
  const transport = new import_stdio.StdioServerTransport();
1141
1452
  await server.connect(transport);
1142
- console.error("MindGraph MCP server running on stdio");
1453
+ console.error(
1454
+ `MindGraph MCP server v0.2.0 running on stdio (${BASE_URL})`
1455
+ );
1143
1456
  }
1144
1457
  main().catch((error) => {
1145
1458
  console.error("Fatal error:", error);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mindgraph-mcp",
3
- "version": "0.1.0",
3
+ "version": "0.2.1",
4
4
  "description": "MCP server for MindGraph — connect Claude Desktop, Claude Code, and any MCP client to your knowledge graph",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",