viewgate-mcp 1.0.4 → 1.0.6
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/dist/index.js +28 -22
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -20,9 +20,15 @@ import { CallToolRequestSchema, ListToolsRequestSchema, } from "@modelcontextpro
|
|
|
20
20
|
import fetch from "node-fetch";
|
|
21
21
|
import cors from "cors";
|
|
22
22
|
import dotenv from "dotenv";
|
|
23
|
-
|
|
23
|
+
import path from "path";
|
|
24
|
+
import { fileURLToPath } from "url";
|
|
25
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
26
|
+
const __dirname = path.dirname(__filename);
|
|
27
|
+
dotenv.config({ path: path.join(__dirname, "..", ".env") });
|
|
24
28
|
const port = process.env.PORT || 3000;
|
|
25
29
|
const BACKEND_URL = process.env.BACKEND_URL || "https://view-gate.vercel.app";
|
|
30
|
+
console.error(`[MCP Config] BACKEND_URL: ${BACKEND_URL}`);
|
|
31
|
+
console.error(`[MCP Config] API_KEY Prefix: ${process.env.API_KEY?.substring(0, 5)}...`);
|
|
26
32
|
// Store active sessions for SSE: sessionId -> { server, transport }
|
|
27
33
|
const sessions = new Map();
|
|
28
34
|
/**
|
|
@@ -42,7 +48,7 @@ function createMcpServer(apiKey) {
|
|
|
42
48
|
tools: [
|
|
43
49
|
{
|
|
44
50
|
name: "get_annotations",
|
|
45
|
-
description: "Retrieves all feedback annotations.
|
|
51
|
+
description: "Retrieves all feedback annotations. WORKFLOW: 1. Read these annotations, 2. Open the source files and apply SURGICAL fixes based on '_ia_fix_instruction'. 3. IMMEDIATELY call 'mark_annotation_ready' with the results for EACH ticket you fixed. Use 'outerHtml' and 'source' (file:line) to locate the exact code block without manual searching. IMPORTANT: All AI analysis and comments MUST be in the 'preferredLanguage' specified in the output.",
|
|
46
52
|
inputSchema: {
|
|
47
53
|
type: "object",
|
|
48
54
|
properties: {},
|
|
@@ -50,24 +56,23 @@ function createMcpServer(apiKey) {
|
|
|
50
56
|
},
|
|
51
57
|
{
|
|
52
58
|
name: "mark_annotation_ready",
|
|
53
|
-
description: "
|
|
59
|
+
description: "CRITICAL: Call this tool AFTER applying code fixes for annotations. It marks tickets as 'Ready for Review' in the ViewGate dashboard and stores your AI-generated change summary. Support batch processing of multiple tickets at once.",
|
|
54
60
|
inputSchema: {
|
|
55
61
|
type: "object",
|
|
56
62
|
properties: {
|
|
57
|
-
|
|
58
|
-
type: "
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
description: "Brief summary of what was changed in the code"
|
|
63
|
+
results: {
|
|
64
|
+
type: "array",
|
|
65
|
+
items: {
|
|
66
|
+
type: "object",
|
|
67
|
+
properties: {
|
|
68
|
+
id: { type: "string", description: "The ID of the annotation to mark as ready" },
|
|
69
|
+
appliedChanges: { type: "string", description: "Descriptive summary of what was changed in the code for this specific ticket" }
|
|
70
|
+
},
|
|
71
|
+
required: ["id", "appliedChanges"]
|
|
72
|
+
}
|
|
68
73
|
}
|
|
69
74
|
},
|
|
70
|
-
required: ["
|
|
75
|
+
required: ["results"]
|
|
71
76
|
},
|
|
72
77
|
},
|
|
73
78
|
{
|
|
@@ -116,7 +121,7 @@ function createMcpServer(apiKey) {
|
|
|
116
121
|
throw new Error(`Backend responded with ${response.status}`);
|
|
117
122
|
}
|
|
118
123
|
const data = (await response.json());
|
|
119
|
-
const rawAnnotations = Array.isArray(data) ? data : (data?.data || []);
|
|
124
|
+
const rawAnnotations = Array.isArray(data) ? data : (data?.data || data?.annotations || []);
|
|
120
125
|
if (!Array.isArray(rawAnnotations)) {
|
|
121
126
|
return {
|
|
122
127
|
content: [{ type: "text", text: "Error: Invalid format" }],
|
|
@@ -197,25 +202,26 @@ function createMcpServer(apiKey) {
|
|
|
197
202
|
}
|
|
198
203
|
case "mark_annotation_ready": {
|
|
199
204
|
try {
|
|
200
|
-
const
|
|
201
|
-
const response = await fetch(`${BACKEND_URL}/api/annotations
|
|
205
|
+
const args = request.params.arguments;
|
|
206
|
+
const response = await fetch(`${BACKEND_URL}/api/mcp/annotations/batch-ready`, {
|
|
202
207
|
method: 'PATCH',
|
|
203
208
|
headers: {
|
|
204
209
|
'Content-Type': 'application/json',
|
|
205
210
|
'x-api-key': apiKey
|
|
206
211
|
},
|
|
207
|
-
body: JSON.stringify({
|
|
212
|
+
body: JSON.stringify({ results: args.results })
|
|
208
213
|
});
|
|
209
214
|
if (!response.ok) {
|
|
210
|
-
throw new Error(`Backend responded with ${response.status} when updating
|
|
215
|
+
throw new Error(`Backend responded with ${response.status} when updating annotations`);
|
|
211
216
|
}
|
|
217
|
+
const result = await response.json();
|
|
212
218
|
return {
|
|
213
|
-
content: [{ type: "text", text: `Successfully
|
|
219
|
+
content: [{ type: "text", text: `Successfully processed batch update: ${JSON.stringify(result, null, 2)}` }],
|
|
214
220
|
};
|
|
215
221
|
}
|
|
216
222
|
catch (error) {
|
|
217
223
|
return {
|
|
218
|
-
content: [{ type: "text", text: `Error marking
|
|
224
|
+
content: [{ type: "text", text: `Error marking annotations ready: ${error.message}` }],
|
|
219
225
|
isError: true,
|
|
220
226
|
};
|
|
221
227
|
}
|