@codesherlock/codesherlock-beta-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 +36 -0
- package/build/handlers/analyzeCommitHandler.d.ts.map +1 -0
- package/build/handlers/analyzeCommitHandler.js +397 -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 +29 -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 +50 -0
- package/build/schemas/toolSchemas.d.ts.map +1 -0
- package/build/schemas/toolSchemas.js +48 -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 +265 -0
- package/build/services/backendApiService.js.map +1 -0
- package/build/services/commitReviewService.d.ts +71 -0
- package/build/services/commitReviewService.d.ts.map +1 -0
- package/build/services/commitReviewService.js +506 -0
- package/build/services/commitReviewService.js.map +1 -0
- package/build/services/gitService.d.ts +159 -0
- package/build/services/gitService.d.ts.map +1 -0
- package/build/services/gitService.js +778 -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/analysisFormatter.test.d.ts +2 -0
- package/build/tests/analysisFormatter.test.d.ts.map +1 -0
- package/build/tests/analysisFormatter.test.js +92 -0
- package/build/tests/analysisFormatter.test.js.map +1 -0
- package/build/tests/analyzeCommitHandler.test.d.ts +2 -0
- package/build/tests/analyzeCommitHandler.test.d.ts.map +1 -0
- package/build/tests/analyzeCommitHandler.test.js +111 -0
- package/build/tests/analyzeCommitHandler.test.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 +120 -0
- package/build/tests/commitReviewService.test.js.map +1 -0
- package/build/tests/errorExtractor.test.d.ts +2 -0
- package/build/tests/errorExtractor.test.d.ts.map +1 -0
- package/build/tests/errorExtractor.test.js +61 -0
- package/build/tests/errorExtractor.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 +153 -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/tests/tools.test.d.ts +2 -0
- package/build/tests/tools.test.d.ts.map +1 -0
- package/build/tests/tools.test.js +58 -0
- package/build/tests/tools.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 +55 -0
package/.env
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# Environment Configuration
|
|
2
|
+
|
|
3
|
+
# Backend API Configuration
|
|
4
|
+
BACKEND_API_URL=https://api.test.codesherlock.ai
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
# Application Insights Configuration
|
|
8
|
+
APPLICATIONINSIGHTS_CONNECTION_STRING="InstrumentationKey=7dfd6598-1e84-4225-aecc-eadb62b3fd31;IngestionEndpoint=https://eastus-8.in.applicationinsights.azure.com/;LiveEndpoint=https://eastus.livediagnostics.monitor.azure.com/;ApplicationId=35d6bba6-e221-4ee8-a2ed-9f367e1347e9"
|
|
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 alpha 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-alpha-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,36 @@
|
|
|
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
|
+
};
|
|
26
|
+
isError: boolean;
|
|
27
|
+
} | {
|
|
28
|
+
content: {
|
|
29
|
+
type: "text";
|
|
30
|
+
text: string;
|
|
31
|
+
}[];
|
|
32
|
+
structuredContent: import("../services/commitReviewService.js").CommitReviewResult;
|
|
33
|
+
isError?: undefined;
|
|
34
|
+
}>;
|
|
35
|
+
export {};
|
|
36
|
+
//# 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;AAuBF,eAAO,MAAM,0BAA0B,GACnC,YAAY,UAAU,EACtB,qBAAqB,mBAAmB,EACxC,mBAAmB,iBAAiB,MAEtB,oCAAoC,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;EAsYtE,CAAC"}
|
|
@@ -0,0 +1,397 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AASxB;;;;GAIG;AACH,SAAS,yBAAyB,CAAC,KAAa,EAAE,iBAA0B;IACxE,IAAI,CAAC;QACD,MAAM,OAAO,GAAG,iBAAwB,CAAC;QACzC,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE;YAClB,OAAO,EAAE,MAAM,CAAC,OAAO,EAAE,OAAO,CAAC;YACjC,SAAS,EAAE,OAAO,EAAE,SAAS,CAAC,C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AAU,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"}
|
|
@@ -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"}
|