mta-mcp 3.0.0 → 3.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -5699,8 +5699,199 @@ async function listTroubleshootingCases(framework) {
5699
5699
  }
5700
5700
  }
5701
5701
 
5702
+ // src/tools/memory.ts
5703
+ import path18 from "path";
5704
+ var KnowledgeGraphManagerClass = null;
5705
+ async function loadKnowledgeGraphManager() {
5706
+ if (!KnowledgeGraphManagerClass) {
5707
+ try {
5708
+ const module = await import("@modelcontextprotocol/server-memory");
5709
+ KnowledgeGraphManagerClass = module.KnowledgeGraphManager;
5710
+ } catch (error) {
5711
+ console.error("\u65E0\u6CD5\u52A0\u8F7D @modelcontextprotocol/server-memory:", error);
5712
+ throw new Error("\u77E5\u8BC6\u56FE\u8C31\u6A21\u5757\u52A0\u8F7D\u5931\u8D25\uFF0C\u8BF7\u786E\u4FDD\u5DF2\u5B89\u88C5 @modelcontextprotocol/server-memory");
5713
+ }
5714
+ }
5715
+ return KnowledgeGraphManagerClass;
5716
+ }
5717
+ var memoryManager = null;
5718
+ async function getMemoryManager() {
5719
+ if (!memoryManager) {
5720
+ const Manager = await loadKnowledgeGraphManager();
5721
+ const homeDir = process.env.HOME || process.env.USERPROFILE || ".";
5722
+ const memoryPath = path18.join(homeDir, ".mta", "memory.jsonl");
5723
+ memoryManager = new Manager(memoryPath);
5724
+ }
5725
+ return memoryManager;
5726
+ }
5727
+ async function createEntities(args) {
5728
+ const manager = await getMemoryManager();
5729
+ const result = await manager.createEntities(args.entities);
5730
+ return {
5731
+ content: [{
5732
+ type: "text",
5733
+ text: JSON.stringify({
5734
+ success: true,
5735
+ created: result.length,
5736
+ entities: result
5737
+ }, null, 2)
5738
+ }]
5739
+ };
5740
+ }
5741
+ async function createRelations(args) {
5742
+ const manager = await getMemoryManager();
5743
+ const result = await manager.createRelations(args.relations);
5744
+ return {
5745
+ content: [{
5746
+ type: "text",
5747
+ text: JSON.stringify({
5748
+ success: true,
5749
+ created: result.length,
5750
+ relations: result
5751
+ }, null, 2)
5752
+ }]
5753
+ };
5754
+ }
5755
+ async function addObservations(args) {
5756
+ const manager = await getMemoryManager();
5757
+ const result = await manager.addObservations(args.observations);
5758
+ return {
5759
+ content: [{
5760
+ type: "text",
5761
+ text: JSON.stringify({
5762
+ success: true,
5763
+ results: result
5764
+ }, null, 2)
5765
+ }]
5766
+ };
5767
+ }
5768
+ async function deleteEntities(args) {
5769
+ const manager = await getMemoryManager();
5770
+ await manager.deleteEntities(args.entityNames);
5771
+ return {
5772
+ content: [{
5773
+ type: "text",
5774
+ text: JSON.stringify({
5775
+ success: true,
5776
+ message: `\u5DF2\u5220\u9664 ${args.entityNames.length} \u4E2A\u5B9E\u4F53\u53CA\u5176\u5173\u8054\u5173\u7CFB`
5777
+ }, null, 2)
5778
+ }]
5779
+ };
5780
+ }
5781
+ async function deleteObservations(args) {
5782
+ const manager = await getMemoryManager();
5783
+ await manager.deleteObservations(args.deletions);
5784
+ return {
5785
+ content: [{
5786
+ type: "text",
5787
+ text: JSON.stringify({
5788
+ success: true,
5789
+ message: "\u89C2\u5BDF\u5DF2\u5220\u9664"
5790
+ }, null, 2)
5791
+ }]
5792
+ };
5793
+ }
5794
+ async function deleteRelations(args) {
5795
+ const manager = await getMemoryManager();
5796
+ await manager.deleteRelations(args.relations);
5797
+ return {
5798
+ content: [{
5799
+ type: "text",
5800
+ text: JSON.stringify({
5801
+ success: true,
5802
+ message: `\u5DF2\u5220\u9664 ${args.relations.length} \u4E2A\u5173\u7CFB`
5803
+ }, null, 2)
5804
+ }]
5805
+ };
5806
+ }
5807
+ async function readGraph() {
5808
+ const manager = await getMemoryManager();
5809
+ const graph = await manager.readGraph();
5810
+ return {
5811
+ content: [{
5812
+ type: "text",
5813
+ text: JSON.stringify({
5814
+ entities: graph.entities.length,
5815
+ relations: graph.relations.length,
5816
+ graph
5817
+ }, null, 2)
5818
+ }]
5819
+ };
5820
+ }
5821
+ async function searchNodes(args) {
5822
+ const manager = await getMemoryManager();
5823
+ const graph = await manager.searchNodes(args.query);
5824
+ return {
5825
+ content: [{
5826
+ type: "text",
5827
+ text: JSON.stringify({
5828
+ query: args.query,
5829
+ found: {
5830
+ entities: graph.entities.length,
5831
+ relations: graph.relations.length
5832
+ },
5833
+ graph
5834
+ }, null, 2)
5835
+ }]
5836
+ };
5837
+ }
5838
+ async function openNodes(args) {
5839
+ const manager = await getMemoryManager();
5840
+ const graph = await manager.openNodes(args.names);
5841
+ return {
5842
+ content: [{
5843
+ type: "text",
5844
+ text: JSON.stringify({
5845
+ requested: args.names,
5846
+ found: {
5847
+ entities: graph.entities.length,
5848
+ relations: graph.relations.length
5849
+ },
5850
+ graph
5851
+ }, null, 2)
5852
+ }]
5853
+ };
5854
+ }
5855
+
5856
+ // src/tools/sequentialThinking.ts
5857
+ var SequentialThinkingServerClass = null;
5858
+ async function loadSequentialThinkingServer() {
5859
+ if (!SequentialThinkingServerClass) {
5860
+ try {
5861
+ const module = await import("@modelcontextprotocol/server-sequential-thinking");
5862
+ SequentialThinkingServerClass = module.SequentialThinkingServer;
5863
+ } catch (error) {
5864
+ console.error("\u65E0\u6CD5\u52A0\u8F7D @modelcontextprotocol/server-sequential-thinking:", error);
5865
+ throw new Error("\u987A\u5E8F\u601D\u8003\u6A21\u5757\u52A0\u8F7D\u5931\u8D25\uFF0C\u8BF7\u786E\u4FDD\u5DF2\u5B89\u88C5 @modelcontextprotocol/server-sequential-thinking");
5866
+ }
5867
+ }
5868
+ return SequentialThinkingServerClass;
5869
+ }
5870
+ var thinkingServer = null;
5871
+ async function getThinkingServer() {
5872
+ if (!thinkingServer) {
5873
+ const Server2 = await loadSequentialThinkingServer();
5874
+ thinkingServer = new Server2();
5875
+ }
5876
+ return thinkingServer;
5877
+ }
5878
+ async function sequentialThinking(args) {
5879
+ const server = await getThinkingServer();
5880
+ const result = server.processThought(args);
5881
+ if (result.isError) {
5882
+ return result;
5883
+ }
5884
+ const parsedContent = JSON.parse(result.content[0].text);
5885
+ return {
5886
+ content: [{
5887
+ type: "text",
5888
+ text: JSON.stringify(parsedContent, null, 2)
5889
+ }]
5890
+ };
5891
+ }
5892
+
5702
5893
  // src/index.ts
5703
- var SERVER_VERSION = "3.0.0";
5894
+ var SERVER_VERSION = "3.2.0";
5704
5895
  var logger3 = createLogger("Server");
5705
5896
  var CopilotPromptsMCPServer = class {
5706
5897
  constructor() {
@@ -6260,6 +6451,274 @@ var CopilotPromptsMCPServer = class {
6260
6451
  }
6261
6452
  }
6262
6453
  }
6454
+ },
6455
+ // ================== 知识图谱记忆工具 ==================
6456
+ {
6457
+ name: "create_entities",
6458
+ description: "\u5728\u77E5\u8BC6\u56FE\u8C31\u4E2D\u521B\u5EFA\u591A\u4E2A\u65B0\u5B9E\u4F53",
6459
+ inputSchema: {
6460
+ type: "object",
6461
+ properties: {
6462
+ entities: {
6463
+ type: "array",
6464
+ description: "\u5B9E\u4F53\u6570\u7EC4",
6465
+ items: {
6466
+ type: "object",
6467
+ properties: {
6468
+ name: { type: "string", description: "\u5B9E\u4F53\u540D\u79F0\uFF08\u552F\u4E00\u6807\u8BC6\uFF09" },
6469
+ entityType: { type: "string", description: "\u5B9E\u4F53\u7C7B\u578B\uFF08\u5982 person\u3001project\u3001concept\uFF09" },
6470
+ observations: { type: "array", items: { type: "string" }, description: "\u5173\u4E8E\u8BE5\u5B9E\u4F53\u7684\u89C2\u5BDF/\u4E8B\u5B9E" }
6471
+ },
6472
+ required: ["name", "entityType", "observations"]
6473
+ }
6474
+ }
6475
+ },
6476
+ required: ["entities"]
6477
+ }
6478
+ },
6479
+ {
6480
+ name: "create_relations",
6481
+ description: "\u5728\u77E5\u8BC6\u56FE\u8C31\u4E2D\u521B\u5EFA\u5B9E\u4F53\u4E4B\u95F4\u7684\u5173\u7CFB\uFF08\u4F7F\u7528\u4E3B\u52A8\u8BED\u6001\uFF09",
6482
+ inputSchema: {
6483
+ type: "object",
6484
+ properties: {
6485
+ relations: {
6486
+ type: "array",
6487
+ description: "\u5173\u7CFB\u6570\u7EC4",
6488
+ items: {
6489
+ type: "object",
6490
+ properties: {
6491
+ from: { type: "string", description: "\u8D77\u59CB\u5B9E\u4F53\u540D\u79F0" },
6492
+ to: { type: "string", description: "\u76EE\u6807\u5B9E\u4F53\u540D\u79F0" },
6493
+ relationType: { type: "string", description: "\u5173\u7CFB\u7C7B\u578B\uFF08\u4E3B\u52A8\u8BED\u6001\uFF0C\u5982 works_at\u3001uses\u3001depends_on\uFF09" }
6494
+ },
6495
+ required: ["from", "to", "relationType"]
6496
+ }
6497
+ }
6498
+ },
6499
+ required: ["relations"]
6500
+ }
6501
+ },
6502
+ {
6503
+ name: "add_observations",
6504
+ description: "\u5411\u73B0\u6709\u5B9E\u4F53\u6DFB\u52A0\u65B0\u7684\u89C2\u5BDF/\u4E8B\u5B9E",
6505
+ inputSchema: {
6506
+ type: "object",
6507
+ properties: {
6508
+ observations: {
6509
+ type: "array",
6510
+ description: "\u89C2\u5BDF\u6570\u7EC4",
6511
+ items: {
6512
+ type: "object",
6513
+ properties: {
6514
+ entityName: { type: "string", description: "\u5B9E\u4F53\u540D\u79F0" },
6515
+ contents: { type: "array", items: { type: "string" }, description: "\u8981\u6DFB\u52A0\u7684\u89C2\u5BDF\u5185\u5BB9" }
6516
+ },
6517
+ required: ["entityName", "contents"]
6518
+ }
6519
+ }
6520
+ },
6521
+ required: ["observations"]
6522
+ }
6523
+ },
6524
+ {
6525
+ name: "delete_entities",
6526
+ description: "\u5220\u9664\u5B9E\u4F53\u53CA\u5176\u5173\u8054\u7684\u5173\u7CFB",
6527
+ inputSchema: {
6528
+ type: "object",
6529
+ properties: {
6530
+ entityNames: {
6531
+ type: "array",
6532
+ items: { type: "string" },
6533
+ description: "\u8981\u5220\u9664\u7684\u5B9E\u4F53\u540D\u79F0\u5217\u8868"
6534
+ }
6535
+ },
6536
+ required: ["entityNames"]
6537
+ }
6538
+ },
6539
+ {
6540
+ name: "delete_observations",
6541
+ description: "\u4ECE\u5B9E\u4F53\u4E2D\u5220\u9664\u7279\u5B9A\u7684\u89C2\u5BDF",
6542
+ inputSchema: {
6543
+ type: "object",
6544
+ properties: {
6545
+ deletions: {
6546
+ type: "array",
6547
+ items: {
6548
+ type: "object",
6549
+ properties: {
6550
+ entityName: { type: "string", description: "\u5B9E\u4F53\u540D\u79F0" },
6551
+ observations: { type: "array", items: { type: "string" }, description: "\u8981\u5220\u9664\u7684\u89C2\u5BDF" }
6552
+ },
6553
+ required: ["entityName", "observations"]
6554
+ }
6555
+ }
6556
+ },
6557
+ required: ["deletions"]
6558
+ }
6559
+ },
6560
+ {
6561
+ name: "delete_relations",
6562
+ description: "\u4ECE\u77E5\u8BC6\u56FE\u8C31\u4E2D\u5220\u9664\u5173\u7CFB",
6563
+ inputSchema: {
6564
+ type: "object",
6565
+ properties: {
6566
+ relations: {
6567
+ type: "array",
6568
+ items: {
6569
+ type: "object",
6570
+ properties: {
6571
+ from: { type: "string", description: "\u8D77\u59CB\u5B9E\u4F53\u540D\u79F0" },
6572
+ to: { type: "string", description: "\u76EE\u6807\u5B9E\u4F53\u540D\u79F0" },
6573
+ relationType: { type: "string", description: "\u5173\u7CFB\u7C7B\u578B" }
6574
+ },
6575
+ required: ["from", "to", "relationType"]
6576
+ }
6577
+ }
6578
+ },
6579
+ required: ["relations"]
6580
+ }
6581
+ },
6582
+ {
6583
+ name: "read_graph",
6584
+ description: "\u8BFB\u53D6\u6574\u4E2A\u77E5\u8BC6\u56FE\u8C31",
6585
+ inputSchema: {
6586
+ type: "object",
6587
+ properties: {}
6588
+ }
6589
+ },
6590
+ {
6591
+ name: "search_nodes",
6592
+ description: "\u5728\u77E5\u8BC6\u56FE\u8C31\u4E2D\u641C\u7D22\u8282\u70B9\uFF08\u6309\u540D\u79F0\u3001\u7C7B\u578B\u6216\u89C2\u5BDF\u5185\u5BB9\u5339\u914D\uFF09",
6593
+ inputSchema: {
6594
+ type: "object",
6595
+ properties: {
6596
+ query: {
6597
+ type: "string",
6598
+ description: "\u641C\u7D22\u5173\u952E\u8BCD"
6599
+ }
6600
+ },
6601
+ required: ["query"]
6602
+ }
6603
+ },
6604
+ {
6605
+ name: "open_nodes",
6606
+ description: "\u6309\u540D\u79F0\u6253\u5F00\u7279\u5B9A\u8282\u70B9",
6607
+ inputSchema: {
6608
+ type: "object",
6609
+ properties: {
6610
+ names: {
6611
+ type: "array",
6612
+ items: { type: "string" },
6613
+ description: "\u8981\u68C0\u7D22\u7684\u5B9E\u4F53\u540D\u79F0\u5217\u8868"
6614
+ }
6615
+ },
6616
+ required: ["names"]
6617
+ }
6618
+ },
6619
+ // ================== 顺序思考工具 ==================
6620
+ {
6621
+ name: "sequentialthinking",
6622
+ description: `A detailed tool for dynamic and reflective problem-solving through thoughts.
6623
+ This tool helps analyze problems through a flexible thinking process that can adapt and evolve.
6624
+ Each thought can build on, question, or revise previous insights as understanding deepens.
6625
+
6626
+ When to use this tool:
6627
+ - Breaking down complex problems into steps
6628
+ - Planning and design with room for revision
6629
+ - Analysis that might need course correction
6630
+ - Problems where the full scope might not be clear initially
6631
+ - Problems that require a multi-step solution
6632
+ - Tasks that need to maintain context over multiple steps
6633
+ - Situations where irrelevant information needs to be filtered out
6634
+
6635
+ Key features:
6636
+ - You can adjust total_thoughts up or down as you progress
6637
+ - You can question or revise previous thoughts
6638
+ - You can add more thoughts even after reaching what seemed like the end
6639
+ - You can express uncertainty and explore alternative approaches
6640
+ - Not every thought needs to build linearly - you can branch or backtrack
6641
+ - Generates a solution hypothesis
6642
+ - Verifies the hypothesis based on the Chain of Thought steps
6643
+ - Repeats the process until satisfied
6644
+ - Provides a correct answer
6645
+
6646
+ Parameters explained:
6647
+ - thought: Your current thinking step, which can include:
6648
+ * Regular analytical steps
6649
+ * Revisions of previous thoughts
6650
+ * Questions about previous decisions
6651
+ * Realizations about needing more analysis
6652
+ * Changes in approach
6653
+ * Hypothesis generation
6654
+ * Hypothesis verification
6655
+ - nextThoughtNeeded: True if you need more thinking, even if at what seemed like the end
6656
+ - thoughtNumber: Current number in sequence (can go beyond initial total if needed)
6657
+ - totalThoughts: Current estimate of thoughts needed (can be adjusted up/down)
6658
+ - isRevision: A boolean indicating if this thought revises previous thinking
6659
+ - revisesThought: If is_revision is true, which thought number is being reconsidered
6660
+ - branchFromThought: If branching, which thought number is the branching point
6661
+ - branchId: Identifier for the current branch (if any)
6662
+ - needsMoreThoughts: If reaching end but realizing more thoughts needed
6663
+
6664
+ You should:
6665
+ 1. Start with an initial estimate of needed thoughts, but be ready to adjust
6666
+ 2. Feel free to question or revise previous thoughts
6667
+ 3. Don't hesitate to add more thoughts if needed, even at the "end"
6668
+ 4. Express uncertainty when present
6669
+ 5. Mark thoughts that revise previous thinking or branch into new paths
6670
+ 6. Ignore information that is irrelevant to the current step
6671
+ 7. Generate a solution hypothesis when appropriate
6672
+ 8. Verify the hypothesis based on the Chain of Thought steps
6673
+ 9. Repeat the process until satisfied with the solution
6674
+ 10. Provide a single, ideally correct answer as the final output
6675
+ 11. Only set nextThoughtNeeded to false when truly done and a satisfactory answer is reached`,
6676
+ inputSchema: {
6677
+ type: "object",
6678
+ properties: {
6679
+ thought: {
6680
+ type: "string",
6681
+ description: "Your current thinking step"
6682
+ },
6683
+ nextThoughtNeeded: {
6684
+ type: "boolean",
6685
+ description: "Whether another thought step is needed"
6686
+ },
6687
+ thoughtNumber: {
6688
+ type: "integer",
6689
+ description: "Current thought number (numeric value, e.g., 1, 2, 3)",
6690
+ minimum: 1
6691
+ },
6692
+ totalThoughts: {
6693
+ type: "integer",
6694
+ description: "Estimated total thoughts needed (numeric value, e.g., 5, 10)",
6695
+ minimum: 1
6696
+ },
6697
+ isRevision: {
6698
+ type: "boolean",
6699
+ description: "Whether this revises previous thinking"
6700
+ },
6701
+ revisesThought: {
6702
+ type: "integer",
6703
+ description: "Which thought is being reconsidered",
6704
+ minimum: 1
6705
+ },
6706
+ branchFromThought: {
6707
+ type: "integer",
6708
+ description: "Branching point thought number",
6709
+ minimum: 1
6710
+ },
6711
+ branchId: {
6712
+ type: "string",
6713
+ description: "Branch identifier"
6714
+ },
6715
+ needsMoreThoughts: {
6716
+ type: "boolean",
6717
+ description: "If more thoughts are needed"
6718
+ }
6719
+ },
6720
+ required: ["thought", "nextThoughtNeeded", "thoughtNumber", "totalThoughts"]
6721
+ }
6263
6722
  }
6264
6723
  ]
6265
6724
  }));
@@ -6372,6 +6831,38 @@ var CopilotPromptsMCPServer = class {
6372
6831
  case "list_troubleshooting_cases":
6373
6832
  result = await listTroubleshootingCases(args == null ? void 0 : args.framework);
6374
6833
  break;
6834
+ // ================== 知识图谱记忆工具 ==================
6835
+ case "create_entities":
6836
+ result = await createEntities(args);
6837
+ break;
6838
+ case "create_relations":
6839
+ result = await createRelations(args);
6840
+ break;
6841
+ case "add_observations":
6842
+ result = await addObservations(args);
6843
+ break;
6844
+ case "delete_entities":
6845
+ result = await deleteEntities(args);
6846
+ break;
6847
+ case "delete_observations":
6848
+ result = await deleteObservations(args);
6849
+ break;
6850
+ case "delete_relations":
6851
+ result = await deleteRelations(args);
6852
+ break;
6853
+ case "read_graph":
6854
+ result = await readGraph();
6855
+ break;
6856
+ case "search_nodes":
6857
+ result = await searchNodes(args);
6858
+ break;
6859
+ case "open_nodes":
6860
+ result = await openNodes(args);
6861
+ break;
6862
+ // ================== 顺序思考工具 ==================
6863
+ case "sequentialthinking":
6864
+ result = await sequentialThinking(args);
6865
+ break;
6375
6866
  default:
6376
6867
  throw new Error(`\u672A\u77E5\u5DE5\u5177: ${name}`);
6377
6868
  }
@@ -6455,6 +6946,16 @@ var CopilotPromptsMCPServer = class {
6455
6946
  ` \u2022 analyze_reference_project - \u6DF1\u5EA6\u5206\u6790\u53C2\u8003\u9879\u76EE`,
6456
6947
  ` \u2022 generate_project_skeleton - \u751F\u6210\u9879\u76EE\u9AA8\u67B6`,
6457
6948
  ``,
6949
+ `\u{1F9E0} \u77E5\u8BC6\u56FE\u8C31\u8BB0\u5FC6:`,
6950
+ ` \u2022 create_entities - \u521B\u5EFA\u5B9E\u4F53`,
6951
+ ` \u2022 create_relations - \u521B\u5EFA\u5173\u7CFB`,
6952
+ ` \u2022 add_observations - \u6DFB\u52A0\u89C2\u5BDF`,
6953
+ ` \u2022 read_graph - \u8BFB\u53D6\u56FE\u8C31`,
6954
+ ` \u2022 search_nodes - \u641C\u7D22\u8282\u70B9`,
6955
+ ``,
6956
+ `\u{1F914} \u987A\u5E8F\u601D\u8003:`,
6957
+ ` \u2022 sequentialthinking - \u52A8\u6001\u53CD\u601D\u6027\u95EE\u9898\u89E3\u51B3`,
6958
+ ``,
6458
6959
  `\u{1F4A1} \u63D0\u793A: \u5728 Copilot Chat \u4E2D\u4F7F\u7528 @mta \u8C03\u7528\u670D\u52A1`,
6459
6960
  `\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501`
6460
6961
  ];