mindgraph-mcp 0.8.0 → 0.9.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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Shuruheel Ahamed
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -62,6 +62,8 @@ Or drop this into your Claude Desktop config by hand (`~/Library/Application Sup
62
62
  | `mindgraph_synthesize` | Project-scoped cross-document synthesis — mine signals, spawn Article-generation jobs |
63
63
  | `mindgraph_ontology` | Operational Ontology (Layer 7) — typed domain objects, NL queries with provenance, extraction proposal review (approve/reject), object linking |
64
64
 
65
+ Plus **dynamically generated read tools**: when the tenant's active schema declares object types, the server renders per-type `search_<objs>` / `get_<obj>` / `summarize_<obj>` tools (from the cloud's `GET /v1/ontology/tools` manifest) at session start. `summarize_<obj>` returns the object — whether mapped from a connected SQL database or extracted from documents — *plus* its cognitive context (claims, risks, decisions, evidence).
66
+
65
67
  **7 prompt templates** for common workflows:
66
68
 
67
69
  `graph-summary`, `active-goals`, `open-questions`, `review-contradictions`, `knowledge-about`, `daily-briefing`, `capture-conversation`.
package/dist/cli.js CHANGED
@@ -445,6 +445,15 @@ async function handleRetrieve(client2, args) {
445
445
  return ok(await client2.getPendingApprovals());
446
446
  case "unresolved_contradictions":
447
447
  return ok(await client2.getContradictions());
448
+ case "preferences":
449
+ return ok(
450
+ await client2.retrieve({
451
+ action: "preferences",
452
+ ...query ? { query, k: limit } : {},
453
+ limit,
454
+ agent_id
455
+ })
456
+ );
448
457
  case "layer":
449
458
  if (!layer) return err("layer is required for layer retrieval");
450
459
  return ok(
@@ -1002,7 +1011,7 @@ var init_tools = __esm({
1002
1011
  },
1003
1012
  {
1004
1013
  name: "mindgraph_retrieve",
1005
- description: "Search and explore the knowledge graph. Use 'context' (default) for BM25 keyword retrieval \u2014 returns graph nodes only by default (labels, summaries, types, confidence); set include_chunks=true to also get full source text. Pass 1-3 discriminating keywords, not sentences. GOOD: 'Kissinger NATO'. BAD: 'What is Kissinger\\'s view on NATO?'. Use 'document_index' to list all ingested documents (titles, dates, UIDs) for orientation. Use 'semantic' when keywords return nothing \u2014 conceptual/fuzzy queries. Use 'hybrid' for keyword + semantic. Use 'text' for fast keyword-only. Use 'neighborhood'/'chain'/'path'/'subgraph' for graph traversal. Other actions ('active_goals', 'open_questions', etc.) only when the user explicitly asks.",
1014
+ description: "Search and explore the knowledge graph. Use 'context' (default) for BM25 keyword retrieval \u2014 returns graph nodes only by default (labels, summaries, types, confidence); set include_chunks=true to also get full source text. Pass 1-3 discriminating keywords, not sentences. GOOD: 'Kissinger NATO'. BAD: 'What is Kissinger\\'s view on NATO?'. Use 'document_index' to list all ingested documents (titles, dates, UIDs) for orientation. Use 'semantic' when keywords return nothing \u2014 conceptual/fuzzy queries. Use 'hybrid' for keyword + semantic. Use 'text' for fast keyword-only. Use 'neighborhood'/'chain'/'path'/'subgraph' for graph traversal \u2014 traversal steps carry path_cost (lower = stronger connection; sum of -ln(edge weight)) and path_confidence (product of edge confidences; a ranking signal, not a calibrated probability) for the returned path, useful for ranking results; they score the path returned, not the best possible path. Use 'preferences' for advice or recommendation requests ('suggest a hotel', 'what should I read?') \u2014 it returns the user's stated/learned preferences relevant to the query (pass the topic as 'query'), so your answer reflects what they actually like instead of being generic. Other structured actions ('active_goals', 'open_questions', etc.) only when the user explicitly asks.",
1006
1015
  inputSchema: {
1007
1016
  type: "object",
1008
1017
  properties: {
@@ -1018,6 +1027,7 @@ var init_tools = __esm({
1018
1027
  "weak_claims",
1019
1028
  "pending_approvals",
1020
1029
  "unresolved_contradictions",
1030
+ "preferences",
1021
1031
  "layer",
1022
1032
  "recent",
1023
1033
  "chain",
@@ -1301,6 +1311,84 @@ var init_tools = __esm({
1301
1311
  }
1302
1312
  });
1303
1313
 
1314
+ // src/generated-tools.ts
1315
+ async function getGeneratedTools(client2) {
1316
+ if (cache && Date.now() - cache.fetchedAt < CACHE_TTL_MS) {
1317
+ return { tools: cache.tools, byName: cache.byName };
1318
+ }
1319
+ try {
1320
+ const c = client2;
1321
+ if (typeof c.listOntologyTools !== "function") {
1322
+ cache = { tools: [], byName: /* @__PURE__ */ new Map(), fetchedAt: Date.now() };
1323
+ return { tools: cache.tools, byName: cache.byName };
1324
+ }
1325
+ const resp = await c.listOntologyTools();
1326
+ const byName = /* @__PURE__ */ new Map();
1327
+ const tools = [];
1328
+ for (const d of resp.tools ?? []) {
1329
+ byName.set(d.name, d);
1330
+ tools.push({
1331
+ name: d.name,
1332
+ description: d.description,
1333
+ inputSchema: d.input_schema
1334
+ });
1335
+ }
1336
+ cache = { tools, byName, fetchedAt: Date.now() };
1337
+ return { tools, byName };
1338
+ } catch {
1339
+ cache = { tools: [], byName: /* @__PURE__ */ new Map(), fetchedAt: Date.now() };
1340
+ return { tools: cache.tools, byName: cache.byName };
1341
+ }
1342
+ }
1343
+ async function handleGeneratedTool(client2, desc, args) {
1344
+ try {
1345
+ switch (desc.maps_to) {
1346
+ case "search": {
1347
+ const query = args.query;
1348
+ if (!query) return err2(`query is required for ${desc.name}`);
1349
+ const limit = typeof args.limit === "number" ? args.limit : void 0;
1350
+ return ok2(
1351
+ await client2.searchDomainObjects(query, {
1352
+ schema_id: desc.schema_id,
1353
+ object_types: [desc.object_type],
1354
+ limit
1355
+ })
1356
+ );
1357
+ }
1358
+ case "object": {
1359
+ const uid = args.uid;
1360
+ if (!uid) return err2(`uid is required for ${desc.name}`);
1361
+ return ok2(await client2.getDomainObject(uid));
1362
+ }
1363
+ case "object_context": {
1364
+ const uid = args.uid;
1365
+ if (!uid) return err2(`uid is required for ${desc.name}`);
1366
+ const depth = typeof args.depth === "number" ? args.depth : void 0;
1367
+ return ok2(await client2.getDomainObjectContext(uid, depth));
1368
+ }
1369
+ default:
1370
+ return err2(`unknown generated tool mapping: ${desc.maps_to}`);
1371
+ }
1372
+ } catch (e) {
1373
+ return err2(e instanceof Error ? e.message : String(e));
1374
+ }
1375
+ }
1376
+ var ok2, err2, CACHE_TTL_MS, cache;
1377
+ var init_generated_tools = __esm({
1378
+ "src/generated-tools.ts"() {
1379
+ "use strict";
1380
+ ok2 = (data) => ({
1381
+ content: [{ type: "text", text: JSON.stringify(data, null, 2) }]
1382
+ });
1383
+ err2 = (message) => ({
1384
+ content: [{ type: "text", text: JSON.stringify({ error: message }) }],
1385
+ isError: true
1386
+ });
1387
+ CACHE_TTL_MS = 5 * 60 * 1e3;
1388
+ cache = null;
1389
+ }
1390
+ });
1391
+
1304
1392
  // src/index.ts
1305
1393
  var src_exports = {};
1306
1394
  async function main() {
@@ -1319,6 +1407,7 @@ var init_src = __esm({
1319
1407
  import_types = require("@modelcontextprotocol/sdk/types.js");
1320
1408
  import_mindgraph = require("mindgraph");
1321
1409
  init_tools();
1410
+ init_generated_tools();
1322
1411
  API_KEY = process.env.MINDGRAPH_API_KEY;
1323
1412
  BASE_URL = process.env.MINDGRAPH_BASE_URL || "https://api.mindgraph.cloud";
1324
1413
  AGENT_ID = process.env.MINDGRAPH_AGENT_ID || "mcp";
@@ -1383,6 +1472,7 @@ If keyword search returns no results, escalate:
1383
1472
  - User asks "what documents are in my graph?" \u2192 action "document_index"
1384
1473
  - User explicitly asks "what are my goals?" \u2192 action "active_goals"
1385
1474
  - User explicitly asks about open questions \u2192 action "open_questions"
1475
+ - User asks for advice or a recommendation ("suggest a hotel", "what should I read?") \u2192 action "preferences", query "topic keywords" \u2014 tailor the answer to what they like
1386
1476
  - Explore around a known node \u2192 action "neighborhood" with start_uid
1387
1477
  - Find connections between nodes \u2192 action "path" with start_uid + end_uid
1388
1478
 
@@ -1411,7 +1501,7 @@ Capture knowledge when the user shares something worth remembering:
1411
1501
  server = new import_server.Server(
1412
1502
  {
1413
1503
  name: "mindgraph",
1414
- version: "0.7.1"
1504
+ version: "0.9.1"
1415
1505
  },
1416
1506
  {
1417
1507
  capabilities: {
@@ -1423,7 +1513,8 @@ Capture knowledge when the user shares something worth remembering:
1423
1513
  }
1424
1514
  );
1425
1515
  server.setRequestHandler(import_types.ListToolsRequestSchema, async () => {
1426
- return { tools: TOOLS };
1516
+ const generated = await getGeneratedTools(client);
1517
+ return { tools: [...TOOLS, ...generated.tools] };
1427
1518
  });
1428
1519
  server.setRequestHandler(import_types.CallToolRequestSchema, async (request) => {
1429
1520
  const { name, arguments: args } = request.params;
@@ -1431,6 +1522,11 @@ Capture knowledge when the user shares something worth remembering:
1431
1522
  if (!toolArgs.agent_id) {
1432
1523
  toolArgs.agent_id = AGENT_ID;
1433
1524
  }
1525
+ const generated = await getGeneratedTools(client);
1526
+ const desc = generated.byName.get(name);
1527
+ if (desc) {
1528
+ return handleGeneratedTool(client, desc, toolArgs);
1529
+ }
1434
1530
  return handleTool(client, name, toolArgs);
1435
1531
  });
1436
1532
  PROMPTS = [
package/dist/index.js CHANGED
@@ -297,7 +297,7 @@ var TOOLS = [
297
297
  },
298
298
  {
299
299
  name: "mindgraph_retrieve",
300
- description: "Search and explore the knowledge graph. Use 'context' (default) for BM25 keyword retrieval \u2014 returns graph nodes only by default (labels, summaries, types, confidence); set include_chunks=true to also get full source text. Pass 1-3 discriminating keywords, not sentences. GOOD: 'Kissinger NATO'. BAD: 'What is Kissinger\\'s view on NATO?'. Use 'document_index' to list all ingested documents (titles, dates, UIDs) for orientation. Use 'semantic' when keywords return nothing \u2014 conceptual/fuzzy queries. Use 'hybrid' for keyword + semantic. Use 'text' for fast keyword-only. Use 'neighborhood'/'chain'/'path'/'subgraph' for graph traversal. Other actions ('active_goals', 'open_questions', etc.) only when the user explicitly asks.",
300
+ description: "Search and explore the knowledge graph. Use 'context' (default) for BM25 keyword retrieval \u2014 returns graph nodes only by default (labels, summaries, types, confidence); set include_chunks=true to also get full source text. Pass 1-3 discriminating keywords, not sentences. GOOD: 'Kissinger NATO'. BAD: 'What is Kissinger\\'s view on NATO?'. Use 'document_index' to list all ingested documents (titles, dates, UIDs) for orientation. Use 'semantic' when keywords return nothing \u2014 conceptual/fuzzy queries. Use 'hybrid' for keyword + semantic. Use 'text' for fast keyword-only. Use 'neighborhood'/'chain'/'path'/'subgraph' for graph traversal \u2014 traversal steps carry path_cost (lower = stronger connection; sum of -ln(edge weight)) and path_confidence (product of edge confidences; a ranking signal, not a calibrated probability) for the returned path, useful for ranking results; they score the path returned, not the best possible path. Use 'preferences' for advice or recommendation requests ('suggest a hotel', 'what should I read?') \u2014 it returns the user's stated/learned preferences relevant to the query (pass the topic as 'query'), so your answer reflects what they actually like instead of being generic. Other structured actions ('active_goals', 'open_questions', etc.) only when the user explicitly asks.",
301
301
  inputSchema: {
302
302
  type: "object",
303
303
  properties: {
@@ -313,6 +313,7 @@ var TOOLS = [
313
313
  "weak_claims",
314
314
  "pending_approvals",
315
315
  "unresolved_contradictions",
316
+ "preferences",
316
317
  "layer",
317
318
  "recent",
318
319
  "chain",
@@ -1011,6 +1012,15 @@ async function handleRetrieve(client2, args) {
1011
1012
  return ok(await client2.getPendingApprovals());
1012
1013
  case "unresolved_contradictions":
1013
1014
  return ok(await client2.getContradictions());
1015
+ case "preferences":
1016
+ return ok(
1017
+ await client2.retrieve({
1018
+ action: "preferences",
1019
+ ...query ? { query, k: limit } : {},
1020
+ limit,
1021
+ agent_id
1022
+ })
1023
+ );
1014
1024
  case "layer":
1015
1025
  if (!layer) return err("layer is required for layer retrieval");
1016
1026
  return ok(
@@ -1275,6 +1285,78 @@ async function handleOntology(client2, args) {
1275
1285
  }
1276
1286
  }
1277
1287
 
1288
+ // src/generated-tools.ts
1289
+ var ok2 = (data) => ({
1290
+ content: [{ type: "text", text: JSON.stringify(data, null, 2) }]
1291
+ });
1292
+ var err2 = (message) => ({
1293
+ content: [{ type: "text", text: JSON.stringify({ error: message }) }],
1294
+ isError: true
1295
+ });
1296
+ var CACHE_TTL_MS = 5 * 60 * 1e3;
1297
+ var cache = null;
1298
+ async function getGeneratedTools(client2) {
1299
+ if (cache && Date.now() - cache.fetchedAt < CACHE_TTL_MS) {
1300
+ return { tools: cache.tools, byName: cache.byName };
1301
+ }
1302
+ try {
1303
+ const c = client2;
1304
+ if (typeof c.listOntologyTools !== "function") {
1305
+ cache = { tools: [], byName: /* @__PURE__ */ new Map(), fetchedAt: Date.now() };
1306
+ return { tools: cache.tools, byName: cache.byName };
1307
+ }
1308
+ const resp = await c.listOntologyTools();
1309
+ const byName = /* @__PURE__ */ new Map();
1310
+ const tools = [];
1311
+ for (const d of resp.tools ?? []) {
1312
+ byName.set(d.name, d);
1313
+ tools.push({
1314
+ name: d.name,
1315
+ description: d.description,
1316
+ inputSchema: d.input_schema
1317
+ });
1318
+ }
1319
+ cache = { tools, byName, fetchedAt: Date.now() };
1320
+ return { tools, byName };
1321
+ } catch {
1322
+ cache = { tools: [], byName: /* @__PURE__ */ new Map(), fetchedAt: Date.now() };
1323
+ return { tools: cache.tools, byName: cache.byName };
1324
+ }
1325
+ }
1326
+ async function handleGeneratedTool(client2, desc, args) {
1327
+ try {
1328
+ switch (desc.maps_to) {
1329
+ case "search": {
1330
+ const query = args.query;
1331
+ if (!query) return err2(`query is required for ${desc.name}`);
1332
+ const limit = typeof args.limit === "number" ? args.limit : void 0;
1333
+ return ok2(
1334
+ await client2.searchDomainObjects(query, {
1335
+ schema_id: desc.schema_id,
1336
+ object_types: [desc.object_type],
1337
+ limit
1338
+ })
1339
+ );
1340
+ }
1341
+ case "object": {
1342
+ const uid = args.uid;
1343
+ if (!uid) return err2(`uid is required for ${desc.name}`);
1344
+ return ok2(await client2.getDomainObject(uid));
1345
+ }
1346
+ case "object_context": {
1347
+ const uid = args.uid;
1348
+ if (!uid) return err2(`uid is required for ${desc.name}`);
1349
+ const depth = typeof args.depth === "number" ? args.depth : void 0;
1350
+ return ok2(await client2.getDomainObjectContext(uid, depth));
1351
+ }
1352
+ default:
1353
+ return err2(`unknown generated tool mapping: ${desc.maps_to}`);
1354
+ }
1355
+ } catch (e) {
1356
+ return err2(e instanceof Error ? e.message : String(e));
1357
+ }
1358
+ }
1359
+
1278
1360
  // src/index.ts
1279
1361
  var API_KEY = process.env.MINDGRAPH_API_KEY;
1280
1362
  var BASE_URL = process.env.MINDGRAPH_BASE_URL || "https://api.mindgraph.cloud";
@@ -1340,6 +1422,7 @@ If keyword search returns no results, escalate:
1340
1422
  - User asks "what documents are in my graph?" \u2192 action "document_index"
1341
1423
  - User explicitly asks "what are my goals?" \u2192 action "active_goals"
1342
1424
  - User explicitly asks about open questions \u2192 action "open_questions"
1425
+ - User asks for advice or a recommendation ("suggest a hotel", "what should I read?") \u2192 action "preferences", query "topic keywords" \u2014 tailor the answer to what they like
1343
1426
  - Explore around a known node \u2192 action "neighborhood" with start_uid
1344
1427
  - Find connections between nodes \u2192 action "path" with start_uid + end_uid
1345
1428
 
@@ -1368,7 +1451,7 @@ Capture knowledge when the user shares something worth remembering:
1368
1451
  var server = new import_server.Server(
1369
1452
  {
1370
1453
  name: "mindgraph",
1371
- version: "0.7.1"
1454
+ version: "0.9.1"
1372
1455
  },
1373
1456
  {
1374
1457
  capabilities: {
@@ -1380,7 +1463,8 @@ var server = new import_server.Server(
1380
1463
  }
1381
1464
  );
1382
1465
  server.setRequestHandler(import_types.ListToolsRequestSchema, async () => {
1383
- return { tools: TOOLS };
1466
+ const generated = await getGeneratedTools(client);
1467
+ return { tools: [...TOOLS, ...generated.tools] };
1384
1468
  });
1385
1469
  server.setRequestHandler(import_types.CallToolRequestSchema, async (request) => {
1386
1470
  const { name, arguments: args } = request.params;
@@ -1388,6 +1472,11 @@ server.setRequestHandler(import_types.CallToolRequestSchema, async (request) =>
1388
1472
  if (!toolArgs.agent_id) {
1389
1473
  toolArgs.agent_id = AGENT_ID;
1390
1474
  }
1475
+ const generated = await getGeneratedTools(client);
1476
+ const desc = generated.byName.get(name);
1477
+ if (desc) {
1478
+ return handleGeneratedTool(client, desc, toolArgs);
1479
+ }
1391
1480
  return handleTool(client, name, toolArgs);
1392
1481
  });
1393
1482
  var PROMPTS = [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mindgraph-mcp",
3
- "version": "0.8.0",
3
+ "version": "0.9.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",
@@ -13,6 +13,7 @@
13
13
  "scripts": {
14
14
  "build": "tsup",
15
15
  "lint": "tsc --noEmit",
16
+ "test": "vitest run",
16
17
  "dev": "tsup --watch"
17
18
  },
18
19
  "keywords": [
@@ -27,11 +28,12 @@
27
28
  "license": "MIT",
28
29
  "dependencies": {
29
30
  "@modelcontextprotocol/sdk": "^1.12.1",
30
- "mindgraph": "^0.5.0"
31
+ "mindgraph": "^0.9.0"
31
32
  },
32
33
  "devDependencies": {
33
34
  "@types/node": "^22.0.0",
34
35
  "tsup": "^8.0.0",
35
- "typescript": "^5.7.0"
36
+ "typescript": "^5.7.0",
37
+ "vitest": "^3.0.0"
36
38
  }
37
39
  }