@codesherlock/codesherlock-alpha-mcp-server 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.env +9 -0
- package/README.md +185 -0
- package/build/handlers/analyzeCommitHandler.d.ts +55 -0
- package/build/handlers/analyzeCommitHandler.d.ts.map +1 -0
- package/build/handlers/analyzeCommitHandler.js +345 -0
- package/build/handlers/analyzeCommitHandler.js.map +1 -0
- package/build/handlers/events.d.ts +7 -0
- package/build/handlers/events.d.ts.map +1 -0
- package/build/handlers/events.js +15 -0
- package/build/handlers/events.js.map +1 -0
- package/build/handlers/resources.d.ts +10 -0
- package/build/handlers/resources.d.ts.map +1 -0
- package/build/handlers/resources.js +14 -0
- package/build/handlers/resources.js.map +1 -0
- package/build/handlers/tools.d.ts +6 -0
- package/build/handlers/tools.d.ts.map +1 -0
- package/build/handlers/tools.js +24 -0
- package/build/handlers/tools.js.map +1 -0
- package/build/index.d.ts +3 -0
- package/build/index.d.ts.map +1 -0
- package/build/index.js +82 -0
- package/build/index.js.map +1 -0
- package/build/schemas/toolSchemas.d.ts +40 -0
- package/build/schemas/toolSchemas.d.ts.map +1 -0
- package/build/schemas/toolSchemas.js +42 -0
- package/build/schemas/toolSchemas.js.map +1 -0
- package/build/services/backendApiService.d.ts +81 -0
- package/build/services/backendApiService.d.ts.map +1 -0
- package/build/services/backendApiService.js +211 -0
- package/build/services/backendApiService.js.map +1 -0
- package/build/services/commitReviewService.d.ts +61 -0
- package/build/services/commitReviewService.d.ts.map +1 -0
- package/build/services/commitReviewService.js +306 -0
- package/build/services/commitReviewService.js.map +1 -0
- package/build/services/gitService.d.ts +120 -0
- package/build/services/gitService.d.ts.map +1 -0
- package/build/services/gitService.js +360 -0
- package/build/services/gitService.js.map +1 -0
- package/build/services/loggingService.d.ts +64 -0
- package/build/services/loggingService.d.ts.map +1 -0
- package/build/services/loggingService.js +185 -0
- package/build/services/loggingService.js.map +1 -0
- package/build/services/zipService.d.ts +9 -0
- package/build/services/zipService.d.ts.map +1 -0
- package/build/services/zipService.js +47 -0
- package/build/services/zipService.js.map +1 -0
- package/build/tests/backendApiService.test.d.ts +2 -0
- package/build/tests/backendApiService.test.d.ts.map +1 -0
- package/build/tests/backendApiService.test.js +109 -0
- package/build/tests/backendApiService.test.js.map +1 -0
- package/build/tests/commitReviewService.test.d.ts +2 -0
- package/build/tests/commitReviewService.test.d.ts.map +1 -0
- package/build/tests/commitReviewService.test.js +118 -0
- package/build/tests/commitReviewService.test.js.map +1 -0
- package/build/tests/loggingService.test.d.ts +2 -0
- package/build/tests/loggingService.test.d.ts.map +1 -0
- package/build/tests/loggingService.test.js +156 -0
- package/build/tests/loggingService.test.js.map +1 -0
- package/build/tests/setup.test.d.ts +2 -0
- package/build/tests/setup.test.d.ts.map +1 -0
- package/build/tests/setup.test.js +7 -0
- package/build/tests/setup.test.js.map +1 -0
- package/build/utils/analysisFormatter.d.ts +40 -0
- package/build/utils/analysisFormatter.d.ts.map +1 -0
- package/build/utils/analysisFormatter.js +97 -0
- package/build/utils/analysisFormatter.js.map +1 -0
- package/build/utils/errorExtractor.d.ts +36 -0
- package/build/utils/errorExtractor.d.ts.map +1 -0
- package/build/utils/errorExtractor.js +178 -0
- package/build/utils/errorExtractor.js.map +1 -0
- package/package.json +53 -0
package/.env
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# Environment Configuration
|
|
2
|
+
|
|
3
|
+
# Backend API Configuration
|
|
4
|
+
BACKEND_API_URL=http://127.0.0.1:8000
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
# Application Insights Configuration
|
|
8
|
+
APPLICATIONINSIGHTS_CONNECTION_STRING="InstrumentationKey=9a687b23-0384-4345-abaa-4e7065b0d103;IngestionEndpoint=https://eastus-8.in.applicationinsights.azure.com/;LiveEndpoint=https://eastus.livediagnostics.monitor.azure.com/;ApplicationId=9e40bff2-07af-4326-be55-f5dc98e9e9c3"
|
|
9
|
+
|
package/README.md
ADDED
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
# CodeSherlock MCP Server - Setup & Usage Guide
|
|
2
|
+
|
|
3
|
+
**Key Features:**
|
|
4
|
+
- Analyze uncommitted changes (staged and unstaged files)
|
|
5
|
+
- Analyze committed changes (from your latest commit)
|
|
6
|
+
- Perform security analysis using OWASP Top 10 and CWE frameworks
|
|
7
|
+
- Integration with AI assistants like Claude Desktop, Cline, and other MCP-compatible tools
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## Prerequisites
|
|
12
|
+
|
|
13
|
+
Before you begin, ensure you have:
|
|
14
|
+
- Node.js (version [INSERT VERSION HERE]) and npm installed on your system
|
|
15
|
+
- A Git repository with code you want to analyze
|
|
16
|
+
- An AI coding assistant that supports MCP (e.g., Claude Desktop, Cline, or similar)
|
|
17
|
+
|
|
18
|
+
The CodeSherlock MCP Server is available on the npm registry and can be used directly with `npx`.
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
## Step 1: Get Your API Key
|
|
23
|
+
|
|
24
|
+
CodeSherlock requires an API key to analyze your code. This API Key is used to authenticate your requests to the CodeSherlock API.
|
|
25
|
+
|
|
26
|
+
### Obtaining Your API Key
|
|
27
|
+
|
|
28
|
+
1. Visit the CodeSherlock API Key page: **[https://codesherlock.ai/mcp-api-key](https://codesherlock.ai/mcp-api-key)**
|
|
29
|
+
2. Sign in or create an account if you haven't already
|
|
30
|
+
3. Generate a new API key
|
|
31
|
+
4. **Copy and store your API key securely** - you'll need to provide it when prompted
|
|
32
|
+
|
|
33
|
+
### Important Security Notes
|
|
34
|
+
|
|
35
|
+
- **Never share your API key** with others
|
|
36
|
+
- **Never commit your API key** to version control
|
|
37
|
+
- Store it in a secure location (password manager recommended)
|
|
38
|
+
- If your key is compromised, regenerate it immediately from the CodeSherlock dashboard
|
|
39
|
+
|
|
40
|
+
---
|
|
41
|
+
|
|
42
|
+
## Step 2: Configure Your AI Assistant
|
|
43
|
+
|
|
44
|
+
You need to add the CodeSherlock MCP Server configuration to your AI assistant's settings. Below given are the documentation links for popular AI assistants to setup MCP server:
|
|
45
|
+
|
|
46
|
+
- [Cluade Code](https://code.claude.com/docs/en/mcp#option-3%3A-add-a-local-stdio-server)
|
|
47
|
+
- [Cursor](https://cursor.com/docs/context/mcp#using-mcpjson)
|
|
48
|
+
- [VS Code / GitHub Copilot](https://code.visualstudio.com/docs/copilot/customization/mcp-servers)
|
|
49
|
+
|
|
50
|
+
<br/>
|
|
51
|
+
|
|
52
|
+
The general pattern is to specify:
|
|
53
|
+
- **Command**: `npx`
|
|
54
|
+
- **Args**: `[-y, codesherlock-mcp-server]`
|
|
55
|
+
- **Server Name**: `codesherlock`
|
|
56
|
+
|
|
57
|
+
#### MCP Configuration JSON:
|
|
58
|
+
|
|
59
|
+
```json
|
|
60
|
+
{
|
|
61
|
+
"mcpServers": {
|
|
62
|
+
"codesherlock": {
|
|
63
|
+
"name": "CodeSherlock MCP Server",
|
|
64
|
+
"description": "CodeSherlock delivers deep code analysis and exposes MCP tools for commit analysis and uncommit analysis.",
|
|
65
|
+
"command": "npx",
|
|
66
|
+
"args": ["-y", "@codesherlock/codesherlock-mcp-server"],
|
|
67
|
+
"env": {
|
|
68
|
+
"CODESHERLOCK_API_KEY": "your-api-key-here"
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
*After adding the configuration, restart your AI assistant to load the MCP server.*
|
|
76
|
+
|
|
77
|
+
---
|
|
78
|
+
|
|
79
|
+
## Step 3: Using CodeSherlock with Your AI Assistant
|
|
80
|
+
|
|
81
|
+
Once configured, you can start using CodeSherlock by prompting your AI assistant. The assistant will automatically invoke the MCP server tools to perform code analysis.
|
|
82
|
+
|
|
83
|
+
### Analysis Types
|
|
84
|
+
|
|
85
|
+
CodeSherlock supports three analysis factors:
|
|
86
|
+
|
|
87
|
+
| Factor | Description |
|
|
88
|
+
|--------|-------------|
|
|
89
|
+
| **power analysis** | A A full-spectrum scan that covers the most essential and critical issues |
|
|
90
|
+
| **owasp** | Security analysis based on OWASP Top 10 vulnerabilities |
|
|
91
|
+
| **cwe** | Analyzes code against Common Weakness Enumeration (CWE) framework |
|
|
92
|
+
|
|
93
|
+
---
|
|
94
|
+
|
|
95
|
+
## Example Prompts
|
|
96
|
+
|
|
97
|
+
Here are practical examples of how to prompt your AI assistant to perform code analysis:
|
|
98
|
+
|
|
99
|
+
```
|
|
100
|
+
"Review my uncommitted changes using CodeSherlock"
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
```
|
|
104
|
+
"Use CodeSherlock to check my uncommitted code for CWE vulnerabilities"
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
```
|
|
108
|
+
"Analyze my latest commit for OWASP vulnerabilities using CodeSherlock"
|
|
109
|
+
```
|
|
110
|
+
```
|
|
111
|
+
"Check the last commit in my current repo for CWE issues with CodeSherlock"
|
|
112
|
+
```
|
|
113
|
+
---
|
|
114
|
+
|
|
115
|
+
## Understanding the Results
|
|
116
|
+
|
|
117
|
+
### When Analysis Completes
|
|
118
|
+
|
|
119
|
+
The AI assistant will present the analysis results in a readable format, typically including:
|
|
120
|
+
|
|
121
|
+
- **Number of issues found**
|
|
122
|
+
- **Severity levels** (Critical, High, Medium, Low)
|
|
123
|
+
- **Issue categories**
|
|
124
|
+
- **Affected files and line numbers**
|
|
125
|
+
- **Descriptions and recommendations** for each issue
|
|
126
|
+
|
|
127
|
+
---
|
|
128
|
+
|
|
129
|
+
## Troubleshooting
|
|
130
|
+
|
|
131
|
+
### Common Issues
|
|
132
|
+
|
|
133
|
+
#### "Server not found" or "MCP server failed to start"
|
|
134
|
+
**Solution:**
|
|
135
|
+
- Verify the configuration file path is correct
|
|
136
|
+
- Check that Node.js and npm are properly installed
|
|
137
|
+
|
|
138
|
+
#### "Authentication failed" or "Invalid API key"
|
|
139
|
+
**Solution:**
|
|
140
|
+
- Verify your API key is correctly added to the configuration
|
|
141
|
+
- Check for any extra spaces or characters in the API key
|
|
142
|
+
- Regenerate your API key from the CodeSherlock dashboard
|
|
143
|
+
- Ensure you've restarted your AI assistant after adding the key
|
|
144
|
+
|
|
145
|
+
#### "Not a Git repository"
|
|
146
|
+
**Solution:**
|
|
147
|
+
- Ensure you're analyzing a directory that contains a `.git` folder
|
|
148
|
+
- Initialize a Git repository if needed: `git init`
|
|
149
|
+
|
|
150
|
+
#### "No changes to analyze"
|
|
151
|
+
**Solution:**
|
|
152
|
+
- For uncommitted analysis: Make sure you have modified files
|
|
153
|
+
- For commit analysis: Verify the commit exists using `git log`
|
|
154
|
+
- Check that you're in the correct Git repository
|
|
155
|
+
|
|
156
|
+
#### Analysis takes too long or times out
|
|
157
|
+
**Solution:**
|
|
158
|
+
- Start with analyzing specific files or smaller changesets
|
|
159
|
+
- Check your internet connection
|
|
160
|
+
- Break large changes into smaller commits for analysis
|
|
161
|
+
|
|
162
|
+
---
|
|
163
|
+
|
|
164
|
+
## Best Practices
|
|
165
|
+
|
|
166
|
+
### 1. Integrate into Your Workflow
|
|
167
|
+
- **Before committing**: Analyze uncommitted changes to catch issues early
|
|
168
|
+
- **After committing**: Review commits before pushing to remote
|
|
169
|
+
- **During code review**: Use analysis results to supplement manual reviews
|
|
170
|
+
|
|
171
|
+
### 2. Choose the Right Analysis Factor
|
|
172
|
+
- **Use OWASP** Best for web applications and APIs; focuses on the OWASP Top 10 and other common web security risks.
|
|
173
|
+
- **Use CWE** Ideal when you need deeper, classification-based coverage of software weaknesses across all domains.
|
|
174
|
+
- **Use Power Analysis** A broad, high-coverage analysis designed to catch the most essential and critical issues across any type of project (web, mobile, backend, etc.)
|
|
175
|
+
|
|
176
|
+
### 3. Act on Results
|
|
177
|
+
- Prioritize **Critical** and **High** severity issues immediately
|
|
178
|
+
- Create tickets for **Medium** severity issues
|
|
179
|
+
- Document **Low** severity issues for future refactoring
|
|
180
|
+
|
|
181
|
+
---
|
|
182
|
+
|
|
183
|
+
## Getting Help
|
|
184
|
+
|
|
185
|
+
If you face any issues, please send us a mail at [support@codesherlock.ai](mailto:support@codesherlock.ai). We will help you resolve the issue as soon as possible.
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { GitService } from "../services/gitService.js";
|
|
2
|
+
import { CommitReviewService } from "../services/commitReviewService.js";
|
|
3
|
+
import { BackendApiService } from "../services/backendApiService.js";
|
|
4
|
+
import { ErrorType } from "../utils/errorExtractor.js";
|
|
5
|
+
type AnalyzeCommitArgs = {
|
|
6
|
+
uncommitted: boolean;
|
|
7
|
+
directory: string;
|
|
8
|
+
factor: "power_analysis" | "owasp" | "cwe";
|
|
9
|
+
};
|
|
10
|
+
export declare const createAnalyzeCommitHandler: (gitService: GitService, commitReviewService: CommitReviewService, backendApiService: BackendApiService) => ({ uncommitted, directory, factor }: AnalyzeCommitArgs) => Promise<{
|
|
11
|
+
content: {
|
|
12
|
+
type: "text";
|
|
13
|
+
text: string;
|
|
14
|
+
}[];
|
|
15
|
+
structuredContent: {
|
|
16
|
+
success: boolean;
|
|
17
|
+
error: string;
|
|
18
|
+
errorType: ErrorType;
|
|
19
|
+
statusCode: number | undefined;
|
|
20
|
+
errorDetails: {
|
|
21
|
+
userMessage: string;
|
|
22
|
+
technicalDetails: string;
|
|
23
|
+
retryable: boolean;
|
|
24
|
+
};
|
|
25
|
+
status?: undefined;
|
|
26
|
+
};
|
|
27
|
+
isError: boolean;
|
|
28
|
+
} | {
|
|
29
|
+
content: {
|
|
30
|
+
type: "text";
|
|
31
|
+
text: string;
|
|
32
|
+
}[];
|
|
33
|
+
structuredContent: {
|
|
34
|
+
success: boolean;
|
|
35
|
+
error: string;
|
|
36
|
+
errorType: ErrorType;
|
|
37
|
+
statusCode: number | undefined;
|
|
38
|
+
status: ErrorType;
|
|
39
|
+
errorDetails: {
|
|
40
|
+
userMessage: string;
|
|
41
|
+
technicalDetails: string;
|
|
42
|
+
retryable: boolean;
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
isError: boolean;
|
|
46
|
+
} | {
|
|
47
|
+
content: {
|
|
48
|
+
type: "text";
|
|
49
|
+
text: string;
|
|
50
|
+
}[];
|
|
51
|
+
structuredContent: import("../services/commitReviewService.js").CommitReviewResult;
|
|
52
|
+
isError?: undefined;
|
|
53
|
+
}>;
|
|
54
|
+
export {};
|
|
55
|
+
//# sourceMappingURL=analyzeCommitHandler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"analyzeCommitHandler.d.ts","sourceRoot":"","sources":["../../src/handlers/analyzeCommitHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACvD,OAAO,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AACzE,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AAGrE,OAAO,EAAuB,SAAS,EAAE,MAAM,4BAA4B,CAAC;AAK5E,KAAK,iBAAiB,GAAG;IACrB,WAAW,EAAE,OAAO,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,gBAAgB,GAAG,OAAO,GAAG,KAAK,CAAC;CAC9C,CAAC;AAEF,eAAO,MAAM,0BAA0B,GACnC,YAAY,UAAU,EACtB,qBAAqB,mBAAmB,EACxC,mBAAmB,iBAAiB,MAEtB,oCAAoC,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAuWtE,CAAC"}
|
|
@@ -0,0 +1,345 @@
|
|
|
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
|
+
export const createAnalyzeCommitHandler = (gitService, commitReviewService, backendApiService) => {
|
|
7
|
+
return async ({ uncommitted, directory, factor }) => {
|
|
8
|
+
try {
|
|
9
|
+
// Normalize factor: map "power" to "power_analysis" for backward compatibility
|
|
10
|
+
const normalizedFactor = factor === "power" ? "power_analysis" : factor;
|
|
11
|
+
logger.logInfo("=== TOOL INVOKED: analyze_commit ===", {
|
|
12
|
+
uncommitted: String(uncommitted),
|
|
13
|
+
directory,
|
|
14
|
+
originalFactor: factor,
|
|
15
|
+
normalizedFactor,
|
|
16
|
+
});
|
|
17
|
+
// Validate directory exists
|
|
18
|
+
if (!fs.existsSync(directory)) {
|
|
19
|
+
const errorDetails = extractErrorDetails(new Error("Directory does not exist"));
|
|
20
|
+
return {
|
|
21
|
+
content: [
|
|
22
|
+
{
|
|
23
|
+
type: "text",
|
|
24
|
+
text: `Error: ${errorDetails.userMessage}`,
|
|
25
|
+
},
|
|
26
|
+
],
|
|
27
|
+
structuredContent: {
|
|
28
|
+
success: false,
|
|
29
|
+
error: errorDetails.userMessage,
|
|
30
|
+
errorType: errorDetails.errorType,
|
|
31
|
+
statusCode: 404,
|
|
32
|
+
errorDetails: {
|
|
33
|
+
userMessage: errorDetails.userMessage,
|
|
34
|
+
technicalDetails: `Directory not found: ${directory}`,
|
|
35
|
+
retryable: false,
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
isError: true,
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
// Step 1: Get file changes from Git
|
|
42
|
+
logger.logInfo("Fetching file changes", {
|
|
43
|
+
uncommitted: String(uncommitted),
|
|
44
|
+
directory,
|
|
45
|
+
factor
|
|
46
|
+
});
|
|
47
|
+
let fileChanges;
|
|
48
|
+
try {
|
|
49
|
+
fileChanges = await gitService.analyzeGitChanges(uncommitted, directory);
|
|
50
|
+
}
|
|
51
|
+
catch (error) {
|
|
52
|
+
const errorDetails = extractErrorDetails(error);
|
|
53
|
+
logger.logError("Failed to analyze git changes", error, { directory, uncommitted: String(uncommitted) });
|
|
54
|
+
return {
|
|
55
|
+
content: [
|
|
56
|
+
{
|
|
57
|
+
type: "text",
|
|
58
|
+
text: `Error: ${errorDetails.userMessage}`,
|
|
59
|
+
},
|
|
60
|
+
],
|
|
61
|
+
structuredContent: {
|
|
62
|
+
success: false,
|
|
63
|
+
error: errorDetails.userMessage,
|
|
64
|
+
errorType: errorDetails.errorType,
|
|
65
|
+
statusCode: errorDetails.statusCode,
|
|
66
|
+
errorDetails: {
|
|
67
|
+
userMessage: errorDetails.userMessage,
|
|
68
|
+
technicalDetails: errorDetails.technicalDetails,
|
|
69
|
+
retryable: errorDetails.retryable,
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
isError: true,
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
// Validate that we have file changes
|
|
76
|
+
if (!fileChanges || fileChanges.length === 0) {
|
|
77
|
+
const errorDetails = extractErrorDetails(new Error("No file changes found in the commit"));
|
|
78
|
+
return {
|
|
79
|
+
content: [
|
|
80
|
+
{
|
|
81
|
+
type: "text",
|
|
82
|
+
text: `Error: ${errorDetails.userMessage}`,
|
|
83
|
+
},
|
|
84
|
+
],
|
|
85
|
+
structuredContent: {
|
|
86
|
+
success: false,
|
|
87
|
+
error: errorDetails.userMessage,
|
|
88
|
+
errorType: "validation_error",
|
|
89
|
+
statusCode: 422,
|
|
90
|
+
errorDetails: {
|
|
91
|
+
userMessage: "No file changes found. Please ensure you have committed changes or uncommitted changes to analyze.",
|
|
92
|
+
technicalDetails: "Git analysis returned empty file changes array",
|
|
93
|
+
retryable: false,
|
|
94
|
+
},
|
|
95
|
+
},
|
|
96
|
+
isError: true,
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
// Validate file changes structure before sending to backend
|
|
100
|
+
// Each file change should have required fields: filename, status, new_content
|
|
101
|
+
const invalidFiles = [];
|
|
102
|
+
for (let i = 0; i < fileChanges.length; i++) {
|
|
103
|
+
const file = fileChanges[i];
|
|
104
|
+
if (!file || typeof file !== "object") {
|
|
105
|
+
invalidFiles.push(`File at index ${i} is not a valid object`);
|
|
106
|
+
continue;
|
|
107
|
+
}
|
|
108
|
+
if (!file.filename || typeof file.filename !== "string") {
|
|
109
|
+
invalidFiles.push(`File at index ${i} is missing or has invalid 'filename' field`);
|
|
110
|
+
}
|
|
111
|
+
if (!file.status || typeof file.status !== "string") {
|
|
112
|
+
invalidFiles.push(`File at index ${i} is missing or has invalid 'status' field`);
|
|
113
|
+
}
|
|
114
|
+
if (file.new_content === undefined) {
|
|
115
|
+
invalidFiles.push(`File at index ${i} is missing 'new_content' field`);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
if (invalidFiles.length > 0) {
|
|
119
|
+
const errorMessage = `Invalid file changes structure: ${invalidFiles.join("; ")}`;
|
|
120
|
+
const errorDetails = extractErrorDetails(new Error(errorMessage));
|
|
121
|
+
logger.logError("Invalid file changes structure", new Error(errorMessage), {
|
|
122
|
+
invalidFilesCount: String(invalidFiles.length),
|
|
123
|
+
});
|
|
124
|
+
return {
|
|
125
|
+
content: [
|
|
126
|
+
{
|
|
127
|
+
type: "text",
|
|
128
|
+
text: `Error: ${errorDetails.userMessage}`,
|
|
129
|
+
},
|
|
130
|
+
],
|
|
131
|
+
structuredContent: {
|
|
132
|
+
success: false,
|
|
133
|
+
error: errorDetails.userMessage,
|
|
134
|
+
errorType: "validation_error",
|
|
135
|
+
statusCode: 422,
|
|
136
|
+
errorDetails: {
|
|
137
|
+
userMessage: "Invalid file changes structure. Each file must have 'filename', 'status', and 'new_content' fields.",
|
|
138
|
+
technicalDetails: errorMessage,
|
|
139
|
+
retryable: false,
|
|
140
|
+
},
|
|
141
|
+
},
|
|
142
|
+
isError: true,
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
// Fetch commit identifier directly from Git (avoid relying on agent input)
|
|
146
|
+
let commitId;
|
|
147
|
+
try {
|
|
148
|
+
commitId = await gitService.getCurrentCommitHash(directory);
|
|
149
|
+
}
|
|
150
|
+
catch (error) {
|
|
151
|
+
const errorDetails = extractErrorDetails(error);
|
|
152
|
+
logger.logError("Failed to get commit hash", error, { directory });
|
|
153
|
+
// Use fallback commit ID
|
|
154
|
+
commitId = "UNCOMMITTED";
|
|
155
|
+
logger.logWarning("Using fallback commit ID", { commitId });
|
|
156
|
+
}
|
|
157
|
+
// Step 2: Get user info dynamically from secure_route endpoint
|
|
158
|
+
logger.logInfo("Fetching user information from secure route");
|
|
159
|
+
let user;
|
|
160
|
+
try {
|
|
161
|
+
user = await backendApiService.getUserFromSecureRoute();
|
|
162
|
+
}
|
|
163
|
+
catch (error) {
|
|
164
|
+
const errorDetails = extractErrorDetails(error);
|
|
165
|
+
logger.logError("Failed to fetch user from secure route", error);
|
|
166
|
+
// Return error from MCP server with backend error details
|
|
167
|
+
return {
|
|
168
|
+
content: [
|
|
169
|
+
{
|
|
170
|
+
type: "text",
|
|
171
|
+
text: `Error: ${errorDetails.userMessage}`,
|
|
172
|
+
},
|
|
173
|
+
],
|
|
174
|
+
structuredContent: {
|
|
175
|
+
success: false,
|
|
176
|
+
error: errorDetails.userMessage,
|
|
177
|
+
errorType: errorDetails.errorType,
|
|
178
|
+
statusCode: errorDetails.statusCode,
|
|
179
|
+
status: errorDetails.errorType,
|
|
180
|
+
errorDetails: {
|
|
181
|
+
userMessage: errorDetails.userMessage,
|
|
182
|
+
technicalDetails: errorDetails.technicalDetails,
|
|
183
|
+
retryable: errorDetails.retryable,
|
|
184
|
+
},
|
|
185
|
+
},
|
|
186
|
+
isError: true,
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
const userId = user.userid;
|
|
190
|
+
const username = user.username;
|
|
191
|
+
logger.logInfo("User information retrieved", {
|
|
192
|
+
user_id: userId,
|
|
193
|
+
username: username
|
|
194
|
+
});
|
|
195
|
+
const repoName = directory.split(/[/\\]/).pop() || "unknown-repo";
|
|
196
|
+
// Extract organization name from directory path
|
|
197
|
+
// Example: c:\Users\...\Documents\GitHub\CodeSherlock-MCP-Server -> CodeSherlock-MCP-Server
|
|
198
|
+
const pathParts = directory.split(/[/\\]/);
|
|
199
|
+
const githubIndex = pathParts.findIndex(part => part.toLowerCase() === 'github');
|
|
200
|
+
const organizationName = githubIndex >= 0 && pathParts[githubIndex + 1]
|
|
201
|
+
? pathParts[githubIndex + 1]
|
|
202
|
+
: undefined; // Will be undefined if extraction fails
|
|
203
|
+
// Step 3: Submit commit review and wait for results
|
|
204
|
+
let result;
|
|
205
|
+
try {
|
|
206
|
+
result = await commitReviewService.submitAndWaitForResults({
|
|
207
|
+
factor: normalizedFactor,
|
|
208
|
+
user_id: userId,
|
|
209
|
+
repo_name: repoName,
|
|
210
|
+
commit_id: commitId,
|
|
211
|
+
username,
|
|
212
|
+
file_changes: fileChanges,
|
|
213
|
+
organization_name: organizationName, // Use extracted or agent-provided value
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
catch (error) {
|
|
217
|
+
const errorDetails = extractErrorDetails(error);
|
|
218
|
+
logger.logError("Error in commit review submission", error, {
|
|
219
|
+
user_id: userId,
|
|
220
|
+
commit_id: commitId,
|
|
221
|
+
factor: normalizedFactor,
|
|
222
|
+
});
|
|
223
|
+
return {
|
|
224
|
+
content: [
|
|
225
|
+
{
|
|
226
|
+
type: "text",
|
|
227
|
+
text: `Error: ${errorDetails.userMessage}`,
|
|
228
|
+
},
|
|
229
|
+
],
|
|
230
|
+
structuredContent: {
|
|
231
|
+
success: false,
|
|
232
|
+
error: errorDetails.userMessage,
|
|
233
|
+
errorType: errorDetails.errorType,
|
|
234
|
+
statusCode: errorDetails.statusCode,
|
|
235
|
+
errorDetails: {
|
|
236
|
+
userMessage: errorDetails.userMessage,
|
|
237
|
+
technicalDetails: errorDetails.technicalDetails,
|
|
238
|
+
retryable: errorDetails.retryable,
|
|
239
|
+
},
|
|
240
|
+
},
|
|
241
|
+
isError: true,
|
|
242
|
+
};
|
|
243
|
+
}
|
|
244
|
+
// Handle backend errors returned in result
|
|
245
|
+
if (!result.success) {
|
|
246
|
+
const errorDetails = extractErrorDetails(new Error(result.error || "Unknown error"));
|
|
247
|
+
logger.logError("Commit review failed", new Error(result.error || "Unknown error"), {
|
|
248
|
+
user_id: userId,
|
|
249
|
+
commit_id: commitId,
|
|
250
|
+
});
|
|
251
|
+
return {
|
|
252
|
+
content: [
|
|
253
|
+
{
|
|
254
|
+
type: "text",
|
|
255
|
+
text: `Error: ${errorDetails.userMessage}`,
|
|
256
|
+
},
|
|
257
|
+
],
|
|
258
|
+
structuredContent: {
|
|
259
|
+
success: false,
|
|
260
|
+
error: result.error || errorDetails.userMessage,
|
|
261
|
+
errorType: errorDetails.errorType,
|
|
262
|
+
statusCode: errorDetails.statusCode,
|
|
263
|
+
errorDetails: {
|
|
264
|
+
userMessage: errorDetails.userMessage,
|
|
265
|
+
technicalDetails: result.error || errorDetails.technicalDetails,
|
|
266
|
+
retryable: errorDetails.retryable,
|
|
267
|
+
},
|
|
268
|
+
},
|
|
269
|
+
isError: true,
|
|
270
|
+
};
|
|
271
|
+
}
|
|
272
|
+
const outputDir = path.join(process.cwd(), "debug_outputs");
|
|
273
|
+
// Convert analysis results to markdown format
|
|
274
|
+
logger.logInfo("Processing analysis results", {
|
|
275
|
+
success: String(result.success),
|
|
276
|
+
hasResults: String(!!result.results),
|
|
277
|
+
resultsLength: String(result.results?.length || 0)
|
|
278
|
+
});
|
|
279
|
+
let markdownAnalysis = "";
|
|
280
|
+
if (result.success && result.results && result.results.length > 0) {
|
|
281
|
+
markdownAnalysis = formatMultipleFileAnalysisToMarkdown(result.results);
|
|
282
|
+
// Ensure output directory exists
|
|
283
|
+
if (!fs.existsSync(outputDir)) {
|
|
284
|
+
fs.mkdirSync(outputDir, { recursive: true });
|
|
285
|
+
logger.logInfo("Created output directory", { path: outputDir });
|
|
286
|
+
}
|
|
287
|
+
else {
|
|
288
|
+
logger.logInfo("Output directory already exists", { path: outputDir });
|
|
289
|
+
}
|
|
290
|
+
// Save markdown to file
|
|
291
|
+
const markdownPath = path.join(outputDir, `analysis_result_${Date.now()}.md`);
|
|
292
|
+
fs.writeFileSync(markdownPath, markdownAnalysis, "utf-8");
|
|
293
|
+
logger.logInfo("Markdown analysis saved", { path: markdownPath });
|
|
294
|
+
}
|
|
295
|
+
else {
|
|
296
|
+
logger.logInfo("Skipping markdown conversion - no results to convert");
|
|
297
|
+
}
|
|
298
|
+
// Step 4: Return complete results to AI
|
|
299
|
+
logger.logEvent("tool_completed", {
|
|
300
|
+
toolName: "analyze_commit",
|
|
301
|
+
success: String(result.success),
|
|
302
|
+
analysisId: result.analysisId || "none",
|
|
303
|
+
factor,
|
|
304
|
+
});
|
|
305
|
+
return {
|
|
306
|
+
content: [
|
|
307
|
+
{
|
|
308
|
+
type: "text",
|
|
309
|
+
text: markdownAnalysis || JSON.stringify(result, null, 2),
|
|
310
|
+
},
|
|
311
|
+
],
|
|
312
|
+
structuredContent: result,
|
|
313
|
+
};
|
|
314
|
+
}
|
|
315
|
+
catch (error) {
|
|
316
|
+
const errorDetails = extractErrorDetails(error);
|
|
317
|
+
logger.logError("Unexpected error in analyze_commit handler", error, {
|
|
318
|
+
directory,
|
|
319
|
+
uncommitted: String(uncommitted),
|
|
320
|
+
factor,
|
|
321
|
+
});
|
|
322
|
+
return {
|
|
323
|
+
content: [
|
|
324
|
+
{
|
|
325
|
+
type: "text",
|
|
326
|
+
text: `Error analyzing commit: ${errorDetails.userMessage}`,
|
|
327
|
+
},
|
|
328
|
+
],
|
|
329
|
+
structuredContent: {
|
|
330
|
+
success: false,
|
|
331
|
+
error: errorDetails.userMessage,
|
|
332
|
+
errorType: errorDetails.errorType,
|
|
333
|
+
statusCode: errorDetails.statusCode || 500,
|
|
334
|
+
errorDetails: {
|
|
335
|
+
userMessage: errorDetails.userMessage,
|
|
336
|
+
technicalDetails: errorDetails.technicalDetails,
|
|
337
|
+
retryable: errorDetails.retryable,
|
|
338
|
+
},
|
|
339
|
+
},
|
|
340
|
+
isError: true,
|
|
341
|
+
};
|
|
342
|
+
}
|
|
343
|
+
};
|
|
344
|
+
};
|
|
345
|
+
//# sourceMappingURL=analyzeCommitHandler.js.map
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C,gBAAgB;wBAC/C,SAAS,EAAE,YAAY,CAAC,SAAS;qBACpC;iBACJ;gBACD,OAAO,EAAE,IAAI;aAChB,CAAC;QACN,CAAC;IACL,CAAC,CAAC;AACN,CAAC,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1,15 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1,10 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|