@codesherlock/codesherlock-alpha-mcp-server 0.0.28 → 0.1.4
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/.env +0 -1
- package/README.md +331 -56
- package/build/index.js +88 -81
- package/package.json +7 -2
- package/build/handlers/analyzeCommitHandler.d.ts +0 -36
- package/build/handlers/analyzeCommitHandler.d.ts.map +0 -1
- package/build/handlers/analyzeCommitHandler.js +0 -397
- package/build/handlers/analyzeCommitHandler.js.map +0 -1
- package/build/handlers/events.d.ts +0 -7
- package/build/handlers/events.d.ts.map +0 -1
- package/build/handlers/events.js +0 -15
- package/build/handlers/events.js.map +0 -1
- package/build/handlers/resources.d.ts +0 -10
- package/build/handlers/resources.d.ts.map +0 -1
- package/build/handlers/resources.js +0 -14
- package/build/handlers/resources.js.map +0 -1
- package/build/handlers/tools.d.ts +0 -6
- package/build/handlers/tools.d.ts.map +0 -1
- package/build/handlers/tools.js +0 -29
- package/build/handlers/tools.js.map +0 -1
- package/build/index.d.ts +0 -3
- package/build/index.d.ts.map +0 -1
- package/build/index.js.map +0 -1
- package/build/schemas/toolSchemas.d.ts +0 -50
- package/build/schemas/toolSchemas.d.ts.map +0 -1
- package/build/schemas/toolSchemas.js +0 -48
- package/build/schemas/toolSchemas.js.map +0 -1
- package/build/services/backendApiService.d.ts +0 -81
- package/build/services/backendApiService.d.ts.map +0 -1
- package/build/services/backendApiService.js +0 -265
- package/build/services/backendApiService.js.map +0 -1
- package/build/services/commitReviewService.d.ts +0 -71
- package/build/services/commitReviewService.d.ts.map +0 -1
- package/build/services/commitReviewService.js +0 -506
- package/build/services/commitReviewService.js.map +0 -1
- package/build/services/gitService.d.ts +0 -159
- package/build/services/gitService.d.ts.map +0 -1
- package/build/services/gitService.js +0 -778
- package/build/services/gitService.js.map +0 -1
- package/build/services/loggingService.d.ts +0 -64
- package/build/services/loggingService.d.ts.map +0 -1
- package/build/services/loggingService.js +0 -185
- package/build/services/loggingService.js.map +0 -1
- package/build/services/zipService.d.ts +0 -9
- package/build/services/zipService.d.ts.map +0 -1
- package/build/services/zipService.js +0 -47
- package/build/services/zipService.js.map +0 -1
- package/build/tests/analysisFormatter.test.d.ts +0 -2
- package/build/tests/analysisFormatter.test.d.ts.map +0 -1
- package/build/tests/analysisFormatter.test.js +0 -92
- package/build/tests/analysisFormatter.test.js.map +0 -1
- package/build/tests/analyzeCommitHandler.test.d.ts +0 -2
- package/build/tests/analyzeCommitHandler.test.d.ts.map +0 -1
- package/build/tests/analyzeCommitHandler.test.js +0 -111
- package/build/tests/analyzeCommitHandler.test.js.map +0 -1
- package/build/tests/backendApiService.test.d.ts +0 -2
- package/build/tests/backendApiService.test.d.ts.map +0 -1
- package/build/tests/backendApiService.test.js +0 -109
- package/build/tests/backendApiService.test.js.map +0 -1
- package/build/tests/commitReviewService.test.d.ts +0 -2
- package/build/tests/commitReviewService.test.d.ts.map +0 -1
- package/build/tests/commitReviewService.test.js +0 -120
- package/build/tests/commitReviewService.test.js.map +0 -1
- package/build/tests/errorExtractor.test.d.ts +0 -2
- package/build/tests/errorExtractor.test.d.ts.map +0 -1
- package/build/tests/errorExtractor.test.js +0 -61
- package/build/tests/errorExtractor.test.js.map +0 -1
- package/build/tests/loggingService.test.d.ts +0 -2
- package/build/tests/loggingService.test.d.ts.map +0 -1
- package/build/tests/loggingService.test.js +0 -153
- package/build/tests/loggingService.test.js.map +0 -1
- package/build/tests/setup.test.d.ts +0 -2
- package/build/tests/setup.test.d.ts.map +0 -1
- package/build/tests/setup.test.js +0 -7
- package/build/tests/setup.test.js.map +0 -1
- package/build/tests/tools.test.d.ts +0 -2
- package/build/tests/tools.test.d.ts.map +0 -1
- package/build/tests/tools.test.js +0 -58
- package/build/tests/tools.test.js.map +0 -1
- package/build/utils/analysisFormatter.d.ts +0 -40
- package/build/utils/analysisFormatter.d.ts.map +0 -1
- package/build/utils/analysisFormatter.js +0 -97
- package/build/utils/analysisFormatter.js.map +0 -1
- package/build/utils/errorExtractor.d.ts +0 -36
- package/build/utils/errorExtractor.d.ts.map +0 -1
- package/build/utils/errorExtractor.js +0 -178
- package/build/utils/errorExtractor.js.map +0 -1
|
@@ -1,397 +0,0 @@
|
|
|
1
|
-
import { logger } from "../services/loggingService.js";
|
|
2
|
-
import { formatMultipleFileAnalysisToMarkdown } from "../utils/analysisFormatter.js";
|
|
3
|
-
import { extractErrorDetails } from "../utils/errorExtractor.js";
|
|
4
|
-
import fs from "fs";
|
|
5
|
-
import path from "path";
|
|
6
|
-
/**
|
|
7
|
-
* Helper to log the exact structuredContent object we are about to return to MCP.
|
|
8
|
-
* This is critical for debugging schema validation issues like:
|
|
9
|
-
* "Structured content does not match the tool's output schema: data.errorType should be equal to one of the allowed values"
|
|
10
|
-
*/
|
|
11
|
-
function logStructuredContentDebug(label, structuredContent) {
|
|
12
|
-
try {
|
|
13
|
-
const payload = structuredContent;
|
|
14
|
-
logger.logInfo(label, {
|
|
15
|
-
success: String(payload?.success),
|
|
16
|
-
errorType: payload?.errorType ? String(payload.errorType) : "",
|
|
17
|
-
hasErrorType: payload && "errorType" in payload ? "true" : "false",
|
|
18
|
-
statusCode: payload?.statusCode !== undefined ? String(payload.statusCode) : "",
|
|
19
|
-
// Truncate JSON to avoid massive logs while still being useful for debugging
|
|
20
|
-
structuredContentPreview: JSON.stringify(payload).slice(0, 2000),
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
catch (e) {
|
|
24
|
-
logger.logError("Failed to log structuredContent debug payload", e);
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
export const createAnalyzeCommitHandler = (gitService, commitReviewService, backendApiService) => {
|
|
28
|
-
return async ({ uncommitted, directory, factor }) => {
|
|
29
|
-
try {
|
|
30
|
-
// Normalize factor: map "power" to "power_analysis" for backward compatibility
|
|
31
|
-
const normalizedFactor = factor === "power" ? "power_analysis" : factor;
|
|
32
|
-
logger.logInfo("=== TOOL INVOKED: analyze_commit ===", {
|
|
33
|
-
uncommitted: String(uncommitted),
|
|
34
|
-
directory,
|
|
35
|
-
originalFactor: factor,
|
|
36
|
-
normalizedFactor,
|
|
37
|
-
});
|
|
38
|
-
// Validate directory exists
|
|
39
|
-
if (!fs.existsSync(directory)) {
|
|
40
|
-
const errorDetails = extractErrorDetails(new Error("Directory does not exist"));
|
|
41
|
-
const structuredContent = {
|
|
42
|
-
success: false,
|
|
43
|
-
error: errorDetails.userMessage,
|
|
44
|
-
errorType: errorDetails.errorType,
|
|
45
|
-
statusCode: 404,
|
|
46
|
-
errorDetails: {
|
|
47
|
-
userMessage: errorDetails.userMessage,
|
|
48
|
-
technicalDetails: `Directory not found: ${directory}`,
|
|
49
|
-
retryable: false,
|
|
50
|
-
},
|
|
51
|
-
};
|
|
52
|
-
logStructuredContentDebug("analyze_commit: returning error (directory does not exist)", structuredContent);
|
|
53
|
-
return {
|
|
54
|
-
content: [
|
|
55
|
-
{
|
|
56
|
-
type: "text",
|
|
57
|
-
text: `Error: ${errorDetails.userMessage}`,
|
|
58
|
-
},
|
|
59
|
-
],
|
|
60
|
-
structuredContent,
|
|
61
|
-
isError: true,
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
|
-
// Step 1: Get file changes from Git
|
|
65
|
-
logger.logInfo("Fetching file changes", {
|
|
66
|
-
uncommitted: String(uncommitted),
|
|
67
|
-
directory,
|
|
68
|
-
factor
|
|
69
|
-
});
|
|
70
|
-
let fileChanges;
|
|
71
|
-
try {
|
|
72
|
-
logger.logInfo("Calling gitService.analyzeGitChanges", {
|
|
73
|
-
uncommitted: String(uncommitted),
|
|
74
|
-
directory
|
|
75
|
-
});
|
|
76
|
-
fileChanges = await gitService.analyzeGitChanges(uncommitted, directory);
|
|
77
|
-
logger.logInfo("File changes received from gitService", {
|
|
78
|
-
fileCount: String(fileChanges.length),
|
|
79
|
-
files: JSON.stringify(fileChanges.map(f => ({
|
|
80
|
-
filename: f.filename,
|
|
81
|
-
status: f.status,
|
|
82
|
-
contentLength: String(f.new_content?.length || 0),
|
|
83
|
-
patchLength: String(f.patch?.length || 0)
|
|
84
|
-
})))
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
|
-
catch (error) {
|
|
88
|
-
const errorDetails = extractErrorDetails(error);
|
|
89
|
-
logger.logError("Failed to analyze git changes", error, { directory, uncommitted: String(uncommitted) });
|
|
90
|
-
const structuredContent = {
|
|
91
|
-
success: false,
|
|
92
|
-
error: errorDetails.userMessage,
|
|
93
|
-
errorType: errorDetails.errorType,
|
|
94
|
-
statusCode: errorDetails.statusCode,
|
|
95
|
-
errorDetails: {
|
|
96
|
-
userMessage: errorDetails.userMessage,
|
|
97
|
-
technicalDetails: errorDetails.technicalDetails,
|
|
98
|
-
retryable: errorDetails.retryable,
|
|
99
|
-
},
|
|
100
|
-
};
|
|
101
|
-
logStructuredContentDebug("analyze_commit: returning error (gitService.analyzeGitChanges failed)", structuredContent);
|
|
102
|
-
return {
|
|
103
|
-
content: [
|
|
104
|
-
{
|
|
105
|
-
type: "text",
|
|
106
|
-
text: `Error: ${errorDetails.userMessage}`,
|
|
107
|
-
},
|
|
108
|
-
],
|
|
109
|
-
structuredContent,
|
|
110
|
-
isError: true,
|
|
111
|
-
};
|
|
112
|
-
}
|
|
113
|
-
// Validate that we have file changes
|
|
114
|
-
if (!fileChanges || fileChanges.length === 0) {
|
|
115
|
-
const errorDetails = extractErrorDetails(new Error("No file changes found in the commit"));
|
|
116
|
-
const structuredContent = {
|
|
117
|
-
success: false,
|
|
118
|
-
error: errorDetails.userMessage,
|
|
119
|
-
errorType: "validation_error",
|
|
120
|
-
statusCode: 422,
|
|
121
|
-
errorDetails: {
|
|
122
|
-
userMessage: "No file changes found. Please ensure you have committed changes or uncommitted changes to analyze.",
|
|
123
|
-
technicalDetails: "Git analysis returned empty file changes array",
|
|
124
|
-
retryable: false,
|
|
125
|
-
},
|
|
126
|
-
};
|
|
127
|
-
logStructuredContentDebug("analyze_commit: returning error (no file changes)", structuredContent);
|
|
128
|
-
return {
|
|
129
|
-
content: [
|
|
130
|
-
{
|
|
131
|
-
type: "text",
|
|
132
|
-
text: `Error: ${errorDetails.userMessage}`,
|
|
133
|
-
},
|
|
134
|
-
],
|
|
135
|
-
structuredContent,
|
|
136
|
-
isError: true,
|
|
137
|
-
};
|
|
138
|
-
}
|
|
139
|
-
// Validate file changes structure before sending to backend
|
|
140
|
-
// Each file change should have required fields: filename, status, new_content
|
|
141
|
-
const invalidFiles = [];
|
|
142
|
-
for (let i = 0; i < fileChanges.length; i++) {
|
|
143
|
-
const file = fileChanges[i];
|
|
144
|
-
if (!file || typeof file !== "object") {
|
|
145
|
-
invalidFiles.push(`File at index ${i} is not a valid object`);
|
|
146
|
-
continue;
|
|
147
|
-
}
|
|
148
|
-
if (!file.filename || typeof file.filename !== "string") {
|
|
149
|
-
invalidFiles.push(`File at index ${i} is missing or has invalid 'filename' field`);
|
|
150
|
-
}
|
|
151
|
-
if (!file.status || typeof file.status !== "string") {
|
|
152
|
-
invalidFiles.push(`File at index ${i} is missing or has invalid 'status' field`);
|
|
153
|
-
}
|
|
154
|
-
if (file.new_content === undefined) {
|
|
155
|
-
invalidFiles.push(`File at index ${i} is missing 'new_content' field`);
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
if (invalidFiles.length > 0) {
|
|
159
|
-
const errorMessage = `Invalid file changes structure: ${invalidFiles.join("; ")}`;
|
|
160
|
-
const errorDetails = extractErrorDetails(new Error(errorMessage));
|
|
161
|
-
logger.logError("Invalid file changes structure", new Error(errorMessage), {
|
|
162
|
-
invalidFilesCount: String(invalidFiles.length),
|
|
163
|
-
});
|
|
164
|
-
const structuredContent = {
|
|
165
|
-
success: false,
|
|
166
|
-
error: errorDetails.userMessage,
|
|
167
|
-
errorType: "validation_error",
|
|
168
|
-
statusCode: 422,
|
|
169
|
-
errorDetails: {
|
|
170
|
-
userMessage: "Invalid file changes structure. Each file must have 'filename', 'status', and 'new_content' fields.",
|
|
171
|
-
technicalDetails: errorMessage,
|
|
172
|
-
retryable: false,
|
|
173
|
-
},
|
|
174
|
-
};
|
|
175
|
-
logStructuredContentDebug("analyze_commit: returning error (invalid file changes structure)", structuredContent);
|
|
176
|
-
return {
|
|
177
|
-
content: [
|
|
178
|
-
{
|
|
179
|
-
type: "text",
|
|
180
|
-
text: `Error: ${errorDetails.userMessage}`,
|
|
181
|
-
},
|
|
182
|
-
],
|
|
183
|
-
structuredContent,
|
|
184
|
-
isError: true,
|
|
185
|
-
};
|
|
186
|
-
}
|
|
187
|
-
// Fetch commit identifier directly from Git (avoid relying on agent input)
|
|
188
|
-
let commitId;
|
|
189
|
-
try {
|
|
190
|
-
commitId = await gitService.getCurrentCommitHash(directory);
|
|
191
|
-
}
|
|
192
|
-
catch (error) {
|
|
193
|
-
const errorDetails = extractErrorDetails(error);
|
|
194
|
-
logger.logError("Failed to get commit hash", error, { directory });
|
|
195
|
-
// Use fallback commit ID
|
|
196
|
-
commitId = "UNCOMMITTED";
|
|
197
|
-
logger.logWarning("Using fallback commit ID", { commitId });
|
|
198
|
-
}
|
|
199
|
-
// Step 2: Get user info dynamically from secure_route endpoint
|
|
200
|
-
logger.logInfo("Fetching user information from secure route");
|
|
201
|
-
let user;
|
|
202
|
-
try {
|
|
203
|
-
user = await backendApiService.getUserFromSecureRoute();
|
|
204
|
-
}
|
|
205
|
-
catch (error) {
|
|
206
|
-
const errorDetails = extractErrorDetails(error);
|
|
207
|
-
logger.logError("Failed to fetch user from secure route", error);
|
|
208
|
-
const structuredContent = {
|
|
209
|
-
success: false,
|
|
210
|
-
error: errorDetails.userMessage,
|
|
211
|
-
errorType: errorDetails.errorType,
|
|
212
|
-
statusCode: errorDetails.statusCode,
|
|
213
|
-
status: errorDetails.errorType,
|
|
214
|
-
errorDetails: {
|
|
215
|
-
userMessage: errorDetails.userMessage,
|
|
216
|
-
technicalDetails: errorDetails.technicalDetails,
|
|
217
|
-
retryable: errorDetails.retryable,
|
|
218
|
-
},
|
|
219
|
-
};
|
|
220
|
-
logStructuredContentDebug("analyze_commit: returning error (getUserFromSecureRoute failed)", structuredContent);
|
|
221
|
-
// Return error from MCP server with backend error details
|
|
222
|
-
return {
|
|
223
|
-
content: [
|
|
224
|
-
{
|
|
225
|
-
type: "text",
|
|
226
|
-
text: `Error: ${errorDetails.userMessage}`,
|
|
227
|
-
},
|
|
228
|
-
],
|
|
229
|
-
structuredContent,
|
|
230
|
-
isError: true,
|
|
231
|
-
};
|
|
232
|
-
}
|
|
233
|
-
const userId = user.userid;
|
|
234
|
-
const username = user.username;
|
|
235
|
-
logger.logInfo("User information retrieved", {
|
|
236
|
-
user_id: userId,
|
|
237
|
-
username: username
|
|
238
|
-
});
|
|
239
|
-
const repoName = directory.split(/[/\\]/).pop() || "unknown-repo";
|
|
240
|
-
// Extract organization name from directory path
|
|
241
|
-
// Example: c:\Users\...\Documents\GitHub\CodeSherlock-MCP-Server -> CodeSherlock-MCP-Server
|
|
242
|
-
const pathParts = directory.split(/[/\\]/);
|
|
243
|
-
const githubIndex = pathParts.findIndex(part => part.toLowerCase() === 'github');
|
|
244
|
-
const organizationName = githubIndex >= 0 && pathParts[githubIndex + 1]
|
|
245
|
-
? pathParts[githubIndex + 1]
|
|
246
|
-
: undefined; // Will be undefined if extraction fails
|
|
247
|
-
// Step 3: Submit commit review and wait for results
|
|
248
|
-
let result;
|
|
249
|
-
try {
|
|
250
|
-
result = await commitReviewService.submitAndWaitForResults({
|
|
251
|
-
factor: normalizedFactor,
|
|
252
|
-
user_id: userId,
|
|
253
|
-
repo_name: repoName,
|
|
254
|
-
commit_id: commitId,
|
|
255
|
-
username,
|
|
256
|
-
file_changes: fileChanges,
|
|
257
|
-
organization_name: organizationName, // Use extracted or agent-provided value
|
|
258
|
-
});
|
|
259
|
-
}
|
|
260
|
-
catch (error) {
|
|
261
|
-
const errorDetails = extractErrorDetails(error);
|
|
262
|
-
logger.logError("Error in commit review submission", error, {
|
|
263
|
-
user_id: userId,
|
|
264
|
-
commit_id: commitId,
|
|
265
|
-
factor: normalizedFactor,
|
|
266
|
-
});
|
|
267
|
-
const structuredContent = {
|
|
268
|
-
success: false,
|
|
269
|
-
error: errorDetails.userMessage,
|
|
270
|
-
errorType: errorDetails.errorType,
|
|
271
|
-
statusCode: errorDetails.statusCode,
|
|
272
|
-
errorDetails: {
|
|
273
|
-
userMessage: errorDetails.userMessage,
|
|
274
|
-
technicalDetails: errorDetails.technicalDetails,
|
|
275
|
-
retryable: errorDetails.retryable,
|
|
276
|
-
},
|
|
277
|
-
};
|
|
278
|
-
logStructuredContentDebug("analyze_commit: returning error (commitReviewService.submitAndWaitForResults failed)", structuredContent);
|
|
279
|
-
return {
|
|
280
|
-
content: [
|
|
281
|
-
{
|
|
282
|
-
type: "text",
|
|
283
|
-
text: `Error: ${errorDetails.userMessage}`,
|
|
284
|
-
},
|
|
285
|
-
],
|
|
286
|
-
structuredContent,
|
|
287
|
-
isError: true,
|
|
288
|
-
};
|
|
289
|
-
}
|
|
290
|
-
// Handle backend errors returned in result
|
|
291
|
-
if (!result.success) {
|
|
292
|
-
const errorDetails = extractErrorDetails(new Error(result.error || "Unknown error"));
|
|
293
|
-
logger.logError("Commit review failed", new Error(result.error || "Unknown error"), {
|
|
294
|
-
user_id: userId,
|
|
295
|
-
commit_id: commitId,
|
|
296
|
-
});
|
|
297
|
-
const structuredContent = {
|
|
298
|
-
success: false,
|
|
299
|
-
error: result.error || errorDetails.userMessage,
|
|
300
|
-
errorType: errorDetails.errorType,
|
|
301
|
-
statusCode: errorDetails.statusCode,
|
|
302
|
-
errorDetails: {
|
|
303
|
-
userMessage: errorDetails.userMessage,
|
|
304
|
-
technicalDetails: result.error || errorDetails.technicalDetails,
|
|
305
|
-
retryable: errorDetails.retryable,
|
|
306
|
-
},
|
|
307
|
-
};
|
|
308
|
-
logStructuredContentDebug("analyze_commit: returning error (result.success === false)", structuredContent);
|
|
309
|
-
return {
|
|
310
|
-
content: [
|
|
311
|
-
{
|
|
312
|
-
type: "text",
|
|
313
|
-
text: `Error: ${errorDetails.userMessage}`,
|
|
314
|
-
},
|
|
315
|
-
],
|
|
316
|
-
structuredContent,
|
|
317
|
-
isError: true,
|
|
318
|
-
};
|
|
319
|
-
}
|
|
320
|
-
const outputDir = path.join(process.cwd(), "debug_outputs");
|
|
321
|
-
// Convert analysis results to markdown format
|
|
322
|
-
logger.logInfo("Processing analysis results", {
|
|
323
|
-
success: String(result.success),
|
|
324
|
-
hasResults: String(!!result.results),
|
|
325
|
-
resultsLength: String(result.results?.length || 0)
|
|
326
|
-
});
|
|
327
|
-
let markdownAnalysis = "";
|
|
328
|
-
if (result.success && result.results && result.results.length > 0) {
|
|
329
|
-
markdownAnalysis = formatMultipleFileAnalysisToMarkdown(result.results);
|
|
330
|
-
// Ensure output directory exists
|
|
331
|
-
if (!fs.existsSync(outputDir)) {
|
|
332
|
-
fs.mkdirSync(outputDir, { recursive: true });
|
|
333
|
-
logger.logInfo("Created output directory", { path: outputDir });
|
|
334
|
-
}
|
|
335
|
-
else {
|
|
336
|
-
logger.logInfo("Output directory already exists", { path: outputDir });
|
|
337
|
-
}
|
|
338
|
-
// Save markdown to file
|
|
339
|
-
const markdownPath = path.join(outputDir, `analysis_result_${Date.now()}.md`);
|
|
340
|
-
fs.writeFileSync(markdownPath, markdownAnalysis, "utf-8");
|
|
341
|
-
logger.logInfo("Markdown analysis saved", { path: markdownPath });
|
|
342
|
-
}
|
|
343
|
-
else {
|
|
344
|
-
logger.logInfo("Skipping markdown conversion - no results to convert");
|
|
345
|
-
}
|
|
346
|
-
// Step 4: Return complete results to AI
|
|
347
|
-
logger.logEvent("tool_completed", {
|
|
348
|
-
toolName: "analyze_commit",
|
|
349
|
-
success: String(result.success),
|
|
350
|
-
analysisId: result.analysisId || "none",
|
|
351
|
-
factor,
|
|
352
|
-
});
|
|
353
|
-
const structuredContent = result;
|
|
354
|
-
logStructuredContentDebug("analyze_commit: returning success structuredContent", structuredContent);
|
|
355
|
-
return {
|
|
356
|
-
content: [
|
|
357
|
-
{
|
|
358
|
-
type: "text",
|
|
359
|
-
text: markdownAnalysis || JSON.stringify(result, null, 2),
|
|
360
|
-
},
|
|
361
|
-
],
|
|
362
|
-
structuredContent,
|
|
363
|
-
};
|
|
364
|
-
}
|
|
365
|
-
catch (error) {
|
|
366
|
-
const errorDetails = extractErrorDetails(error);
|
|
367
|
-
logger.logError("Unexpected error in analyze_commit handler", error, {
|
|
368
|
-
directory,
|
|
369
|
-
uncommitted: String(uncommitted),
|
|
370
|
-
factor,
|
|
371
|
-
});
|
|
372
|
-
const structuredContent = {
|
|
373
|
-
success: false,
|
|
374
|
-
error: errorDetails.userMessage,
|
|
375
|
-
errorType: errorDetails.errorType,
|
|
376
|
-
statusCode: errorDetails.statusCode || 500,
|
|
377
|
-
errorDetails: {
|
|
378
|
-
userMessage: errorDetails.userMessage,
|
|
379
|
-
technicalDetails: errorDetails.technicalDetails,
|
|
380
|
-
retryable: errorDetails.retryable,
|
|
381
|
-
},
|
|
382
|
-
};
|
|
383
|
-
logStructuredContentDebug("analyze_commit: returning error (top-level catch)", structuredContent);
|
|
384
|
-
return {
|
|
385
|
-
content: [
|
|
386
|
-
{
|
|
387
|
-
type: "text",
|
|
388
|
-
text: `Error analyzing commit: ${errorDetails.userMessage}`,
|
|
389
|
-
},
|
|
390
|
-
],
|
|
391
|
-
structuredContent,
|
|
392
|
-
isError: true,
|
|
393
|
-
};
|
|
394
|
-
}
|
|
395
|
-
};
|
|
396
|
-
};
|
|
397
|
-
//# sourceMappingURL=analyzeCommitHandler.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"analyzeCommitHandler.js","sourceRoot":"","sources":["../../src/handlers/analyzeCommitHandler.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,MAAM,EAAE,MAAM,+BAA+B,CAAC;AACvD,OAAO,EAAE,oCAAoC,EAAE,MAAM,+BAA+B,CAAC;AACrF,OAAO,EAAE,mBAAmB,EAAa,MAAM,4BAA4B,CAAC;AAC5E,OAAO,EAAE,MAAM,IAAI,CAAC;AACp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AC,CAAC;YAChD,MAAM,CAAC,QAAQ,CAAC,4CAA4C,EAAE,KAAc,EAAE;gBAC1E,SAAS;gBACT,WAAW,EAAE,MAAM,CAAC,WAAW,CAAC;gBAChC,MAAM;aACT,CAAC,CAAC;YAEH,MAAM,iBAAiB,GAAG;gBACtB,OAAO,EAAE,KAAK;gBACd,KAAK,EAAE,YAAY,CAAC,WAAW;gBAC/B,SAAS,EAAE,YAAY,CAAC,SAAS;gBACjC,UAAU,EAAE,YAAY,CAAC,UAAU,IAAI,GAAG;gBAC1C,YAAY,EAAE;oBACV,WAAW,EAAE,YAAY,CAAC,WAAW;oBACrC,gBAAgB,EAAE,YAAY,CAAC,gBAAgB;oBAC/C,SAAS,EAAE,YAAY,CAAC,SAAS;iBACpC;aACJ,CAAC;YACF,yBAAyB,CAAC,mDAAmD,EAAE,iBAAiB,CAAC,CAAC;YAClG,OAAO;gBACH,OAAO,EAAE;oBACL;wBACI,IAAI,EAAE,MAAe;wBACrB,IAAI,EAAE,2BAA2B,YAAY,CAAC,WAAW,EAAE;qBAC9D;iBACJ;gBACD,iBAAiB;gBACjB,OAAO,EAAE,IAAI;aAChB,CAAC;QACN,CAAC;IACL,CAAC,CAAC;AACN,CAAC,CAAC"}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
|
-
/**
|
|
3
|
-
* Register event handlers with the MCP server
|
|
4
|
-
* This is optional and can be used for handling server lifecycle events
|
|
5
|
-
*/
|
|
6
|
-
export declare function registerEventHandlers(server: McpServer): void;
|
|
7
|
-
//# sourceMappingURL=events.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../src/handlers/events.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAEpE;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,SAAS,QAWtD"}
|
package/build/handlers/events.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Register event handlers with the MCP server
|
|
3
|
-
* This is optional and can be used for handling server lifecycle events
|
|
4
|
-
*/
|
|
5
|
-
export function registerEventHandlers(server) {
|
|
6
|
-
// Example: You can add custom event handlers here
|
|
7
|
-
// For now, this is a placeholder for future event handling logic
|
|
8
|
-
// Example event handler (if needed in the future):
|
|
9
|
-
// server.onError((error) => {
|
|
10
|
-
// Server errors are logged via Application Insights only
|
|
11
|
-
// });
|
|
12
|
-
// Event handlers registered
|
|
13
|
-
// Logging is handled via Application Insights only
|
|
14
|
-
}
|
|
15
|
-
//# sourceMappingURL=events.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"events.js","sourceRoot":"","sources":["../../src/handlers/events.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,MAAM,UAAU,qBAAqB,CAAC,MAAiB;IACnD,kDAAkD;IAClD,iEAAiE;IAEjE,mDAAmD;IACnD,8BAA8B;IAC9B,yDAAyD;IACzD,MAAM;IAEN,4BAA4B;IAC5B,mDAAmD;AACvD,CAAC"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
|
-
/**
|
|
3
|
-
* Register all resources with the MCP server
|
|
4
|
-
*
|
|
5
|
-
* Note: Resources are optional. In this setup, we don't expose any resources
|
|
6
|
-
* because the AI doesn't need to read data directly - it only needs to call tools.
|
|
7
|
-
* Tools internally orchestrate Git operations and backend API calls.
|
|
8
|
-
*/
|
|
9
|
-
export declare function registerResources(server: McpServer): void;
|
|
10
|
-
//# sourceMappingURL=resources.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"resources.d.ts","sourceRoot":"","sources":["../../src/handlers/resources.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAEpE;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,SAAS,QAKlD"}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Register all resources with the MCP server
|
|
3
|
-
*
|
|
4
|
-
* Note: Resources are optional. In this setup, we don't expose any resources
|
|
5
|
-
* because the AI doesn't need to read data directly - it only needs to call tools.
|
|
6
|
-
* Tools internally orchestrate Git operations and backend API calls.
|
|
7
|
-
*/
|
|
8
|
-
export function registerResources(server) {
|
|
9
|
-
// No resources needed for this use case
|
|
10
|
-
// Tools handle all the orchestration internally
|
|
11
|
-
// Resources handler registered (no resources defined)
|
|
12
|
-
// Logging is handled via Application Insights only
|
|
13
|
-
}
|
|
14
|
-
//# sourceMappingURL=resources.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"resources.js","sourceRoot":"","sources":["../../src/handlers/resources.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,MAAM,UAAU,iBAAiB,CAAC,MAAiB;IAC/C,wCAAwC;IACxC,gDAAgD;IAChD,sDAAsD;IACtD,mDAAmD;AACvD,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../src/handlers/tools.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAQpE;;GAEG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,SAAS,QA4B9C"}
|
package/build/handlers/tools.js
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { GitService } from "../services/gitService.js";
|
|
2
|
-
import { BackendApiService } from "../services/backendApiService.js";
|
|
3
|
-
import { CommitReviewService } from "../services/commitReviewService.js";
|
|
4
|
-
import { AnalyzeCommitInputSchema, AnalyzeCommitOutputSchema } from "../schemas/toolSchemas.js";
|
|
5
|
-
import { createAnalyzeCommitHandler } from "./analyzeCommitHandler.js";
|
|
6
|
-
import { logger } from "../services/loggingService.js";
|
|
7
|
-
/**
|
|
8
|
-
* Register all tools with the MCP server
|
|
9
|
-
*/
|
|
10
|
-
export function registerTools(server) {
|
|
11
|
-
const gitService = new GitService();
|
|
12
|
-
// Validate required environment variables
|
|
13
|
-
const backendUrl = "https://api.dev.codesherlock.ai";
|
|
14
|
-
logger.logInfo("Backend URL: " + backendUrl);
|
|
15
|
-
logger.logInfo("MCP API Key: " + process.env.MCP_API_KEY);
|
|
16
|
-
const backendApiService = new BackendApiService(backendUrl, process.env.MCP_API_KEY);
|
|
17
|
-
const commitReviewService = new CommitReviewService(backendApiService);
|
|
18
|
-
/**
|
|
19
|
-
* Tool: Analyze Commit
|
|
20
|
-
* Complete flow: Get Git data → Send to backend → Return results
|
|
21
|
-
*/
|
|
22
|
-
server.registerTool("analyze_commit", {
|
|
23
|
-
title: "Analyze Commit",
|
|
24
|
-
description: "Analyze a Git commit or uncommitted changes by fetching diff and sending to backend for analysis",
|
|
25
|
-
inputSchema: AnalyzeCommitInputSchema,
|
|
26
|
-
outputSchema: AnalyzeCommitOutputSchema,
|
|
27
|
-
}, createAnalyzeCommitHandler(gitService, commitReviewService, backendApiService));
|
|
28
|
-
}
|
|
29
|
-
//# sourceMappingURL=tools.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tools.js","sourceRoot":"","sources":["../../src/handlers/tools.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AACrE,OAAO,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AACzE,OAAO,EAAE,wBAAwB,EAAE,yBAAyB,EAAE,MAAM,2BAA2B,CAAC;AAChG,OAAO,EAAE,0BAA0B,EAAE,MAAM,2BAA2B,CAAC;AACvE,OAAO,EAAE,MAAM,EAAE,MAAM,+BAA+B,CAAC;AAEvD;;GAEG;AACH,MAAM,UAAU,aAAa,CAAC,MAAiB;IAC3C,MAAM,UAAU,GAAG,IAAI,UAAU,EAAE,CAAC;IAEpC,0CAA0C;IAC1C,MAAM,UAAU,GAAG,iCAAiC,CAAC;IACrD,MAAM,CAAC,OAAO,CAAC,eAAe,GAAG,UAAU,CAAC,CAAC;IAC7C,MAAM,CAAC,OAAO,CAAC,eAAe,GAAG,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;IAE1D,MAAM,iBAAiB,GAAG,IAAI,iBAAiB,CAC3C,UAAiB,EACjB,OAAO,CAAC,GAAG,CAAC,WAAW,CAC1B,CAAC;IACF,MAAM,mBAAmB,GAAG,IAAI,mBAAmB,CAAC,iBAAiB,CAAC,CAAC;IAEvE;;;OAGG;IACH,MAAM,CAAC,YAAY,CACf,gBAAgB,EAChB;QACI,KAAK,EAAE,gBAAgB;QACvB,WAAW,EAAE,kGAAkG;QAC/G,WAAW,EAAE,wBAAwB;QACrC,YAAY,EAAE,yBAAyB;KAC1C,EACD,0BAA0B,CAAC,UAAU,EAAE,mBAAmB,EAAE,iBAAiB,CAAC,CACjF,CAAC;AACN,CAAC"}
|
package/build/index.d.ts
DELETED
package/build/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
|
package/build/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAC;AACtD,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAE,aAAa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rB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AACpB,CAAC,CAAC,CAAC"}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import * as z from "zod";
|
|
2
|
-
export declare const AnalyzeCommitInputSchema: {
|
|
3
|
-
uncommitted: z.ZodBoolean;
|
|
4
|
-
directory: z.ZodString;
|
|
5
|
-
factor: z.ZodEnum<["power_analysis", "owasp", "cwe"]>;
|
|
6
|
-
};
|
|
7
|
-
/**
|
|
8
|
-
* Comprehensive output schema that handles all error scenarios from the FastAPI backend:
|
|
9
|
-
* - HTTP errors (401, 404, 422, 500)
|
|
10
|
-
* - WebSocket errors with status_code and error_message
|
|
11
|
-
* - Validation errors (missing files.json, invalid JSON, invalid file structure, etc.)
|
|
12
|
-
* - Authentication errors
|
|
13
|
-
* - Usage limit errors
|
|
14
|
-
* - Git errors
|
|
15
|
-
* - Internal server errors
|
|
16
|
-
*
|
|
17
|
-
* IMPORTANT:
|
|
18
|
-
* We intentionally keep `errorType` as a free-form string instead of a strict enum.
|
|
19
|
-
* The backend may introduce new error type strings (for example, "no_analysis_error")
|
|
20
|
-
* and we **do not** want the MCP server to fail schema validation with an error like:
|
|
21
|
-
* "Structured content does not match the tool's output schema: data.errorType should be equal to one of the allowed values".
|
|
22
|
-
*
|
|
23
|
-
* By allowing any string here, we always pass through whatever the backend sends and let
|
|
24
|
-
* the client / UI decide how to display or group unknown error types, instead of hiding
|
|
25
|
-
* the real backend error behind a schema error.
|
|
26
|
-
*/
|
|
27
|
-
export declare const AnalyzeCommitOutputSchema: {
|
|
28
|
-
success: z.ZodBoolean;
|
|
29
|
-
analysisId: z.ZodOptional<z.ZodString>;
|
|
30
|
-
status: z.ZodOptional<z.ZodString>;
|
|
31
|
-
statusCode: z.ZodOptional<z.ZodNumber>;
|
|
32
|
-
errorType: z.ZodOptional<z.ZodString>;
|
|
33
|
-
results: z.ZodOptional<z.ZodAny>;
|
|
34
|
-
message: z.ZodOptional<z.ZodString>;
|
|
35
|
-
error: z.ZodOptional<z.ZodString>;
|
|
36
|
-
errorDetails: z.ZodOptional<z.ZodObject<{
|
|
37
|
-
userMessage: z.ZodOptional<z.ZodString>;
|
|
38
|
-
technicalDetails: z.ZodOptional<z.ZodString>;
|
|
39
|
-
retryable: z.ZodOptional<z.ZodBoolean>;
|
|
40
|
-
}, "strip", z.ZodTypeAny, {
|
|
41
|
-
userMessage?: string | undefined;
|
|
42
|
-
technicalDetails?: string | undefined;
|
|
43
|
-
retryable?: boolean | undefined;
|
|
44
|
-
}, {
|
|
45
|
-
userMessage?: string | undefined;
|
|
46
|
-
technicalDetails?: string | undefined;
|
|
47
|
-
retryable?: boolean | undefined;
|
|
48
|
-
}>>;
|
|
49
|
-
};
|
|
50
|
-
//# sourceMappingURL=toolSchemas.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"toolSchemas.d.ts","sourceRoot":"","sources":["../../src/schemas/toolSchemas.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC;AAEzB,eAAO,MAAM,wBAAwB;;;;CAIpC,CAAC;AAEF;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;;;;;;;;;;CAsBrC,CAAC"}
|