@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
|
@@ -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"}
|
|
@@ -0,0 +1,14 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1,29 @@
|
|
|
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 = process.env.BACKEND_API_URL;
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC;IAC/C,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
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
|
package/build/index.js
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
3
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
4
|
+
import { registerTools } from "./handlers/tools.js";
|
|
5
|
+
import { logger } from "./services/loggingService.js";
|
|
6
|
+
import dotenv from "dotenv";
|
|
7
|
+
import { fileURLToPath } from "url";
|
|
8
|
+
import { dirname, join, resolve } from "path";
|
|
9
|
+
// Resolve .env file path relative to project root
|
|
10
|
+
// This works both in development (src/) and production (build/)
|
|
11
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
12
|
+
const __dirname = dirname(__filename);
|
|
13
|
+
// Go up from src/ or build/ to project root
|
|
14
|
+
const projectRoot = resolve(__dirname, "..");
|
|
15
|
+
const envPath = join(projectRoot, ".env");
|
|
16
|
+
// Load environment variables with explicit path
|
|
17
|
+
dotenv.config({ path: envPath });
|
|
18
|
+
/**
|
|
19
|
+
* CodeSherlock MCP Server
|
|
20
|
+
* A TypeScript-based Model Context Protocol server with modular architecture
|
|
21
|
+
*/
|
|
22
|
+
const appInsightsConnectionString = process.env.APPLICATIONINSIGHTS_CONNECTION_STRING;
|
|
23
|
+
// Initialize Application Insights and setup console suppression
|
|
24
|
+
// This must complete before creating the server
|
|
25
|
+
async function initializeLogging() {
|
|
26
|
+
await logger.initialize(appInsightsConnectionString);
|
|
27
|
+
// Note: We don't suppress stdout/stderr streams as MCP SDK uses them for protocol communication
|
|
28
|
+
const noOp = () => { };
|
|
29
|
+
if (logger.isEnabled()) {
|
|
30
|
+
// Only suppress console if Application Insights is initializeds
|
|
31
|
+
console.log = noOp;
|
|
32
|
+
console.error = noOp;
|
|
33
|
+
console.warn = noOp;
|
|
34
|
+
console.info = noOp;
|
|
35
|
+
console.debug = noOp;
|
|
36
|
+
console.trace = noOp;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
// Wait for logging initialization to complete
|
|
40
|
+
await initializeLogging();
|
|
41
|
+
// Create MCP server instance
|
|
42
|
+
const server = new McpServer({
|
|
43
|
+
name: "codesherlock-beta-mcp-server",
|
|
44
|
+
version: "0.0.1",
|
|
45
|
+
});
|
|
46
|
+
logger.logInfo("MCP Server instance created", {
|
|
47
|
+
serverName: "codesherlock-beta-mcp-server",
|
|
48
|
+
version: "0.0.1",
|
|
49
|
+
});
|
|
50
|
+
// Register all handlers
|
|
51
|
+
registerTools(server);
|
|
52
|
+
// registerResources(server);
|
|
53
|
+
// registerEventHandlers(server);
|
|
54
|
+
logger.logInfo("All handlers registered successfully");
|
|
55
|
+
/**
|
|
56
|
+
* Start the server
|
|
57
|
+
*/
|
|
58
|
+
async function main() {
|
|
59
|
+
const transport = new StdioServerTransport();
|
|
60
|
+
await server.connect(transport);
|
|
61
|
+
logger.logInfo("Server started successfully", {
|
|
62
|
+
transport: "stdio",
|
|
63
|
+
timestamp: new Date().toISOString(),
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
// Graceful shutdown handler
|
|
67
|
+
process.on("SIGINT", async () => {
|
|
68
|
+
logger.logInfo("Shutting down server...");
|
|
69
|
+
await logger.flush();
|
|
70
|
+
process.exit(0);
|
|
71
|
+
});
|
|
72
|
+
process.on("SIGTERM", async () => {
|
|
73
|
+
logger.logInfo("Shutting down server...");
|
|
74
|
+
await logger.flush();
|
|
75
|
+
process.exit(0);
|
|
76
|
+
});
|
|
77
|
+
main().catch(async (error) => {
|
|
78
|
+
logger.logError("Fatal error in main()", error);
|
|
79
|
+
await logger.flush();
|
|
80
|
+
process.exit(1);
|
|
81
|
+
});
|
|
82
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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,EAAE,MAAM,KAAK,CAAC;AACpC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAE9C,kDAAkD;AAClD,gEAAgE;AAChE,MAAM,UA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zeCommitInputSchema: {
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import * as z from "zod";
|
|
2
|
+
export const AnalyzeCommitInputSchema = {
|
|
3
|
+
uncommitted: z.boolean().describe("value will be false for commit analysis and true for unstaged changes"),
|
|
4
|
+
directory: z.string().describe("Path to the Git repository root"),
|
|
5
|
+
factor: z.enum(["power_analysis", "owasp", "cwe"]).describe("Analysis factor: power_analysis, owasp, or 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 const AnalyzeCommitOutputSchema = {
|
|
28
|
+
success: z.boolean().describe("Whether the commit analysis was successful"),
|
|
29
|
+
analysisId: z.string().optional().describe("Analysis ID returned from the backend (if successful)"),
|
|
30
|
+
status: z.string().optional().describe("Status string (e.g., 'complete', 'pending', 'failed')"),
|
|
31
|
+
statusCode: z.number().optional().describe("HTTP status code for error scenarios. Common values: 401 (authentication), 404 (not found), 422 (validation), 500 (internal error)"),
|
|
32
|
+
errorType: z
|
|
33
|
+
.string()
|
|
34
|
+
.optional()
|
|
35
|
+
.describe("Categorized error type for better error handling and user experience. " +
|
|
36
|
+
"Common values include: authentication_error, validation_error, not_found_error, " +
|
|
37
|
+
"git_error, websocket_error, api_error, internal_error, usage_limit_error, repository_error. " +
|
|
38
|
+
"Additional values may be introduced by the backend over time."),
|
|
39
|
+
results: z.any().optional().describe("Analysis results array (present when success is true)"),
|
|
40
|
+
message: z.string().optional().describe("Success or informational message"),
|
|
41
|
+
error: z.string().optional().describe("Error message (present when success is false)"),
|
|
42
|
+
errorDetails: z.object({
|
|
43
|
+
userMessage: z.string().optional().describe("User-friendly error message that can be displayed to end users"),
|
|
44
|
+
technicalDetails: z.string().optional().describe("Technical error details for debugging purposes"),
|
|
45
|
+
retryable: z.boolean().optional().describe("Whether the error is retryable (true for transient errors like network issues, false for validation/authentication errors)"),
|
|
46
|
+
}).optional().describe("Detailed error information including user-friendly message and retry guidance"),
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MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,kCAAkC,CAAC;IAC3E,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,+CAA+C,CAAC;IACtF,YAAY,EAAE,CAAC,CAAC,MAAM,CAAC;QACnB,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,gEAAgE,CAAC;QAC7G,gBAAgB,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,gDAAgD,CAAC;QAClG,SAAS,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,4HAA4H,CAAC;KAC3K,CAAC,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,+EAA+E,CAAC;CAC1G,CAAC"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import WebSocket from "ws";
|
|
2
|
+
/**
|
|
3
|
+
* Backend API Service
|
|
4
|
+
* Handles HTTP API calls and WebSocket connections for commit review
|
|
5
|
+
*/
|
|
6
|
+
export declare class BackendApiService {
|
|
7
|
+
private baseUrl;
|
|
8
|
+
private wsBaseUrl;
|
|
9
|
+
private apiKey?;
|
|
10
|
+
constructor(baseUrl: string, apiKey?: string);
|
|
11
|
+
/**
|
|
12
|
+
* Submit commit review to backend
|
|
13
|
+
*/
|
|
14
|
+
submitCommitReview(params: CommitReviewParams): Promise<ApiResponse>;
|
|
15
|
+
/**
|
|
16
|
+
* WebSocket connection for real-time commit analysis
|
|
17
|
+
*/
|
|
18
|
+
connectWebSocket(userId: string, onMessage: (data: WebSocketMessage) => void, onError?: (error: Error) => void, onClose?: (code: number, reason: string) => void): Promise<WebSocket>;
|
|
19
|
+
sendDiff(diff: string, metadata?: DiffMetadata): Promise<ApiResponse>;
|
|
20
|
+
getAnalysisResults(analysisId: string): Promise<AnalysisResult>;
|
|
21
|
+
/**
|
|
22
|
+
* Get user information from secure route
|
|
23
|
+
* Uses API key authentication to fetch authenticated user details
|
|
24
|
+
* @returns User information including user_id and username
|
|
25
|
+
*/
|
|
26
|
+
getUserFromSecureRoute(): Promise<User>;
|
|
27
|
+
}
|
|
28
|
+
export interface CommitReviewParams {
|
|
29
|
+
factor: "power_analysis" | "owasp" | "cwe";
|
|
30
|
+
user_id: string;
|
|
31
|
+
repo_name: string;
|
|
32
|
+
username: string;
|
|
33
|
+
commit_id: string;
|
|
34
|
+
files_json: any;
|
|
35
|
+
organization_name?: string;
|
|
36
|
+
}
|
|
37
|
+
export interface WebSocketMessage {
|
|
38
|
+
status_code: number;
|
|
39
|
+
error_message?: string;
|
|
40
|
+
content?: {
|
|
41
|
+
analysis_type?: string;
|
|
42
|
+
analysis?: any;
|
|
43
|
+
language?: string;
|
|
44
|
+
file_name?: string;
|
|
45
|
+
is_complete?: boolean;
|
|
46
|
+
status?: string;
|
|
47
|
+
};
|
|
48
|
+
analysis_id?: number;
|
|
49
|
+
}
|
|
50
|
+
export interface DiffMetadata {
|
|
51
|
+
directory?: string;
|
|
52
|
+
factor?: "power_analysis" | "owasp" | "cwe";
|
|
53
|
+
commitHash?: string;
|
|
54
|
+
author?: string;
|
|
55
|
+
timestamp?: string;
|
|
56
|
+
uncommitted?: boolean;
|
|
57
|
+
repoName?: string;
|
|
58
|
+
branch?: string;
|
|
59
|
+
}
|
|
60
|
+
export interface ApiResponse {
|
|
61
|
+
success: boolean;
|
|
62
|
+
message?: string;
|
|
63
|
+
data?: any;
|
|
64
|
+
analysisId?: string;
|
|
65
|
+
}
|
|
66
|
+
export interface AnalysisResult {
|
|
67
|
+
id: string;
|
|
68
|
+
status: "pending" | "completed" | "failed";
|
|
69
|
+
results?: any;
|
|
70
|
+
error?: string;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* User interface returned from secure_route endpoint
|
|
74
|
+
*/
|
|
75
|
+
export interface User {
|
|
76
|
+
userid: string;
|
|
77
|
+
username: string;
|
|
78
|
+
email?: string;
|
|
79
|
+
[key: string]: any;
|
|
80
|
+
}
|
|
81
|
+
//# sourceMappingURL=backendApiService.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"backendApiService.d.ts","sourceRoot":"","sources":["../../src/services/backendApiService.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,IAAI,CAAC;AAK3B;;;GAGG;AACH,qBAAa,iBAAiB;IAC1B,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,MAAM,CAAC,CAAS;gBAEZ,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM;IAmB5C;;OAEG;IACG,kBAAkB,CAAC,MAAM,EAAE,kBAAkB,GAAG,OAAO,CAAC,WAAW,CAAC;IAqH1E;;OAEG;IACH,gBAAgB,CACZ,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,CAAC,IAAI,EAAE,gBAAgB,KAAK,IAAI,EAC3C,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,EAChC,OAAO,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,IAAI,GACjD,OAAO,CAAC,SAAS,CAAC;IA2Ef,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,YAAY,GAAG,OAAO,CAAC,WAAW,CAAC;IAOrE,kBAAkB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC;IAIrE;;;;OAIG;IACG,sBAAsB,IAAI,OAAO,CAAC,IAAI,CAAC;CAiDhD;AAMD,MAAM,WAAW,kBAAkB;IAC/B,MAAM,EAAE,gBAAgB,GAAG,OAAO,GAAG,KAAK,CAAC;IAC3C,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE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