@neurynae/toolcairn-mcp 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (102) hide show
  1. package/bin/toolpilot-mcp.js +5 -0
  2. package/dist/index.d.ts +2 -0
  3. package/dist/index.d.ts.map +1 -0
  4. package/dist/index.js +45 -0
  5. package/dist/index.js.map +1 -0
  6. package/dist/middleware/event-logger.d.ts +19 -0
  7. package/dist/middleware/event-logger.d.ts.map +1 -0
  8. package/dist/middleware/event-logger.js +138 -0
  9. package/dist/middleware/event-logger.js.map +1 -0
  10. package/dist/schemas.d.ts +2 -0
  11. package/dist/schemas.d.ts.map +1 -0
  12. package/dist/schemas.js +3 -0
  13. package/dist/schemas.js.map +1 -0
  14. package/dist/server.d.ts +3 -0
  15. package/dist/server.d.ts.map +1 -0
  16. package/dist/server.js +116 -0
  17. package/dist/server.js.map +1 -0
  18. package/dist/server.prod.d.ts +14 -0
  19. package/dist/server.prod.d.ts.map +1 -0
  20. package/dist/server.prod.js +127 -0
  21. package/dist/server.prod.js.map +1 -0
  22. package/dist/templates/agent-instructions.d.ts +22 -0
  23. package/dist/templates/agent-instructions.d.ts.map +1 -0
  24. package/dist/templates/agent-instructions.js +155 -0
  25. package/dist/templates/agent-instructions.js.map +1 -0
  26. package/dist/tools/check-compatibility.d.ts +100 -0
  27. package/dist/tools/check-compatibility.d.ts.map +1 -0
  28. package/dist/tools/check-compatibility.js +103 -0
  29. package/dist/tools/check-compatibility.js.map +1 -0
  30. package/dist/tools/check-issue.d.ts +126 -0
  31. package/dist/tools/check-issue.d.ts.map +1 -0
  32. package/dist/tools/check-issue.js +248 -0
  33. package/dist/tools/check-issue.js.map +1 -0
  34. package/dist/tools/classify-prompt.d.ts +101 -0
  35. package/dist/tools/classify-prompt.d.ts.map +1 -0
  36. package/dist/tools/classify-prompt.js +64 -0
  37. package/dist/tools/classify-prompt.js.map +1 -0
  38. package/dist/tools/compare-tools.d.ts +102 -0
  39. package/dist/tools/compare-tools.d.ts.map +1 -0
  40. package/dist/tools/compare-tools.js +178 -0
  41. package/dist/tools/compare-tools.js.map +1 -0
  42. package/dist/tools/format-results.d.ts +44 -0
  43. package/dist/tools/format-results.d.ts.map +1 -0
  44. package/dist/tools/format-results.js +114 -0
  45. package/dist/tools/format-results.js.map +1 -0
  46. package/dist/tools/generate-tracker.d.ts +7 -0
  47. package/dist/tools/generate-tracker.d.ts.map +1 -0
  48. package/dist/tools/generate-tracker.js +408 -0
  49. package/dist/tools/generate-tracker.js.map +1 -0
  50. package/dist/tools/get-stack.d.ts +105 -0
  51. package/dist/tools/get-stack.d.ts.map +1 -0
  52. package/dist/tools/get-stack.js +156 -0
  53. package/dist/tools/get-stack.js.map +1 -0
  54. package/dist/tools/init-project-config.d.ts +107 -0
  55. package/dist/tools/init-project-config.d.ts.map +1 -0
  56. package/dist/tools/init-project-config.js +52 -0
  57. package/dist/tools/init-project-config.js.map +1 -0
  58. package/dist/tools/read-project-config.d.ts +99 -0
  59. package/dist/tools/read-project-config.d.ts.map +1 -0
  60. package/dist/tools/read-project-config.js +78 -0
  61. package/dist/tools/read-project-config.js.map +1 -0
  62. package/dist/tools/refine-requirement.d.ts +105 -0
  63. package/dist/tools/refine-requirement.d.ts.map +1 -0
  64. package/dist/tools/refine-requirement.js +77 -0
  65. package/dist/tools/refine-requirement.js.map +1 -0
  66. package/dist/tools/report-outcome.d.ts +104 -0
  67. package/dist/tools/report-outcome.d.ts.map +1 -0
  68. package/dist/tools/report-outcome.js +108 -0
  69. package/dist/tools/report-outcome.js.map +1 -0
  70. package/dist/tools/search-tools-respond.d.ts +103 -0
  71. package/dist/tools/search-tools-respond.d.ts.map +1 -0
  72. package/dist/tools/search-tools-respond.js +91 -0
  73. package/dist/tools/search-tools-respond.js.map +1 -0
  74. package/dist/tools/search-tools.d.ts +104 -0
  75. package/dist/tools/search-tools.d.ts.map +1 -0
  76. package/dist/tools/search-tools.js +77 -0
  77. package/dist/tools/search-tools.js.map +1 -0
  78. package/dist/tools/suggest-graph-update.d.ts +117 -0
  79. package/dist/tools/suggest-graph-update.d.ts.map +1 -0
  80. package/dist/tools/suggest-graph-update.js +177 -0
  81. package/dist/tools/suggest-graph-update.js.map +1 -0
  82. package/dist/tools/toolpilot-init.d.ts +103 -0
  83. package/dist/tools/toolpilot-init.d.ts.map +1 -0
  84. package/dist/tools/toolpilot-init.js +115 -0
  85. package/dist/tools/toolpilot-init.js.map +1 -0
  86. package/dist/tools/update-project-config.d.ts +104 -0
  87. package/dist/tools/update-project-config.d.ts.map +1 -0
  88. package/dist/tools/update-project-config.js +117 -0
  89. package/dist/tools/update-project-config.js.map +1 -0
  90. package/dist/tools/verify-suggestion.d.ts +113 -0
  91. package/dist/tools/verify-suggestion.d.ts.map +1 -0
  92. package/dist/tools/verify-suggestion.js +223 -0
  93. package/dist/tools/verify-suggestion.js.map +1 -0
  94. package/dist/transport.d.ts +5 -0
  95. package/dist/transport.d.ts.map +1 -0
  96. package/dist/transport.js +13 -0
  97. package/dist/transport.js.map +1 -0
  98. package/dist/utils.d.ts +4 -0
  99. package/dist/utils.d.ts.map +1 -0
  100. package/dist/utils.js +12 -0
  101. package/dist/utils.js.map +1 -0
  102. package/package.json +54 -0
@@ -0,0 +1,155 @@
1
+ // Agent instruction templates for toolpilot_init.
2
+ // Each function returns the section content to inject into the agent's instruction file.
3
+ // The agent writes the content to the appropriate file — MCP server never touches the filesystem.
4
+ const TOOLPILOT_MCP_ENTRY = {
5
+ toolpilot: {
6
+ command: 'node',
7
+ args: ['<path-to-toolpilot>/apps/mcp-server/dist/index.js'],
8
+ env: {
9
+ MEMGRAPH_URL: 'bolt://localhost:7687',
10
+ QDRANT_URL: 'http://localhost:6333',
11
+ DATABASE_URL: 'postgresql://toolpilot:toolpilot@localhost:5432/toolpilot',
12
+ REDIS_URL: 'redis://localhost:6379',
13
+ },
14
+ },
15
+ };
16
+ const CORE_RULES = `
17
+ ## ToolPilot — Tool Intelligence MCP
18
+
19
+ ToolPilot is your tool intelligence co-pilot. It has a graph database of 500+ indexed tools with health signals, compatibility data, and known issue tracking. Always use it before recommending any tool, library, or framework.
20
+
21
+ ### Workflow for Tool Selection
22
+
23
+ 1. **Before recommending any tool**: Always call \`search_tools\` first. Never recommend from training data alone.
24
+ 2. **When user describes a use case**: Call \`classify_prompt\` first, then \`refine_requirement\` if tool selection is needed.
25
+ 3. **When starting a new project**: Call \`toolpilot_init\` to set up .toolpilot/config.json.
26
+ 4. **When resuming work on a project**: Read .toolpilot/config.json via \`read_project_config\` to see confirmed tools.
27
+ 5. **When a tool is selected**: Call \`update_project_config\` to persist the choice.
28
+ 6. **When encountering an error with a tool**: Call \`check_issue\` before debugging — it may be a known issue with an open GitHub ticket.
29
+ 7. **When user asks to compare tools**: Call \`compare_tools\` for a structured comparison with health data.
30
+ 8. **When user chooses a non-indexed/proprietary tool**: Add it to config with source: "non_oss" via \`update_project_config\`.
31
+
32
+ ### Available ToolPilot MCP Tools
33
+
34
+ | Tool | When to use |
35
+ |------|------------|
36
+ | \`classify_prompt\` | User describes a task — determine if tool search needed |
37
+ | \`refine_requirement\` | Decompose vague use case into searchable tool needs |
38
+ | \`search_tools\` | Find the best tool for a specific need |
39
+ | \`search_tools_respond\` | Answer clarification questions from search_tools |
40
+ | \`get_stack\` | Get recommended tool stack for a use case |
41
+ | \`check_issue\` | Check if an error is a known tool bug before debugging |
42
+ | \`check_compatibility\` | Check if two tools work well together |
43
+ | \`compare_tools\` | Compare two tools with health and graph data |
44
+ | \`report_outcome\` | Report whether a recommended tool worked (improves future results) |
45
+ | \`toolpilot_init\` | Set up ToolPilot for a new project |
46
+ | \`init_project_config\` | Initialize .toolpilot/config.json |
47
+ | \`read_project_config\` | Parse .toolpilot/config.json to get confirmed tools |
48
+ | \`update_project_config\` | Add/remove/update tools in .toolpilot/config.json |
49
+ | \`suggest_graph_update\` | Suggest a new tool or relationship for the ToolPilot graph |
50
+
51
+ ### Rules
52
+
53
+ - NEVER recommend a tool without first checking ToolPilot unless the tool is already in .toolpilot/config.json
54
+ - Always check .toolpilot/config.json at the start of a session if it exists
55
+ - Prefer open-source tools from ToolPilot index; flag proprietary alternatives clearly
56
+ - After selecting a tool, always call \`update_project_config\` to persist it
57
+ - After using a tool successfully/unsuccessfully, call \`report_outcome\`
58
+ `;
59
+ export function getClaudeInstructions() {
60
+ return {
61
+ file_path: 'CLAUDE.md',
62
+ mode: 'append',
63
+ content: CORE_RULES,
64
+ };
65
+ }
66
+ export function getCursorInstructions() {
67
+ return {
68
+ file_path: '.cursorrules',
69
+ mode: 'append',
70
+ content: CORE_RULES,
71
+ };
72
+ }
73
+ export function getWindsurfInstructions() {
74
+ return {
75
+ file_path: '.windsurfrules',
76
+ mode: 'append',
77
+ content: CORE_RULES,
78
+ };
79
+ }
80
+ export function getCopilotInstructions() {
81
+ return {
82
+ file_path: '.github/copilot-instructions.md',
83
+ mode: 'create',
84
+ content: `# GitHub Copilot Instructions\n${CORE_RULES}`,
85
+ };
86
+ }
87
+ export function getCopilotCliInstructions() {
88
+ // GitHub Copilot CLI reads .github/copilot-instructions.md and AGENTS.md
89
+ return {
90
+ file_path: '.github/copilot-instructions.md',
91
+ mode: 'append',
92
+ content: CORE_RULES,
93
+ };
94
+ }
95
+ export function getOpenCodeInstructions() {
96
+ // OpenCode reads AGENTS.md (falls back to CLAUDE.md if absent)
97
+ return {
98
+ file_path: 'AGENTS.md',
99
+ mode: 'append',
100
+ content: CORE_RULES,
101
+ };
102
+ }
103
+ export function getGenericInstructions() {
104
+ return {
105
+ file_path: 'AI_INSTRUCTIONS.md',
106
+ mode: 'create',
107
+ content: `# AI Assistant Instructions\n${CORE_RULES}`,
108
+ };
109
+ }
110
+ export function getInstructionsForAgent(agent) {
111
+ switch (agent) {
112
+ case 'claude':
113
+ return getClaudeInstructions();
114
+ case 'cursor':
115
+ return getCursorInstructions();
116
+ case 'windsurf':
117
+ return getWindsurfInstructions();
118
+ case 'copilot':
119
+ return getCopilotInstructions();
120
+ case 'copilot-cli':
121
+ return getCopilotCliInstructions();
122
+ case 'opencode':
123
+ return getOpenCodeInstructions();
124
+ case 'generic':
125
+ return getGenericInstructions();
126
+ }
127
+ }
128
+ export function getMcpConfigEntry(serverPath) {
129
+ const entry = { ...TOOLPILOT_MCP_ENTRY };
130
+ if (serverPath) {
131
+ entry.toolpilot = {
132
+ ...entry.toolpilot,
133
+ args: [serverPath],
134
+ };
135
+ }
136
+ return entry;
137
+ }
138
+ /** Returns OpenCode-specific MCP config (opencode.json format under "mcp" key). */
139
+ export function getOpenCodeMcpEntry(serverPath) {
140
+ const resolvedPath = serverPath ?? '<path-to-toolpilot>/apps/mcp-server/dist/index.js';
141
+ return {
142
+ toolpilot: {
143
+ type: 'local',
144
+ command: ['node', resolvedPath],
145
+ env: {
146
+ MEMGRAPH_URL: 'bolt://localhost:7687',
147
+ QDRANT_URL: 'http://localhost:6333',
148
+ DATABASE_URL: 'postgresql://toolpilot:toolpilot@localhost:5432/toolpilot',
149
+ REDIS_URL: 'redis://localhost:6379',
150
+ },
151
+ enabled: true,
152
+ },
153
+ };
154
+ }
155
+ //# sourceMappingURL=agent-instructions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent-instructions.js","sourceRoot":"","sources":["../../src/templates/agent-instructions.ts"],"names":[],"mappings":"AAAA,kDAAkD;AAClD,yFAAyF;AACzF,kGAAkG;AAoBlG,MAAM,mBAAmB,GAAG;IAC1B,SAAS,EAAE;QACT,OAAO,EAAE,MAAM;QACf,IAAI,EAAE,CAAC,mDAAmD,CAAC;QAC3D,GAAG,EAAE;YACH,YAAY,EAAE,uBAAuB;YACrC,UAAU,EAAE,uBAAuB;YACnC,YAAY,EAAE,2DAA2D;YACzE,SAAS,EAAE,wBAAwB;SACpC;KACF;CACF,CAAC;AAEF,MAAM,UAAU,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA0ClB,CAAC;AAEF,MAAM,UAAU,qBAAqB;IACnC,OAAO;QACL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C,KAAK,aAAa;YAChB,OAAO,yBAAyB,EAAE,CAAC;QACrC,KAAK,UAAU;YACb,OAAO,uBAAuB,EAAE,CAAC;QACnC,KAAK,SAAS;YACZ,OAAO,sBAAsB,EAAE,CAAC;IACpC,CAAC;AACH,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,UAAmB;IACnD,MAAM,KAAK,GAAG,EAAE,GAAG,mBAAmB,EAAE,CAAC;IACzC,IAAI,UAAU,EAAE,CAAC;QACf,KAAK,CAAC,SAAS,GAAG;YAChB,GAAG,KAAK,CAAC,SAAS;YAClB,IAAI,EAAE,CAAC,UAAU,CAAC;SACnB,CAAC;IACJ,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,mFAAmF;AACnF,MAAM,UAAU,mBAAmB,CAAC,UAAmB;IACrD,MAAM,YAAY,GAAG,UAAU,IAAI,mDAAmD,CAAC;IACvF,OAAO;QACL,SAAS,EAAE;YACT,IAAI,EAAE,OAAO;YACb,OAAO,EAAE,CAAC,MAAM,EAAE,YAAY,CAAC;YAC/B,GAAG,EAAE;gBACH,YAAY,EAAE,uBAAuB;gBACrC,UAAU,EAAE,uBAAuB;gBACnC,YAAY,EAAE,2DAA2D;gBACzE,SAAS,EAAE,wBAAwB;aACpC;YACD,OAAO,EAAE,IAAI;SACd;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,100 @@
1
+ export declare function handleCheckCompatibility(args: {
2
+ tool_a: string;
3
+ tool_b: string;
4
+ }): Promise<{
5
+ [x: string]: unknown;
6
+ content: ({
7
+ type: "text";
8
+ text: string;
9
+ annotations?: {
10
+ audience?: ("user" | "assistant")[] | undefined;
11
+ priority?: number | undefined;
12
+ lastModified?: string | undefined;
13
+ } | undefined;
14
+ _meta?: {
15
+ [x: string]: unknown;
16
+ } | undefined;
17
+ } | {
18
+ type: "image";
19
+ data: string;
20
+ mimeType: string;
21
+ annotations?: {
22
+ audience?: ("user" | "assistant")[] | undefined;
23
+ priority?: number | undefined;
24
+ lastModified?: string | undefined;
25
+ } | undefined;
26
+ _meta?: {
27
+ [x: string]: unknown;
28
+ } | undefined;
29
+ } | {
30
+ type: "audio";
31
+ data: string;
32
+ mimeType: string;
33
+ annotations?: {
34
+ audience?: ("user" | "assistant")[] | undefined;
35
+ priority?: number | undefined;
36
+ lastModified?: string | undefined;
37
+ } | undefined;
38
+ _meta?: {
39
+ [x: string]: unknown;
40
+ } | undefined;
41
+ } | {
42
+ uri: string;
43
+ name: string;
44
+ type: "resource_link";
45
+ description?: string | undefined;
46
+ mimeType?: string | undefined;
47
+ annotations?: {
48
+ audience?: ("user" | "assistant")[] | undefined;
49
+ priority?: number | undefined;
50
+ lastModified?: string | undefined;
51
+ } | undefined;
52
+ _meta?: {
53
+ [x: string]: unknown;
54
+ } | undefined;
55
+ icons?: {
56
+ src: string;
57
+ mimeType?: string | undefined;
58
+ sizes?: string[] | undefined;
59
+ theme?: "light" | "dark" | undefined;
60
+ }[] | undefined;
61
+ title?: string | undefined;
62
+ } | {
63
+ type: "resource";
64
+ resource: {
65
+ uri: string;
66
+ text: string;
67
+ mimeType?: string | undefined;
68
+ _meta?: {
69
+ [x: string]: unknown;
70
+ } | undefined;
71
+ } | {
72
+ uri: string;
73
+ blob: string;
74
+ mimeType?: string | undefined;
75
+ _meta?: {
76
+ [x: string]: unknown;
77
+ } | undefined;
78
+ };
79
+ annotations?: {
80
+ audience?: ("user" | "assistant")[] | undefined;
81
+ priority?: number | undefined;
82
+ lastModified?: string | undefined;
83
+ } | undefined;
84
+ _meta?: {
85
+ [x: string]: unknown;
86
+ } | undefined;
87
+ })[];
88
+ _meta?: {
89
+ [x: string]: unknown;
90
+ progressToken?: string | number | undefined;
91
+ "io.modelcontextprotocol/related-task"?: {
92
+ taskId: string;
93
+ } | undefined;
94
+ } | undefined;
95
+ structuredContent?: {
96
+ [x: string]: unknown;
97
+ } | undefined;
98
+ isError?: boolean | undefined;
99
+ }>;
100
+ //# sourceMappingURL=check-compatibility.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"check-compatibility.d.ts","sourceRoot":"","sources":["../../src/tools/check-compatibility.ts"],"names":[],"mappings":"AAaA,wBAAsB,wBAAwB,CAAC,IAAI,EAAE;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8GtF"}
@@ -0,0 +1,103 @@
1
+ import { MemgraphToolRepository } from '@toolpilot/graph';
2
+ import pino from 'pino';
3
+ import { errResult, okResult } from '../utils.js';
4
+ const logger = pino({ name: '@toolpilot/mcp-server:check-compatibility' });
5
+ const repo = new MemgraphToolRepository();
6
+ const COMPATIBLE_TYPES = new Set(['COMPATIBLE_WITH', 'INTEGRATES_WITH', 'POPULAR_WITH']);
7
+ const CONFLICT_TYPES = new Set(['CONFLICTS_WITH', 'BREAKS_FROM']);
8
+ const REQUIRES_TYPES = new Set(['REQUIRES']);
9
+ export async function handleCheckCompatibility(args) {
10
+ try {
11
+ logger.info({ tool_a: args.tool_a, tool_b: args.tool_b }, 'check_compatibility called');
12
+ // Verify both tools exist
13
+ const [existsA, existsB] = await Promise.all([
14
+ repo.toolExists(args.tool_a),
15
+ repo.toolExists(args.tool_b),
16
+ ]);
17
+ if (!existsA.ok || !existsA.data) {
18
+ return errResult('tool_not_found', `Tool "${args.tool_a}" not found in the ToolPilot index`);
19
+ }
20
+ if (!existsB.ok || !existsB.data) {
21
+ return errResult('tool_not_found', `Tool "${args.tool_b}" not found in the ToolPilot index`);
22
+ }
23
+ // Check direct edges between the two tools
24
+ const edgesResult = await repo.getDirectEdges(args.tool_a, args.tool_b);
25
+ if (!edgesResult.ok) {
26
+ return errResult('graph_error', edgesResult.error.message);
27
+ }
28
+ const edges = edgesResult.data;
29
+ let status = 'unknown';
30
+ let confidence = 0.5;
31
+ const signals = [];
32
+ if (edges.length > 0) {
33
+ // Direct edges — high confidence
34
+ confidence = Math.max(...edges.map((e) => e.confidence));
35
+ if (edges.some((e) => CONFLICT_TYPES.has(e.edgeType))) {
36
+ status = 'conflicts';
37
+ signals.push(`Direct ${edges.find((e) => CONFLICT_TYPES.has(e.edgeType))?.edgeType} edge found`);
38
+ }
39
+ else if (edges.some((e) => COMPATIBLE_TYPES.has(e.edgeType))) {
40
+ status = 'compatible';
41
+ signals.push(`Direct ${edges.find((e) => COMPATIBLE_TYPES.has(e.edgeType))?.edgeType} edge found`);
42
+ }
43
+ else if (edges.some((e) => REQUIRES_TYPES.has(e.edgeType))) {
44
+ status = 'requires';
45
+ signals.push('Direct REQUIRES relationship found');
46
+ }
47
+ }
48
+ else {
49
+ // No direct edges — check 2-hop paths via shared neighbors
50
+ const [neighborsA, neighborsB] = await Promise.all([
51
+ repo.getRelated(args.tool_a, 10),
52
+ repo.getRelated(args.tool_b, 10),
53
+ ]);
54
+ if (neighborsA.ok && neighborsB.ok) {
55
+ const namesA = new Set(neighborsA.data.map((t) => t.name));
56
+ const namesB = new Set(neighborsB.data.map((t) => t.name));
57
+ const sharedNeighbors = [...namesA].filter((n) => namesB.has(n));
58
+ if (sharedNeighbors.length >= 3) {
59
+ status = 'compatible';
60
+ confidence = 0.6;
61
+ signals.push(`${sharedNeighbors.length} shared graph neighbors suggest these tools are used together`);
62
+ }
63
+ else if (sharedNeighbors.length > 0) {
64
+ status = 'unknown';
65
+ confidence = 0.4;
66
+ signals.push(`${sharedNeighbors.length} shared neighbors found — insufficient for strong inference`);
67
+ }
68
+ else {
69
+ signals.push('No direct edges or shared neighbors — these tools may operate in different domains');
70
+ }
71
+ }
72
+ }
73
+ const recommendation = status === 'compatible'
74
+ ? `${args.tool_a} and ${args.tool_b} can be used together.`
75
+ : status === 'conflicts'
76
+ ? `${args.tool_a} and ${args.tool_b} have known conflicts. Avoid using them in the same project.`
77
+ : status === 'requires'
78
+ ? 'One of these tools requires the other. Check the direction of the REQUIRES edge.'
79
+ : 'No direct compatibility data. These tools may work together but it has not been verified.';
80
+ return okResult({
81
+ tool_a: args.tool_a,
82
+ tool_b: args.tool_b,
83
+ status,
84
+ confidence: Math.round(confidence * 100) / 100,
85
+ direct_edges: edges.map((e) => ({
86
+ type: e.edgeType,
87
+ direction: e.direction,
88
+ confidence: Math.round(e.confidence * 100) / 100,
89
+ effective_weight: Math.round(e.effective_weight * 100) / 100,
90
+ })),
91
+ signals,
92
+ recommendation,
93
+ suggest_graph_update: status === 'unknown'
94
+ ? `If you discover compatibility data, call suggest_graph_update with suggestion_type: "new_edge" to contribute it back.`
95
+ : null,
96
+ });
97
+ }
98
+ catch (e) {
99
+ logger.error({ err: e }, 'check_compatibility failed');
100
+ return errResult('compatibility_error', e instanceof Error ? e.message : String(e));
101
+ }
102
+ }
103
+ //# sourceMappingURL=check-compatibility.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"check-compatibility.js","sourceRoot":"","sources":["../../src/tools/check-compatibility.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAC1D,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAElD,MAAM,MAAM,GAAG,IAAI,CAAC,EAAE,IAAI,EAAE,2CAA2C,EAAE,CAAC,CAAC;AAC3E,MAAM,IAAI,GAAG,IAAI,sBAAsB,EAAE,CAAC;AAE1C,MAAM,gBAAgB,GAAG,IAAI,GAAG,CAAC,CAAC,iBAAiB,EAAE,iBAAiB,EAAE,cAAc,CAAC,CAAC,CAAC;AACzF,MAAM,cAAc,GAAG,IAAI,GAAG,CAAC,CAAC,gBAAgB,EAAE,aAAa,CAAC,CAAC,CAAC;AAClE,MAAM,cAAc,GAAG,IAAI,GAAG,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC;AAI7C,MAAM,CAAC,KAAK,UAAU,wBAAwB,CAAC,IA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check_issue — Checks GitHub directly for known issues matching an error.
3
+ *
4
+ * IMPORTANT: This is a last-resort tool. The agent should:
5
+ * 1. Try to fix the error itself (2 retries)
6
+ * 2. Consult the tool's documentation (2 more retries)
7
+ * 3. ONLY THEN call check_issue (pass retry_count≥4, docs_consulted=true)
8
+ *
9
+ * This prevents spamming the GitHub API for errors that are config issues,
10
+ * environment problems, or things the docs would explain.
11
+ *
12
+ * Flow:
13
+ * 1. Gate: enforce retry + docs requirements
14
+ * 2. Look up tool's github_url in Memgraph
15
+ * 3. Search GitHub Issues API directly (no local DB — live data)
16
+ * 4. Also search for PRs that may fix the issue
17
+ * 5. Return one of four statuses:
18
+ * - not_found: no matching issue on GitHub → agent handles it
19
+ * - fix_in_progress: open issue + open PR exists → track PR
20
+ * - known_issue_no_fix: open issue, no PR → gist + ask user intent
21
+ * - fixed_in_version: closed issue → which version fixed it
22
+ * 6. In real-issue cases (3/4): add 👍 reaction to the issue via GitHub API
23
+ */
24
+ export declare function handleCheckIssue(args: {
25
+ tool_name: string;
26
+ issue_title: string;
27
+ retry_count?: number;
28
+ docs_consulted?: boolean;
29
+ issue_url?: string;
30
+ }): Promise<{
31
+ [x: string]: unknown;
32
+ content: ({
33
+ type: "text";
34
+ text: string;
35
+ annotations?: {
36
+ audience?: ("user" | "assistant")[] | undefined;
37
+ priority?: number | undefined;
38
+ lastModified?: string | undefined;
39
+ } | undefined;
40
+ _meta?: {
41
+ [x: string]: unknown;
42
+ } | undefined;
43
+ } | {
44
+ type: "image";
45
+ data: string;
46
+ mimeType: string;
47
+ annotations?: {
48
+ audience?: ("user" | "assistant")[] | undefined;
49
+ priority?: number | undefined;
50
+ lastModified?: string | undefined;
51
+ } | undefined;
52
+ _meta?: {
53
+ [x: string]: unknown;
54
+ } | undefined;
55
+ } | {
56
+ type: "audio";
57
+ data: string;
58
+ mimeType: string;
59
+ annotations?: {
60
+ audience?: ("user" | "assistant")[] | undefined;
61
+ priority?: number | undefined;
62
+ lastModified?: string | undefined;
63
+ } | undefined;
64
+ _meta?: {
65
+ [x: string]: unknown;
66
+ } | undefined;
67
+ } | {
68
+ uri: string;
69
+ name: string;
70
+ type: "resource_link";
71
+ description?: string | undefined;
72
+ mimeType?: string | undefined;
73
+ annotations?: {
74
+ audience?: ("user" | "assistant")[] | undefined;
75
+ priority?: number | undefined;
76
+ lastModified?: string | undefined;
77
+ } | undefined;
78
+ _meta?: {
79
+ [x: string]: unknown;
80
+ } | undefined;
81
+ icons?: {
82
+ src: string;
83
+ mimeType?: string | undefined;
84
+ sizes?: string[] | undefined;
85
+ theme?: "light" | "dark" | undefined;
86
+ }[] | undefined;
87
+ title?: string | undefined;
88
+ } | {
89
+ type: "resource";
90
+ resource: {
91
+ uri: string;
92
+ text: string;
93
+ mimeType?: string | undefined;
94
+ _meta?: {
95
+ [x: string]: unknown;
96
+ } | undefined;
97
+ } | {
98
+ uri: string;
99
+ blob: string;
100
+ mimeType?: string | undefined;
101
+ _meta?: {
102
+ [x: string]: unknown;
103
+ } | undefined;
104
+ };
105
+ annotations?: {
106
+ audience?: ("user" | "assistant")[] | undefined;
107
+ priority?: number | undefined;
108
+ lastModified?: string | undefined;
109
+ } | undefined;
110
+ _meta?: {
111
+ [x: string]: unknown;
112
+ } | undefined;
113
+ })[];
114
+ _meta?: {
115
+ [x: string]: unknown;
116
+ progressToken?: string | number | undefined;
117
+ "io.modelcontextprotocol/related-task"?: {
118
+ taskId: string;
119
+ } | undefined;
120
+ } | undefined;
121
+ structuredContent?: {
122
+ [x: string]: unknown;
123
+ } | undefined;
124
+ isError?: boolean | undefined;
125
+ }>;
126
+ //# sourceMappingURL=check-issue.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"check-issue.d.ts","sourceRoot":"","sources":["../../src/tools/check-issue.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AA8GH,wBAAsB,gBAAgB,CAAC,IAAI,EAAE;IAC3C,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+KA"}