@chinjinyu/mcp-knowledge-graph-plus 0.1.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 (110) hide show
  1. package/README.md +700 -0
  2. package/dist/application/services/FactService.d.ts +16 -0
  3. package/dist/application/services/FactService.d.ts.map +1 -0
  4. package/dist/application/services/FactService.js +50 -0
  5. package/dist/application/services/FactService.js.map +1 -0
  6. package/dist/application/services/KnowledgeGraphService.d.ts +33 -0
  7. package/dist/application/services/KnowledgeGraphService.d.ts.map +1 -0
  8. package/dist/application/services/KnowledgeGraphService.js +271 -0
  9. package/dist/application/services/KnowledgeGraphService.js.map +1 -0
  10. package/dist/application/services/LinkService.d.ts +17 -0
  11. package/dist/application/services/LinkService.d.ts.map +1 -0
  12. package/dist/application/services/LinkService.js +53 -0
  13. package/dist/application/services/LinkService.js.map +1 -0
  14. package/dist/application/services/NodeService.d.ts +31 -0
  15. package/dist/application/services/NodeService.d.ts.map +1 -0
  16. package/dist/application/services/NodeService.js +69 -0
  17. package/dist/application/services/NodeService.js.map +1 -0
  18. package/dist/core/config/index.d.ts +34 -0
  19. package/dist/core/config/index.d.ts.map +1 -0
  20. package/dist/core/config/index.js +60 -0
  21. package/dist/core/config/index.js.map +1 -0
  22. package/dist/core/errors/index.d.ts +70 -0
  23. package/dist/core/errors/index.d.ts.map +1 -0
  24. package/dist/core/errors/index.js +120 -0
  25. package/dist/core/errors/index.js.map +1 -0
  26. package/dist/core/types/index.d.ts +119 -0
  27. package/dist/core/types/index.d.ts.map +1 -0
  28. package/dist/core/types/index.js +5 -0
  29. package/dist/core/types/index.js.map +1 -0
  30. package/dist/index.d.ts +5 -0
  31. package/dist/index.d.ts.map +1 -0
  32. package/dist/index.js +117 -0
  33. package/dist/index.js.map +1 -0
  34. package/dist/infrastructure/database/DatabaseManager.d.ts +13 -0
  35. package/dist/infrastructure/database/DatabaseManager.d.ts.map +1 -0
  36. package/dist/infrastructure/database/DatabaseManager.js +101 -0
  37. package/dist/infrastructure/database/DatabaseManager.js.map +1 -0
  38. package/dist/infrastructure/di/Container.d.ts +21 -0
  39. package/dist/infrastructure/di/Container.d.ts.map +1 -0
  40. package/dist/infrastructure/di/Container.js +45 -0
  41. package/dist/infrastructure/di/Container.js.map +1 -0
  42. package/dist/infrastructure/repositories/BaseRepository.d.ts +23 -0
  43. package/dist/infrastructure/repositories/BaseRepository.d.ts.map +1 -0
  44. package/dist/infrastructure/repositories/BaseRepository.js +84 -0
  45. package/dist/infrastructure/repositories/BaseRepository.js.map +1 -0
  46. package/dist/infrastructure/repositories/FactRepository.d.ts +28 -0
  47. package/dist/infrastructure/repositories/FactRepository.d.ts.map +1 -0
  48. package/dist/infrastructure/repositories/FactRepository.js +101 -0
  49. package/dist/infrastructure/repositories/FactRepository.js.map +1 -0
  50. package/dist/infrastructure/repositories/LinkRepository.d.ts +28 -0
  51. package/dist/infrastructure/repositories/LinkRepository.d.ts.map +1 -0
  52. package/dist/infrastructure/repositories/LinkRepository.js +107 -0
  53. package/dist/infrastructure/repositories/LinkRepository.js.map +1 -0
  54. package/dist/infrastructure/repositories/NodeRepository.d.ts +28 -0
  55. package/dist/infrastructure/repositories/NodeRepository.d.ts.map +1 -0
  56. package/dist/infrastructure/repositories/NodeRepository.js +143 -0
  57. package/dist/infrastructure/repositories/NodeRepository.js.map +1 -0
  58. package/dist/interfaces/mcp/commands/BaseCommand.d.ts +55 -0
  59. package/dist/interfaces/mcp/commands/BaseCommand.d.ts.map +1 -0
  60. package/dist/interfaces/mcp/commands/BaseCommand.js +42 -0
  61. package/dist/interfaces/mcp/commands/BaseCommand.js.map +1 -0
  62. package/dist/interfaces/mcp/commands/FactAddCommand.d.ts +42 -0
  63. package/dist/interfaces/mcp/commands/FactAddCommand.d.ts.map +1 -0
  64. package/dist/interfaces/mcp/commands/FactAddCommand.js +73 -0
  65. package/dist/interfaces/mcp/commands/FactAddCommand.js.map +1 -0
  66. package/dist/interfaces/mcp/commands/FactDelCommand.d.ts +42 -0
  67. package/dist/interfaces/mcp/commands/FactDelCommand.d.ts.map +1 -0
  68. package/dist/interfaces/mcp/commands/FactDelCommand.js +68 -0
  69. package/dist/interfaces/mcp/commands/FactDelCommand.js.map +1 -0
  70. package/dist/interfaces/mcp/commands/FactEditCommand.d.ts +43 -0
  71. package/dist/interfaces/mcp/commands/FactEditCommand.d.ts.map +1 -0
  72. package/dist/interfaces/mcp/commands/FactEditCommand.js +68 -0
  73. package/dist/interfaces/mcp/commands/FactEditCommand.js.map +1 -0
  74. package/dist/interfaces/mcp/commands/LinkAddCommand.d.ts +43 -0
  75. package/dist/interfaces/mcp/commands/LinkAddCommand.d.ts.map +1 -0
  76. package/dist/interfaces/mcp/commands/LinkAddCommand.js +63 -0
  77. package/dist/interfaces/mcp/commands/LinkAddCommand.js.map +1 -0
  78. package/dist/interfaces/mcp/commands/LinkDelCommand.d.ts +43 -0
  79. package/dist/interfaces/mcp/commands/LinkDelCommand.d.ts.map +1 -0
  80. package/dist/interfaces/mcp/commands/LinkDelCommand.js +65 -0
  81. package/dist/interfaces/mcp/commands/LinkDelCommand.js.map +1 -0
  82. package/dist/interfaces/mcp/commands/LinkEditCommand.d.ts +47 -0
  83. package/dist/interfaces/mcp/commands/LinkEditCommand.d.ts.map +1 -0
  84. package/dist/interfaces/mcp/commands/LinkEditCommand.js +75 -0
  85. package/dist/interfaces/mcp/commands/LinkEditCommand.js.map +1 -0
  86. package/dist/interfaces/mcp/commands/ListCommand.d.ts +33 -0
  87. package/dist/interfaces/mcp/commands/ListCommand.d.ts.map +1 -0
  88. package/dist/interfaces/mcp/commands/ListCommand.js +57 -0
  89. package/dist/interfaces/mcp/commands/ListCommand.js.map +1 -0
  90. package/dist/interfaces/mcp/commands/NodeAddCommand.d.ts +46 -0
  91. package/dist/interfaces/mcp/commands/NodeAddCommand.d.ts.map +1 -0
  92. package/dist/interfaces/mcp/commands/NodeAddCommand.js +67 -0
  93. package/dist/interfaces/mcp/commands/NodeAddCommand.js.map +1 -0
  94. package/dist/interfaces/mcp/commands/NodeDelCommand.d.ts +32 -0
  95. package/dist/interfaces/mcp/commands/NodeDelCommand.d.ts.map +1 -0
  96. package/dist/interfaces/mcp/commands/NodeDelCommand.js +63 -0
  97. package/dist/interfaces/mcp/commands/NodeDelCommand.js.map +1 -0
  98. package/dist/interfaces/mcp/commands/NodeEditCommand.d.ts +43 -0
  99. package/dist/interfaces/mcp/commands/NodeEditCommand.d.ts.map +1 -0
  100. package/dist/interfaces/mcp/commands/NodeEditCommand.js +63 -0
  101. package/dist/interfaces/mcp/commands/NodeEditCommand.js.map +1 -0
  102. package/dist/interfaces/mcp/commands/NodeGetCommand.d.ts +40 -0
  103. package/dist/interfaces/mcp/commands/NodeGetCommand.d.ts.map +1 -0
  104. package/dist/interfaces/mcp/commands/NodeGetCommand.js +72 -0
  105. package/dist/interfaces/mcp/commands/NodeGetCommand.js.map +1 -0
  106. package/dist/interfaces/mcp/commands/SearchCommand.d.ts +53 -0
  107. package/dist/interfaces/mcp/commands/SearchCommand.d.ts.map +1 -0
  108. package/dist/interfaces/mcp/commands/SearchCommand.js +91 -0
  109. package/dist/interfaces/mcp/commands/SearchCommand.js.map +1 -0
  110. package/package.json +10 -0
@@ -0,0 +1,43 @@
1
+ import { BaseCommand } from './BaseCommand.js';
2
+ import type { LinkService } from '../../../application/services/LinkService.js';
3
+ export declare class LinkAddCommand extends BaseCommand<any, any> {
4
+ private readonly linkService;
5
+ readonly name = "kg_link_add";
6
+ readonly description = "Create directed links between nodes. Each link connects a \"from\" node to a \"to\" node with a relationship type. Duplicate links (same from, to, and type) are silently ignored.\n\nExamples:\n1. Create a single link:\n { \"links\": [{ \"from\": \"Alice\", \"to\": \"TechCorp\", \"type\": \"works_at\" }] }\n\n2. Create multiple links:\n { \"links\": [{ \"from\": \"Alice\", \"to\": \"Bob\", \"type\": \"manages\" }, { \"from\": \"Bob\", \"to\": \"ProjectX\", \"type\": \"assigned_to\" }] }\n\n3. Create bidirectional relationship:\n { \"links\": [{ \"from\": \"Alice\", \"to\": \"Bob\", \"type\": \"collaborates_with\" }, { \"from\": \"Bob\", \"to\": \"Alice\", \"type\": \"collaborates_with\" }] }";
7
+ readonly inputSchema: {
8
+ type: string;
9
+ properties: {
10
+ links: {
11
+ type: string;
12
+ description: string;
13
+ items: {
14
+ type: string;
15
+ properties: {
16
+ from: {
17
+ type: string;
18
+ description: string;
19
+ };
20
+ to: {
21
+ type: string;
22
+ description: string;
23
+ };
24
+ type: {
25
+ type: string;
26
+ description: string;
27
+ };
28
+ };
29
+ required: string[];
30
+ };
31
+ };
32
+ };
33
+ required: string[];
34
+ };
35
+ constructor(linkService: LinkService);
36
+ execute(input: any): Promise<{
37
+ content: Array<{
38
+ type: 'text';
39
+ text: string;
40
+ }>;
41
+ }>;
42
+ }
43
+ //# sourceMappingURL=LinkAddCommand.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LinkAddCommand.d.ts","sourceRoot":"","sources":["../../../../src/interfaces/mcp/commands/LinkAddCommand.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,8CAA8C,CAAC;AAEhF,qBAAa,cAAe,SAAQ,WAAW,CAAC,GAAG,EAAE,GAAG,CAAC;IAiC3C,OAAO,CAAC,QAAQ,CAAC,WAAW;IAhCxC,QAAQ,CAAC,IAAI,iBAAiB;IAC9B,QAAQ,CAAC,WAAW,usBAU0H;IAC9I,QAAQ,CAAC,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;MAkBlB;gBAE2B,WAAW,EAAE,WAAW;IAI/C,OAAO,CAAC,KAAK,EAAE,GAAG,GAAG,OAAO,CAAC;QAAE,OAAO,EAAE,KAAK,CAAC;YAAE,IAAI,EAAE,MAAM,CAAC;YAAC,IAAI,EAAE,MAAM,CAAA;SAAE,CAAC,CAAA;KAAE,CAAC;CA2BvF"}
@@ -0,0 +1,63 @@
1
+ import { BaseCommand } from './BaseCommand.js';
2
+ export class LinkAddCommand extends BaseCommand {
3
+ linkService;
4
+ name = 'kg_link_add';
5
+ description = `Create directed links between nodes. Each link connects a "from" node to a "to" node with a relationship type. Duplicate links (same from, to, and type) are silently ignored.
6
+
7
+ Examples:
8
+ 1. Create a single link:
9
+ { "links": [{ "from": "Alice", "to": "TechCorp", "type": "works_at" }] }
10
+
11
+ 2. Create multiple links:
12
+ { "links": [{ "from": "Alice", "to": "Bob", "type": "manages" }, { "from": "Bob", "to": "ProjectX", "type": "assigned_to" }] }
13
+
14
+ 3. Create bidirectional relationship:
15
+ { "links": [{ "from": "Alice", "to": "Bob", "type": "collaborates_with" }, { "from": "Bob", "to": "Alice", "type": "collaborates_with" }] }`;
16
+ inputSchema = {
17
+ type: 'object',
18
+ properties: {
19
+ links: {
20
+ type: 'array',
21
+ description: 'Array of links to create. Each link requires from, to, and type.',
22
+ items: {
23
+ type: 'object',
24
+ properties: {
25
+ from: { type: 'string', description: 'Name of the source node' },
26
+ to: { type: 'string', description: 'Name of the target node' },
27
+ type: { type: 'string', description: 'Relationship type (e.g., works_at, manages, knows)' },
28
+ },
29
+ required: ['from', 'to', 'type'],
30
+ },
31
+ },
32
+ },
33
+ required: ['links'],
34
+ };
35
+ constructor(linkService) {
36
+ super();
37
+ this.linkService = linkService;
38
+ }
39
+ async execute(input) {
40
+ // Validate array parameters
41
+ this.validateArray(input.links, 'links', {
42
+ description: 'Provide an array of links to create',
43
+ example: '{"links": [{"from": "Alice", "to": "Bob", "type": "knows"}]}',
44
+ });
45
+ const links = await this.linkService.createLinks(input.links);
46
+ const nodeIds = new Set();
47
+ for (const link of links) {
48
+ nodeIds.add(link.fromNodeId);
49
+ nodeIds.add(link.toNodeId);
50
+ }
51
+ const nodeMap = await this.linkService.getNodeNameMap(Array.from(nodeIds));
52
+ const output = {
53
+ added: links.length,
54
+ links: links.map(l => ({
55
+ from: nodeMap.get(l.fromNodeId) || '',
56
+ to: nodeMap.get(l.toNodeId) || '',
57
+ type: l.type,
58
+ })),
59
+ };
60
+ return { content: [{ type: 'text', text: JSON.stringify(output) }] };
61
+ }
62
+ }
63
+ //# sourceMappingURL=LinkAddCommand.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LinkAddCommand.js","sourceRoot":"","sources":["../../../../src/interfaces/mcp/commands/LinkAddCommand.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAG/C,MAAM,OAAO,cAAe,SAAQ,WAAqB;IAiC1B;IAhCpB,IAAI,GAAG,aAAa,CAAC;IACrB,WAAW,GAAG;;;;;;;;;;+IAUsH,CAAC;IACrI,WAAW,GAAG;QACrB,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,KAAK,EAAE;gBACL,IAAI,EAAE,OAAO;gBACb,WAAW,EAAE,kEAAkE;gBAC/E,KAAK,EAAE;oBACL,IAAI,EAAE,QAAQ;oBACd,UAAU,EAAE;wBACV,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,yBAAyB,EAAE;wBAChE,EAAE,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,yBAAyB,EAAE;wBAC9D,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,oDAAoD,EAAE;qBAC5F;oBACD,QAAQ,EAAE,CAAC,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC;iBACjC;aACF;SACF;QACD,QAAQ,EAAE,CAAC,OAAO,CAAC;KACpB,CAAC;IAEF,YAA6B,WAAwB;QACnD,KAAK,EAAE,CAAC;QADmB,gBAAW,GAAX,WAAW,CAAa;IAErD,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,KAAU;QACtB,4BAA4B;QAC5B,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,KAAK,EAAE,OAAO,EAAE;YACvC,WAAW,EAAE,qCAAqC;YAClD,OAAO,EAAE,8DAA8D;SACxE,CAAC,CAAC;QAEH,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,WAAW,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QAE9D,MAAM,OAAO,GAAG,IAAI,GAAG,EAAU,CAAC;QAClC,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;YACzB,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;YAC7B,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAC7B,CAAC;QACD,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,cAAc,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;QAE3E,MAAM,MAAM,GAAG;YACb,KAAK,EAAE,KAAK,CAAC,MAAM;YACnB,KAAK,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;gBACrB,IAAI,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,UAAU,CAAC,IAAI,EAAE;gBACrC,EAAE,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,EAAE;gBACjC,IAAI,EAAE,CAAC,CAAC,IAAI;aACb,CAAC,CAAC;SACJ,CAAC;QAEF,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,CAAC;IACvE,CAAC;CACF"}
@@ -0,0 +1,43 @@
1
+ import { BaseCommand } from './BaseCommand.js';
2
+ import type { LinkService } from '../../../application/services/LinkService.js';
3
+ export declare class LinkDelCommand extends BaseCommand<any, any> {
4
+ private readonly linkService;
5
+ readonly name = "kg_link_del";
6
+ readonly description = "Delete specific links from the knowledge graph. You must specify the exact link (from, to, and type) to delete. Non-existent links are silently ignored.\n\nExamples:\n1. Delete a single link:\n { \"links\": [{ \"from\": \"Alice\", \"to\": \"TechCorp\", \"type\": \"works_at\" }] }\n\n2. Delete multiple links:\n { \"links\": [{ \"from\": \"Alice\", \"to\": \"Bob\", \"type\": \"manages\" }, { \"from\": \"Alice\", \"to\": \"OldProject\", \"type\": \"assigned_to\" }] }\n\n3. Delete all links of a specific type between nodes:\n { \"links\": [{ \"from\": \"Alice\", \"to\": \"Bob\", \"type\": \"collaborates_with\" }] }";
7
+ readonly inputSchema: {
8
+ type: string;
9
+ properties: {
10
+ links: {
11
+ type: string;
12
+ description: string;
13
+ items: {
14
+ type: string;
15
+ properties: {
16
+ from: {
17
+ type: string;
18
+ description: string;
19
+ };
20
+ to: {
21
+ type: string;
22
+ description: string;
23
+ };
24
+ type: {
25
+ type: string;
26
+ description: string;
27
+ };
28
+ };
29
+ required: string[];
30
+ };
31
+ };
32
+ };
33
+ required: string[];
34
+ };
35
+ constructor(linkService: LinkService);
36
+ execute(input: any): Promise<{
37
+ content: Array<{
38
+ type: 'text';
39
+ text: string;
40
+ }>;
41
+ }>;
42
+ }
43
+ //# sourceMappingURL=LinkDelCommand.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LinkDelCommand.d.ts","sourceRoot":"","sources":["../../../../src/interfaces/mcp/commands/LinkDelCommand.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,8CAA8C,CAAC;AAEhF,qBAAa,cAAe,SAAQ,WAAW,CAAC,GAAG,EAAE,GAAG,CAAC;IAiC3C,OAAO,CAAC,QAAQ,CAAC,WAAW;IAhCxC,QAAQ,CAAC,IAAI,iBAAiB;IAC9B,QAAQ,CAAC,WAAW,snBAU2D;IAC/E,QAAQ,CAAC,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;MAkBlB;gBAE2B,WAAW,EAAE,WAAW;IAI/C,OAAO,CAAC,KAAK,EAAE,GAAG,GAAG,OAAO,CAAC;QAAE,OAAO,EAAE,KAAK,CAAC;YAAE,IAAI,EAAE,MAAM,CAAC;YAAC,IAAI,EAAE,MAAM,CAAA;SAAE,CAAC,CAAA;KAAE,CAAC;CA4BvF"}
@@ -0,0 +1,65 @@
1
+ import { BaseCommand } from './BaseCommand.js';
2
+ export class LinkDelCommand extends BaseCommand {
3
+ linkService;
4
+ name = 'kg_link_del';
5
+ description = `Delete specific links from the knowledge graph. You must specify the exact link (from, to, and type) to delete. Non-existent links are silently ignored.
6
+
7
+ Examples:
8
+ 1. Delete a single link:
9
+ { "links": [{ "from": "Alice", "to": "TechCorp", "type": "works_at" }] }
10
+
11
+ 2. Delete multiple links:
12
+ { "links": [{ "from": "Alice", "to": "Bob", "type": "manages" }, { "from": "Alice", "to": "OldProject", "type": "assigned_to" }] }
13
+
14
+ 3. Delete all links of a specific type between nodes:
15
+ { "links": [{ "from": "Alice", "to": "Bob", "type": "collaborates_with" }] }`;
16
+ inputSchema = {
17
+ type: 'object',
18
+ properties: {
19
+ links: {
20
+ type: 'array',
21
+ description: 'Array of links to delete. Each item must match exactly (from, to, type).',
22
+ items: {
23
+ type: 'object',
24
+ properties: {
25
+ from: { type: 'string', description: 'Name of the source node' },
26
+ to: { type: 'string', description: 'Name of the target node' },
27
+ type: { type: 'string', description: 'Relationship type to delete' },
28
+ },
29
+ required: ['from', 'to', 'type'],
30
+ },
31
+ },
32
+ },
33
+ required: ['links'],
34
+ };
35
+ constructor(linkService) {
36
+ super();
37
+ this.linkService = linkService;
38
+ }
39
+ async execute(input) {
40
+ // Validate array parameters
41
+ this.validateArray(input.links, 'links', {
42
+ description: 'Provide an array of links to delete',
43
+ example: '{"links": [{"from": "Alice", "to": "Bob", "type": "knows"}]}',
44
+ });
45
+ let count = 0;
46
+ const deletedLinks = [];
47
+ for (const link of input.links) {
48
+ const deleted = await this.linkService.deleteLinksByNames(link.from, link.to, link.type);
49
+ if (deleted > 0) {
50
+ count += deleted;
51
+ deletedLinks.push(link);
52
+ }
53
+ }
54
+ return {
55
+ content: [{
56
+ type: 'text',
57
+ text: JSON.stringify({
58
+ deleted: count,
59
+ links: deletedLinks,
60
+ }),
61
+ }],
62
+ };
63
+ }
64
+ }
65
+ //# sourceMappingURL=LinkDelCommand.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LinkDelCommand.js","sourceRoot":"","sources":["../../../../src/interfaces/mcp/commands/LinkDelCommand.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAG/C,MAAM,OAAO,cAAe,SAAQ,WAAqB;IAiC1B;IAhCpB,IAAI,GAAG,aAAa,CAAC;IACrB,WAAW,GAAG;;;;;;;;;;gFAUuD,CAAC;IACtE,WAAW,GAAG;QACrB,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,KAAK,EAAE;gBACL,IAAI,EAAE,OAAO;gBACb,WAAW,EAAE,0EAA0E;gBACvF,KAAK,EAAE;oBACL,IAAI,EAAE,QAAQ;oBACd,UAAU,EAAE;wBACV,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,yBAAyB,EAAE;wBAChE,EAAE,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,yBAAyB,EAAE;wBAC9D,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,6BAA6B,EAAE;qBACrE;oBACD,QAAQ,EAAE,CAAC,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC;iBACjC;aACF;SACF;QACD,QAAQ,EAAE,CAAC,OAAO,CAAC;KACpB,CAAC;IAEF,YAA6B,WAAwB;QACnD,KAAK,EAAE,CAAC;QADmB,gBAAW,GAAX,WAAW,CAAa;IAErD,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,KAAU;QACtB,4BAA4B;QAC5B,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,KAAK,EAAE,OAAO,EAAE;YACvC,WAAW,EAAE,qCAAqC;YAClD,OAAO,EAAE,8DAA8D;SACxE,CAAC,CAAC;QAEH,IAAI,KAAK,GAAG,CAAC,CAAC;QACd,MAAM,YAAY,GAAU,EAAE,CAAC;QAE/B,KAAK,MAAM,IAAI,IAAI,KAAK,CAAC,KAAK,EAAE,CAAC;YAC/B,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,kBAAkB,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,EAAE,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;YACzF,IAAI,OAAO,GAAG,CAAC,EAAE,CAAC;gBAChB,KAAK,IAAI,OAAO,CAAC;gBACjB,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAC1B,CAAC;QACH,CAAC;QAED,OAAO;YACL,OAAO,EAAE,CAAC;oBACR,IAAI,EAAE,MAAM;oBACZ,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC;wBACnB,OAAO,EAAE,KAAK;wBACd,KAAK,EAAE,YAAY;qBACpB,CAAC;iBACH,CAAC;SACH,CAAC;IACJ,CAAC;CACF"}
@@ -0,0 +1,47 @@
1
+ import { BaseCommand } from './BaseCommand.js';
2
+ import type { LinkService } from '../../../application/services/LinkService.js';
3
+ export declare class LinkEditCommand extends BaseCommand<any, any> {
4
+ private readonly linkService;
5
+ readonly name = "kg_link_edit";
6
+ readonly description = "Update the type of an existing link. You must specify the exact link (from, to, and old type) to identify it, then provide the new type.\n\nExamples:\n1. Change a link type:\n { \"links\": [{ \"from\": \"Alice\", \"to\": \"TechCorp\", \"old\": \"works_at\", \"new\": \"formerly_worked_at\" }] }\n\n2. Update multiple links:\n { \"links\": [{ \"from\": \"Alice\", \"to\": \"Bob\", \"old\": \"knows\", \"new\": \"mentors\" }, { \"from\": \"Bob\", \"to\": \"Charlie\", \"old\": \"knows\", \"new\": \"manages\" }] }\n\n3. Correct a typo in link type:\n { \"links\": [{ \"from\": \"ProjectA\", \"to\": \"ProjectB\", \"old\": \"deppends_on\", \"new\": \"depends_on\" }] }";
7
+ readonly inputSchema: {
8
+ type: string;
9
+ properties: {
10
+ links: {
11
+ type: string;
12
+ description: string;
13
+ items: {
14
+ type: string;
15
+ properties: {
16
+ from: {
17
+ type: string;
18
+ description: string;
19
+ };
20
+ to: {
21
+ type: string;
22
+ description: string;
23
+ };
24
+ old: {
25
+ type: string;
26
+ description: string;
27
+ };
28
+ new: {
29
+ type: string;
30
+ description: string;
31
+ };
32
+ };
33
+ required: string[];
34
+ };
35
+ };
36
+ };
37
+ required: string[];
38
+ };
39
+ constructor(linkService: LinkService);
40
+ execute(input: any): Promise<{
41
+ content: Array<{
42
+ type: 'text';
43
+ text: string;
44
+ }>;
45
+ }>;
46
+ }
47
+ //# sourceMappingURL=LinkEditCommand.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LinkEditCommand.d.ts","sourceRoot":"","sources":["../../../../src/interfaces/mcp/commands/LinkEditCommand.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,8CAA8C,CAAC;AAEhF,qBAAa,eAAgB,SAAQ,WAAW,CAAC,GAAG,EAAE,GAAG,CAAC;IAkC5C,OAAO,CAAC,QAAQ,CAAC,WAAW;IAjCxC,QAAQ,CAAC,IAAI,kBAAkB;IAC/B,QAAQ,CAAC,WAAW,qqBAUiF;IACrG,QAAQ,CAAC,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAmBlB;gBAE2B,WAAW,EAAE,WAAW;IAI/C,OAAO,CAAC,KAAK,EAAE,GAAG,GAAG,OAAO,CAAC;QAAE,OAAO,EAAE,KAAK,CAAC;YAAE,IAAI,EAAE,MAAM,CAAC;YAAC,IAAI,EAAE,MAAM,CAAA;SAAE,CAAC,CAAA;KAAE,CAAC;CAsCvF"}
@@ -0,0 +1,75 @@
1
+ import { BaseCommand } from './BaseCommand.js';
2
+ export class LinkEditCommand extends BaseCommand {
3
+ linkService;
4
+ name = 'kg_link_edit';
5
+ description = `Update the type of an existing link. You must specify the exact link (from, to, and old type) to identify it, then provide the new type.
6
+
7
+ Examples:
8
+ 1. Change a link type:
9
+ { "links": [{ "from": "Alice", "to": "TechCorp", "old": "works_at", "new": "formerly_worked_at" }] }
10
+
11
+ 2. Update multiple links:
12
+ { "links": [{ "from": "Alice", "to": "Bob", "old": "knows", "new": "mentors" }, { "from": "Bob", "to": "Charlie", "old": "knows", "new": "manages" }] }
13
+
14
+ 3. Correct a typo in link type:
15
+ { "links": [{ "from": "ProjectA", "to": "ProjectB", "old": "deppends_on", "new": "depends_on" }] }`;
16
+ inputSchema = {
17
+ type: 'object',
18
+ properties: {
19
+ links: {
20
+ type: 'array',
21
+ description: 'Array of links to edit. Each item identifies a link by from/to/old and provides the new type.',
22
+ items: {
23
+ type: 'object',
24
+ properties: {
25
+ from: { type: 'string', description: 'Name of the source node' },
26
+ to: { type: 'string', description: 'Name of the target node' },
27
+ old: { type: 'string', description: 'Current relationship type to match' },
28
+ new: { type: 'string', description: 'New relationship type to set' },
29
+ },
30
+ required: ['from', 'to', 'old', 'new'],
31
+ },
32
+ },
33
+ },
34
+ required: ['links'],
35
+ };
36
+ constructor(linkService) {
37
+ super();
38
+ this.linkService = linkService;
39
+ }
40
+ async execute(input) {
41
+ // Validate array parameters
42
+ this.validateArray(input.links, 'links', {
43
+ description: 'Provide an array of links to edit',
44
+ example: '{"links": [{"from": "Alice", "to": "Bob", "old": "knows", "new": "mentors"}]}',
45
+ });
46
+ // Map 'old'/'new' to 'oldType'/'newType' for LinkService
47
+ const edits = input.links.map((link) => ({
48
+ from: link.from,
49
+ to: link.to,
50
+ oldType: link.old,
51
+ newType: link.new,
52
+ }));
53
+ const updated = await this.linkService.updateLinksByNames(edits);
54
+ const nodeIds = new Set();
55
+ for (const link of updated) {
56
+ nodeIds.add(link.fromNodeId);
57
+ nodeIds.add(link.toNodeId);
58
+ }
59
+ const nodeMap = await this.linkService.getNodeNameMap(Array.from(nodeIds));
60
+ return {
61
+ content: [{
62
+ type: 'text',
63
+ text: JSON.stringify({
64
+ updated: updated.length,
65
+ links: updated.map(l => ({
66
+ from: nodeMap.get(l.fromNodeId) || '',
67
+ to: nodeMap.get(l.toNodeId) || '',
68
+ type: l.type,
69
+ })),
70
+ }),
71
+ }],
72
+ };
73
+ }
74
+ }
75
+ //# sourceMappingURL=LinkEditCommand.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LinkEditCommand.js","sourceRoot":"","sources":["../../../../src/interfaces/mcp/commands/LinkEditCommand.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAG/C,MAAM,OAAO,eAAgB,SAAQ,WAAqB;IAkC3B;IAjCpB,IAAI,GAAG,cAAc,CAAC;IACtB,WAAW,GAAG;;;;;;;;;;sGAU6E,CAAC;IAC5F,WAAW,GAAG;QACrB,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,KAAK,EAAE;gBACL,IAAI,EAAE,OAAO;gBACb,WAAW,EAAE,+FAA+F;gBAC5G,KAAK,EAAE;oBACL,IAAI,EAAE,QAAQ;oBACd,UAAU,EAAE;wBACV,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,yBAAyB,EAAE;wBAChE,EAAE,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,yBAAyB,EAAE;wBAC9D,GAAG,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,oCAAoC,EAAE;wBAC1E,GAAG,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,8BAA8B,EAAE;qBACrE;oBACD,QAAQ,EAAE,CAAC,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,CAAC;iBACvC;aACF;SACF;QACD,QAAQ,EAAE,CAAC,OAAO,CAAC;KACpB,CAAC;IAEF,YAA6B,WAAwB;QACnD,KAAK,EAAE,CAAC;QADmB,gBAAW,GAAX,WAAW,CAAa;IAErD,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,KAAU;QACtB,4BAA4B;QAC5B,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,KAAK,EAAE,OAAO,EAAE;YACvC,WAAW,EAAE,mCAAmC;YAChD,OAAO,EAAE,+EAA+E;SACzF,CAAC,CAAC;QAEH,yDAAyD;QACzD,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAS,EAAE,EAAE,CAAC,CAAC;YAC5C,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,EAAE,EAAE,IAAI,CAAC,EAAE;YACX,OAAO,EAAE,IAAI,CAAC,GAAG;YACjB,OAAO,EAAE,IAAI,CAAC,GAAG;SAClB,CAAC,CAAC,CAAC;QAEJ,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,kBAAkB,CAAC,KAAK,CAAC,CAAC;QAEjE,MAAM,OAAO,GAAG,IAAI,GAAG,EAAU,CAAC;QAClC,KAAK,MAAM,IAAI,IAAI,OAAO,EAAE,CAAC;YAC3B,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;YAC7B,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAC7B,CAAC;QACD,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,cAAc,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;QAE3E,OAAO;YACL,OAAO,EAAE,CAAC;oBACR,IAAI,EAAE,MAAM;oBACZ,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC;wBACnB,OAAO,EAAE,OAAO,CAAC,MAAM;wBACvB,KAAK,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;4BACvB,IAAI,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,UAAU,CAAC,IAAI,EAAE;4BACrC,EAAE,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,EAAE;4BACjC,IAAI,EAAE,CAAC,CAAC,IAAI;yBACb,CAAC,CAAC;qBACJ,CAAC;iBACH,CAAC;SACH,CAAC;IACJ,CAAC;CACF"}
@@ -0,0 +1,33 @@
1
+ import type { Command } from './BaseCommand.js';
2
+ import type { KnowledgeGraphService } from '../../../application/services/KnowledgeGraphService.js';
3
+ export declare class ListCommand implements Command<any, any> {
4
+ private readonly kgService;
5
+ readonly name = "kg_list";
6
+ readonly description = "List all nodes and links in the knowledge graph. Optionally supports pagination for large datasets.\n\nExamples:\n1. List everything:\n { \"page\": false }\n\n2. List with pagination (first page):\n { \"page\": true, \"pageNum\": 1, \"pageSize\": 10 }\n\n3. List with pagination (second page):\n { \"page\": true, \"pageNum\": 2, \"pageSize\": 10 }";
7
+ readonly inputSchema: {
8
+ type: string;
9
+ properties: {
10
+ page: {
11
+ type: string;
12
+ description: string;
13
+ };
14
+ pageNum: {
15
+ type: string;
16
+ description: string;
17
+ };
18
+ pageSize: {
19
+ type: string;
20
+ description: string;
21
+ };
22
+ };
23
+ required: string[];
24
+ };
25
+ constructor(kgService: KnowledgeGraphService);
26
+ execute(input: any): Promise<{
27
+ content: Array<{
28
+ type: 'text';
29
+ text: string;
30
+ }>;
31
+ }>;
32
+ }
33
+ //# sourceMappingURL=ListCommand.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ListCommand.d.ts","sourceRoot":"","sources":["../../../../src/interfaces/mcp/commands/ListCommand.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,wDAAwD,CAAC;AAEpG,qBAAa,WAAY,YAAW,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC;IAuBvC,OAAO,CAAC,QAAQ,CAAC,SAAS;IAtBtC,QAAQ,CAAC,IAAI,aAAa;IAC1B,QAAQ,CAAC,WAAW,wWAU6B;IACjD,QAAQ,CAAC,WAAW;;;;;;;;;;;;;;;;;MAQlB;gBAE2B,SAAS,EAAE,qBAAqB;IAEvD,OAAO,CAAC,KAAK,EAAE,GAAG,GAAG,OAAO,CAAC;QAAE,OAAO,EAAE,KAAK,CAAC;YAAE,IAAI,EAAE,MAAM,CAAC;YAAC,IAAI,EAAE,MAAM,CAAA;SAAE,CAAC,CAAA;KAAE,CAAC;CAiCvF"}
@@ -0,0 +1,57 @@
1
+ export class ListCommand {
2
+ kgService;
3
+ name = 'kg_list';
4
+ description = `List all nodes and links in the knowledge graph. Optionally supports pagination for large datasets.
5
+
6
+ Examples:
7
+ 1. List everything:
8
+ { "page": false }
9
+
10
+ 2. List with pagination (first page):
11
+ { "page": true, "pageNum": 1, "pageSize": 10 }
12
+
13
+ 3. List with pagination (second page):
14
+ { "page": true, "pageNum": 2, "pageSize": 10 }`;
15
+ inputSchema = {
16
+ type: 'object',
17
+ properties: {
18
+ page: { type: 'boolean', description: 'Set to true to enable pagination, false to return all results' },
19
+ pageNum: { type: 'number', description: 'Page number (default: 1), only used when page=true' },
20
+ pageSize: { type: 'number', description: 'Number of nodes per page (default: 10), only used when page=true' },
21
+ },
22
+ required: ['page'],
23
+ };
24
+ constructor(kgService) {
25
+ this.kgService = kgService;
26
+ }
27
+ async execute(input) {
28
+ const enablePagination = input.page === true;
29
+ const pagination = enablePagination ? { page: input.pageNum || 1, pageSize: input.pageSize || 10 } : undefined;
30
+ const result = await this.kgService.readAll(pagination);
31
+ const output = {
32
+ nodes: result.data.nodes.map((n) => ({
33
+ name: n.name,
34
+ type: n.type,
35
+ facts: n.facts.map((f) => f.content),
36
+ })),
37
+ links: result.data.links.map((l) => ({
38
+ from: l.from,
39
+ to: l.to,
40
+ type: l.type,
41
+ })),
42
+ };
43
+ if (enablePagination) {
44
+ const info = result.pagination;
45
+ output.pagination = {
46
+ page: info.page,
47
+ pageSize: info.pageSize,
48
+ total: info.totalItems,
49
+ pages: info.totalPages,
50
+ hasNext: info.hasNextPage,
51
+ hasPrev: info.hasPrevPage,
52
+ };
53
+ }
54
+ return { content: [{ type: 'text', text: JSON.stringify(output) }] };
55
+ }
56
+ }
57
+ //# sourceMappingURL=ListCommand.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ListCommand.js","sourceRoot":"","sources":["../../../../src/interfaces/mcp/commands/ListCommand.ts"],"names":[],"mappings":"AAGA,MAAM,OAAO,WAAW;IAuBO;IAtBpB,IAAI,GAAG,SAAS,CAAC;IACjB,WAAW,GAAG;;;;;;;;;;kDAUyB,CAAC;IACxC,WAAW,GAAG;QACrB,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,IAAI,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,WAAW,EAAE,+DAA+D,EAAE;YACvG,OAAO,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,oDAAoD,EAAE;YAC9F,QAAQ,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,kEAAkE,EAAE;SAC9G;QACD,QAAQ,EAAE,CAAC,MAAM,CAAC;KACnB,CAAC;IAEF,YAA6B,SAAgC;QAAhC,cAAS,GAAT,SAAS,CAAuB;IAAG,CAAC;IAEjE,KAAK,CAAC,OAAO,CAAC,KAAU;QACtB,MAAM,gBAAgB,GAAG,KAAK,CAAC,IAAI,KAAK,IAAI,CAAC;QAC7C,MAAM,UAAU,GAAG,gBAAgB,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,CAAC,OAAO,IAAI,CAAC,EAAE,QAAQ,EAAE,KAAK,CAAC,QAAQ,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;QAE/G,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;QAExD,MAAM,MAAM,GAAQ;YAClB,KAAK,EAAE,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAM,EAAE,EAAE,CAAC,CAAC;gBACxC,IAAI,EAAE,CAAC,CAAC,IAAI;gBACZ,IAAI,EAAE,CAAC,CAAC,IAAI;gBACZ,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAM,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC;aAC1C,CAAC,CAAC;YACH,KAAK,EAAE,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAM,EAAE,EAAE,CAAC,CAAC;gBACxC,IAAI,EAAE,CAAC,CAAC,IAAI;gBACZ,EAAE,EAAE,CAAC,CAAC,EAAE;gBACR,IAAI,EAAE,CAAC,CAAC,IAAI;aACb,CAAC,CAAC;SACJ,CAAC;QAEF,IAAI,gBAAgB,EAAE,CAAC;YACrB,MAAM,IAAI,GAAG,MAAM,CAAC,UAAU,CAAC;YAC/B,MAAM,CAAC,UAAU,GAAG;gBAClB,IAAI,EAAE,IAAI,CAAC,IAAI;gBACf,QAAQ,EAAE,IAAI,CAAC,QAAQ;gBACvB,KAAK,EAAE,IAAI,CAAC,UAAU;gBACtB,KAAK,EAAE,IAAI,CAAC,UAAU;gBACtB,OAAO,EAAE,IAAI,CAAC,WAAW;gBACzB,OAAO,EAAE,IAAI,CAAC,WAAW;aAC1B,CAAC;QACJ,CAAC;QAED,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,CAAC;IACvE,CAAC;CACF"}
@@ -0,0 +1,46 @@
1
+ import { BaseCommand } from './BaseCommand.js';
2
+ import type { NodeService } from '../../../application/services/NodeService.js';
3
+ export declare class NodeAddCommand extends BaseCommand<any, any> {
4
+ private readonly nodeService;
5
+ readonly name = "kg_node_add";
6
+ readonly description = "Add new nodes to the knowledge graph. Each node must have a unique name and a type. Optionally, you can attach facts to the node at creation time.\n\nExamples:\n1. Add a person with facts:\n { \"nodes\": [{ \"name\": \"Alice\", \"type\": \"person\", \"facts\": [\"Software engineer\", \"Lives in San Francisco\"] }] }\n\n2. Add multiple nodes of different types:\n { \"nodes\": [{ \"name\": \"TechCorp\", \"type\": \"company\" }, { \"name\": \"ProjectX\", \"type\": \"project\" }] }\n\n3. Add nodes with facts and without facts mixed:\n { \"nodes\": [{ \"name\": \"Bob\", \"type\": \"person\", \"facts\": [\"Manager\"] }, { \"name\": \"DeptA\", \"type\": \"department\" }] }";
7
+ readonly inputSchema: {
8
+ type: string;
9
+ properties: {
10
+ nodes: {
11
+ type: string;
12
+ description: string;
13
+ items: {
14
+ type: string;
15
+ properties: {
16
+ name: {
17
+ type: string;
18
+ description: string;
19
+ };
20
+ type: {
21
+ type: string;
22
+ description: string;
23
+ };
24
+ facts: {
25
+ type: string;
26
+ items: {
27
+ type: string;
28
+ };
29
+ description: string;
30
+ };
31
+ };
32
+ required: string[];
33
+ };
34
+ };
35
+ };
36
+ required: string[];
37
+ };
38
+ constructor(nodeService: NodeService);
39
+ execute(input: any): Promise<{
40
+ content: Array<{
41
+ type: 'text';
42
+ text: string;
43
+ }>;
44
+ }>;
45
+ }
46
+ //# sourceMappingURL=NodeAddCommand.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NodeAddCommand.d.ts","sourceRoot":"","sources":["../../../../src/interfaces/mcp/commands/NodeAddCommand.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,8CAA8C,CAAC;AAEhF,qBAAa,cAAe,SAAQ,WAAW,CAAC,GAAG,EAAE,GAAG,CAAC;IAiC3C,OAAO,CAAC,QAAQ,CAAC,WAAW;IAhCxC,QAAQ,CAAC,IAAI,iBAAiB;IAC9B,QAAQ,CAAC,WAAW,8qBAUkG;IACtH,QAAQ,CAAC,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAkBlB;gBAE2B,WAAW,EAAE,WAAW;IAI/C,OAAO,CAAC,KAAK,EAAE,GAAG,GAAG,OAAO,CAAC;QAAE,OAAO,EAAE,KAAK,CAAC;YAAE,IAAI,EAAE,MAAM,CAAC;YAAC,IAAI,EAAE,MAAM,CAAA;SAAE,CAAC,CAAA;KAAE,CAAC;CA8BvF"}
@@ -0,0 +1,67 @@
1
+ import { BaseCommand } from './BaseCommand.js';
2
+ export class NodeAddCommand extends BaseCommand {
3
+ nodeService;
4
+ name = 'kg_node_add';
5
+ description = `Add new nodes to the knowledge graph. Each node must have a unique name and a type. Optionally, you can attach facts to the node at creation time.
6
+
7
+ Examples:
8
+ 1. Add a person with facts:
9
+ { "nodes": [{ "name": "Alice", "type": "person", "facts": ["Software engineer", "Lives in San Francisco"] }] }
10
+
11
+ 2. Add multiple nodes of different types:
12
+ { "nodes": [{ "name": "TechCorp", "type": "company" }, { "name": "ProjectX", "type": "project" }] }
13
+
14
+ 3. Add nodes with facts and without facts mixed:
15
+ { "nodes": [{ "name": "Bob", "type": "person", "facts": ["Manager"] }, { "name": "DeptA", "type": "department" }] }`;
16
+ inputSchema = {
17
+ type: 'object',
18
+ properties: {
19
+ nodes: {
20
+ type: 'array',
21
+ description: 'Array of nodes to add. Each node requires name and type, facts are optional.',
22
+ items: {
23
+ type: 'object',
24
+ properties: {
25
+ name: { type: 'string', description: 'Unique identifier name for the node' },
26
+ type: { type: 'string', description: 'Category or type of the node (e.g., person, company, project)' },
27
+ facts: { type: 'array', items: { type: 'string' }, description: 'Optional array of facts about this node' },
28
+ },
29
+ required: ['name', 'type'],
30
+ },
31
+ },
32
+ },
33
+ required: ['nodes'],
34
+ };
35
+ constructor(nodeService) {
36
+ super();
37
+ this.nodeService = nodeService;
38
+ }
39
+ async execute(input) {
40
+ // Validate array parameters
41
+ this.validateArray(input.nodes, 'nodes', {
42
+ description: 'Provide an array of nodes to add',
43
+ example: '{"nodes": [{"name": "Alice", "type": "person"}]}',
44
+ });
45
+ this.validateNestedArray(input.nodes, 'nodes', 'facts', {
46
+ description: 'The "facts" field must be an array of strings',
47
+ example: '{"nodes": [{"name": "Alice", "type": "person", "facts": ["Engineer"]}]}',
48
+ });
49
+ const { nodes, createdFacts } = await this.nodeService.createNodes(input.nodes);
50
+ const factsByNode = new Map();
51
+ for (const { nodeName, content } of createdFacts) {
52
+ if (!factsByNode.has(nodeName))
53
+ factsByNode.set(nodeName, []);
54
+ factsByNode.get(nodeName).push(content);
55
+ }
56
+ const output = {
57
+ added: nodes.length,
58
+ nodes: nodes.map((n) => ({
59
+ name: n.name,
60
+ type: n.type,
61
+ facts: factsByNode.get(n.name) || [],
62
+ })),
63
+ };
64
+ return { content: [{ type: 'text', text: JSON.stringify(output) }] };
65
+ }
66
+ }
67
+ //# sourceMappingURL=NodeAddCommand.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NodeAddCommand.js","sourceRoot":"","sources":["../../../../src/interfaces/mcp/commands/NodeAddCommand.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAG/C,MAAM,OAAO,cAAe,SAAQ,WAAqB;IAiC1B;IAhCpB,IAAI,GAAG,aAAa,CAAC;IACrB,WAAW,GAAG;;;;;;;;;;uHAU8F,CAAC;IAC7G,WAAW,GAAG;QACrB,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,KAAK,EAAE;gBACL,IAAI,EAAE,OAAO;gBACb,WAAW,EAAE,8EAA8E;gBAC3F,KAAK,EAAE;oBACL,IAAI,EAAE,QAAQ;oBACd,UAAU,EAAE;wBACV,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,qCAAqC,EAAE;wBAC5E,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,+DAA+D,EAAE;wBACtG,KAAK,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,WAAW,EAAE,yCAAyC,EAAE;qBAC5G;oBACD,QAAQ,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC;iBAC3B;aACF;SACF;QACD,QAAQ,EAAE,CAAC,OAAO,CAAC;KACpB,CAAC;IAEF,YAA6B,WAAwB;QACnD,KAAK,EAAE,CAAC;QADmB,gBAAW,GAAX,WAAW,CAAa;IAErD,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,KAAU;QACtB,4BAA4B;QAC5B,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,KAAK,EAAE,OAAO,EAAE;YACvC,WAAW,EAAE,kCAAkC;YAC/C,OAAO,EAAE,kDAAkD;SAC5D,CAAC,CAAC;QACH,IAAI,CAAC,mBAAmB,CAAC,KAAK,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE;YACtD,WAAW,EAAE,+CAA+C;YAC5D,OAAO,EAAE,yEAAyE;SACnF,CAAC,CAAC;QAEH,MAAM,EAAE,KAAK,EAAE,YAAY,EAAE,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,WAAW,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QAEhF,MAAM,WAAW,GAAG,IAAI,GAAG,EAAoB,CAAC;QAChD,KAAK,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,YAAY,EAAE,CAAC;YACjD,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,QAAQ,CAAC;gBAAE,WAAW,CAAC,GAAG,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;YAC9D,WAAW,CAAC,GAAG,CAAC,QAAQ,CAAE,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAC3C,CAAC;QAED,MAAM,MAAM,GAAG;YACb,KAAK,EAAE,KAAK,CAAC,MAAM;YACnB,KAAK,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC,CAAM,EAAE,EAAE,CAAC,CAAC;gBAC5B,IAAI,EAAE,CAAC,CAAC,IAAI;gBACZ,IAAI,EAAE,CAAC,CAAC,IAAI;gBACZ,KAAK,EAAE,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE;aACrC,CAAC,CAAC;SACJ,CAAC;QAEF,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,CAAC;IACvE,CAAC;CACF"}
@@ -0,0 +1,32 @@
1
+ import { BaseCommand } from './BaseCommand.js';
2
+ import type { NodeService } from '../../../application/services/NodeService.js';
3
+ import type { FactRepository } from '../../../infrastructure/repositories/FactRepository.js';
4
+ import type { LinkRepository } from '../../../infrastructure/repositories/LinkRepository.js';
5
+ export declare class NodeDelCommand extends BaseCommand<any, any> {
6
+ private readonly nodeService;
7
+ private readonly factRepo;
8
+ private readonly linkRepo;
9
+ readonly name = "kg_node_del";
10
+ readonly description = "Delete nodes from the knowledge graph. This will cascade delete all facts attached to the node and all links connected to it. Non-existent nodes are silently ignored.\n\nExamples:\n1. Delete a single node:\n { \"names\": [\"Alice\"] }\n\n2. Delete multiple nodes:\n { \"names\": [\"Alice\", \"Bob\", \"OldProject\"] }\n\n3. Delete with cleanup (all related data will be removed):\n { \"names\": [\"DeprecatedSystem\"] }";
11
+ readonly inputSchema: {
12
+ type: string;
13
+ properties: {
14
+ names: {
15
+ type: string;
16
+ description: string;
17
+ items: {
18
+ type: string;
19
+ };
20
+ };
21
+ };
22
+ required: string[];
23
+ };
24
+ constructor(nodeService: NodeService, factRepo: FactRepository, linkRepo: LinkRepository);
25
+ execute(input: any): Promise<{
26
+ content: Array<{
27
+ type: 'text';
28
+ text: string;
29
+ }>;
30
+ }>;
31
+ }
32
+ //# sourceMappingURL=NodeDelCommand.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NodeDelCommand.d.ts","sourceRoot":"","sources":["../../../../src/interfaces/mcp/commands/NodeDelCommand.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,8CAA8C,CAAC;AAChF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wDAAwD,CAAC;AAC7F,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wDAAwD,CAAC;AAE7F,qBAAa,cAAe,SAAQ,WAAW,CAAC,GAAG,EAAE,GAAG,CAAC;IA0BrD,OAAO,CAAC,QAAQ,CAAC,WAAW;IAC5B,OAAO,CAAC,QAAQ,CAAC,QAAQ;IACzB,OAAO,CAAC,QAAQ,CAAC,QAAQ;IA3B3B,QAAQ,CAAC,IAAI,iBAAiB;IAC9B,QAAQ,CAAC,WAAW,+aAUgB;IACpC,QAAQ,CAAC,WAAW;;;;;;;;;;;;MAUlB;gBAGiB,WAAW,EAAE,WAAW,EACxB,QAAQ,EAAE,cAAc,EACxB,QAAQ,EAAE,cAAc;IAKrC,OAAO,CAAC,KAAK,EAAE,GAAG,GAAG,OAAO,CAAC;QAAE,OAAO,EAAE,KAAK,CAAC;YAAE,IAAI,EAAE,MAAM,CAAC;YAAC,IAAI,EAAE,MAAM,CAAA;SAAE,CAAC,CAAA;KAAE,CAAC;CA+BvF"}