viewgate-mcp 1.0.21 → 1.0.23
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 +36 -11
- package/package.json +1 -1
- package/dist/test_fix.js +0 -59
- package/dist/test_sse.js +0 -23
package/dist/index.js
CHANGED
|
@@ -52,13 +52,16 @@ function createMcpServer(apiKey, personalKey) {
|
|
|
52
52
|
inputSchema: {
|
|
53
53
|
type: "object",
|
|
54
54
|
properties: {
|
|
55
|
-
limit: { type: "number", description: "Maximum number of annotations to retrieve (default: 3)", default: 3 }
|
|
55
|
+
limit: { type: "number", description: "Maximum number of annotations to retrieve (default: 3)", default: 3 },
|
|
56
|
+
status: { type: "string", description: "Comma-separated list of statuses to fetch (e.g. 'pending,bug_fixing,in_progress'). Use 'all' to fetch from any state.", default: "pending,bug_fixing" },
|
|
57
|
+
search: { type: "string", description: "Search term to filter annotations by text in message or file paths." },
|
|
58
|
+
key: { type: "string", description: "Human-readable key (e.g. VG-B62B4E) to find a specific annotation ID." }
|
|
56
59
|
},
|
|
57
60
|
},
|
|
58
61
|
},
|
|
59
62
|
{
|
|
60
63
|
name: "mark_annotation_ready",
|
|
61
|
-
description: "CRITICAL: Call this tool AFTER applying code fixes for annotations. It marks tickets as 'Ready for Review'
|
|
64
|
+
description: "CRITICAL: Call this tool AFTER applying code fixes for annotations. It marks tickets as 'Ready for Review'. REQUIREMENT: Use the internal database ID (e.g. 675ba...), NOT the human key (VG-XXXX). If you only have the key, use 'get_annotations' with 'key' filter first. IMPORTANT: The 'appliedChanges' summary MUST be written in the 'preferredLanguage' specified by 'get_annotations'.",
|
|
62
65
|
inputSchema: {
|
|
63
66
|
type: "object",
|
|
64
67
|
properties: {
|
|
@@ -108,7 +111,7 @@ function createMcpServer(apiKey, personalKey) {
|
|
|
108
111
|
},
|
|
109
112
|
{
|
|
110
113
|
name: "sync_endpoints",
|
|
111
|
-
description: "
|
|
114
|
+
description: "Manually synchronizes backend endpoints. Call ONLY if the user explicitly asks to 'sync endpoints' or 'update routes'. DO NOT call this automatically during other workflows.",
|
|
112
115
|
inputSchema: {
|
|
113
116
|
type: "object",
|
|
114
117
|
properties: {
|
|
@@ -174,8 +177,20 @@ function createMcpServer(apiKey, personalKey) {
|
|
|
174
177
|
try {
|
|
175
178
|
const args = request.params.arguments;
|
|
176
179
|
const limit = args.limit || 3;
|
|
177
|
-
const statuses = 'pending,bug_fixing';
|
|
178
|
-
const
|
|
180
|
+
const statuses = args.status || 'pending,bug_fixing';
|
|
181
|
+
const search = args.search || '';
|
|
182
|
+
const key = args.key || '';
|
|
183
|
+
const url = new URL(`${BACKEND_URL}/api/mcp/annotations`);
|
|
184
|
+
if (statuses && statuses !== 'all')
|
|
185
|
+
url.searchParams.append('status', statuses);
|
|
186
|
+
if (limit)
|
|
187
|
+
url.searchParams.append('limit', limit.toString());
|
|
188
|
+
if (search)
|
|
189
|
+
url.searchParams.append('search', search);
|
|
190
|
+
if (key)
|
|
191
|
+
url.searchParams.append('key', key);
|
|
192
|
+
url.searchParams.append('lock', 'true');
|
|
193
|
+
const response = await fetch(url.toString(), {
|
|
179
194
|
headers: {
|
|
180
195
|
'x-api-key': apiKey,
|
|
181
196
|
...(personalKey ? { 'x-personal-key': personalKey } : {})
|
|
@@ -184,14 +199,24 @@ function createMcpServer(apiKey, personalKey) {
|
|
|
184
199
|
if (!response.ok) {
|
|
185
200
|
throw new Error(`Backend responded with ${response.status}`);
|
|
186
201
|
}
|
|
187
|
-
const
|
|
188
|
-
|
|
202
|
+
const rawData = (await response.json());
|
|
203
|
+
let rawAnnotations = Array.isArray(rawData) ? rawData : (rawData?.data || rawData?.annotations || []);
|
|
189
204
|
if (!Array.isArray(rawAnnotations)) {
|
|
190
205
|
return {
|
|
191
|
-
content: [{ type: "text", text: "Error: Invalid format" }],
|
|
206
|
+
content: [{ type: "text", text: "Error: Invalid format from backend" }],
|
|
192
207
|
isError: true
|
|
193
208
|
};
|
|
194
209
|
}
|
|
210
|
+
// Local filtering fallback for search and key (in case backend doesn't support them yet)
|
|
211
|
+
if (search) {
|
|
212
|
+
const lowSearch = search.toLowerCase();
|
|
213
|
+
rawAnnotations = rawAnnotations.filter((ann) => (ann.message && ann.message.toLowerCase().includes(lowSearch)) ||
|
|
214
|
+
(ann.reference?.source && ann.reference.source.toLowerCase().includes(lowSearch)) ||
|
|
215
|
+
(ann.key && ann.key.toLowerCase().includes(lowSearch)));
|
|
216
|
+
}
|
|
217
|
+
if (key) {
|
|
218
|
+
rawAnnotations = rawAnnotations.filter((ann) => ann.key === key || ann._id === key);
|
|
219
|
+
}
|
|
195
220
|
const priorityMap = {
|
|
196
221
|
'urgente': 4,
|
|
197
222
|
'urgent': 4,
|
|
@@ -253,13 +278,13 @@ The user has requested the following corrections:
|
|
|
253
278
|
${pendingCorrection.author ? `Requested by: ${pendingCorrection.author.name}` : ''}
|
|
254
279
|
PLEASE ENSURE THESE SPECIFIC ISSUES ARE ADDRESSED IN YOUR FIX.` : ''}
|
|
255
280
|
|
|
256
|
-
### 🔬 SURGICAL FIX PROTOCOL (Language: ${
|
|
281
|
+
### 🔬 SURGICAL FIX PROTOCOL (Language: ${rawData.preferredLanguage || 'en'})
|
|
257
282
|
1. **PRIMARY**: Search for \`data-vg-id="${ann.reference?.vgId}"\`.
|
|
258
283
|
2. **SECONDARY**: Check \`${file}\` L${line} (Fiber Source).
|
|
259
284
|
3. **TERTIARY**: Match Tag(\`${ann.reference?.tag}\`) + Role(\`${ann.reference?.fingerprint?.role}\`) + Text("${ann.reference?.text?.slice(0, 30)}").
|
|
260
285
|
4. **VALIDATE**: Confirm parent context matches \`${ann.reference?.parentContext?.slice(0, 50).replace(/`/g, "'")}...\`.
|
|
261
286
|
|
|
262
|
-
IMPORTANT: All your analysis and implementation comments MUST BE IN ${
|
|
287
|
+
IMPORTANT: All your analysis and implementation comments MUST BE IN ${rawData.preferredLanguage === 'es' ? 'SPANISH' : 'ENGLISH'}.
|
|
263
288
|
|
|
264
289
|
Confidence: [vgId: ${ann.reference?.confidence?.vgId || 0}, Fiber: ${ann.reference?.confidence?.fiber || 0}, Fingerprint: ${ann.reference?.confidence?.fingerprint || 0}]
|
|
265
290
|
Instruction: ${ann.message}${pendingCorrection ? `\nCorrection Needed: ${pendingCorrection.text}` : ''}`
|
|
@@ -270,7 +295,7 @@ Instruction: ${ann.message}${pendingCorrection ? `\nCorrection Needed: ${pending
|
|
|
270
295
|
{
|
|
271
296
|
type: "text",
|
|
272
297
|
text: JSON.stringify({
|
|
273
|
-
preferredLanguage:
|
|
298
|
+
preferredLanguage: rawData.preferredLanguage || 'en',
|
|
274
299
|
annotations: annotationsWithTips
|
|
275
300
|
}, null, 2),
|
|
276
301
|
},
|
package/package.json
CHANGED
package/dist/test_fix.js
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import fetch from "node-fetch";
|
|
2
|
-
async function test() {
|
|
3
|
-
console.log("1. Connecting to http://localhost:3333/sse...");
|
|
4
|
-
const response = await fetch("http://localhost:3333/sse?apiKey=2af5628c9442f10b93cfe6970897d4de26578d958ba43a4e3bcb684fe0f92668");
|
|
5
|
-
if (!response.ok) {
|
|
6
|
-
console.error("Failed to connect to SSE:", response.status, await response.text());
|
|
7
|
-
return;
|
|
8
|
-
}
|
|
9
|
-
console.log("SSE connected. Reading stream for sessionId...");
|
|
10
|
-
const body = response.body;
|
|
11
|
-
let sessionId = null;
|
|
12
|
-
body.on("data", async (chunk) => {
|
|
13
|
-
const text = chunk.toString();
|
|
14
|
-
console.log("SSE Data:", text);
|
|
15
|
-
// Example event:
|
|
16
|
-
// event: endpoint
|
|
17
|
-
// data: /message?sessionId=...
|
|
18
|
-
const match = text.match(/sessionId=([a-f0-9-]+)/);
|
|
19
|
-
if (match && !sessionId) {
|
|
20
|
-
sessionId = match[1];
|
|
21
|
-
console.log("FOUND SESSION ID:", sessionId);
|
|
22
|
-
// 2. Test POST to /message
|
|
23
|
-
console.log(`2. Testing POST to /message?sessionId=${sessionId}...`);
|
|
24
|
-
const postResponse = await fetch(`http://localhost:3333/message?sessionId=${sessionId}`, {
|
|
25
|
-
method: 'POST',
|
|
26
|
-
headers: {
|
|
27
|
-
'Content-Type': 'application/json'
|
|
28
|
-
},
|
|
29
|
-
body: JSON.stringify({
|
|
30
|
-
jsonrpc: "2.0",
|
|
31
|
-
id: 1,
|
|
32
|
-
method: "initialize",
|
|
33
|
-
params: {
|
|
34
|
-
clientInfo: { name: "test-client", version: "1.0.0" },
|
|
35
|
-
protocolVersion: "2024-11-05",
|
|
36
|
-
capabilities: {}
|
|
37
|
-
}
|
|
38
|
-
})
|
|
39
|
-
});
|
|
40
|
-
console.log("POST Response Status:", postResponse.status);
|
|
41
|
-
const responseText = await postResponse.text();
|
|
42
|
-
console.log("POST Response Body:", responseText);
|
|
43
|
-
if (postResponse.status === 200 || postResponse.status === 202) {
|
|
44
|
-
console.log("SUCCESS: Stream was readable and message was accepted.");
|
|
45
|
-
}
|
|
46
|
-
else {
|
|
47
|
-
console.error("FAILURE: Server returned error status.");
|
|
48
|
-
}
|
|
49
|
-
process.exit(0);
|
|
50
|
-
}
|
|
51
|
-
});
|
|
52
|
-
setTimeout(() => {
|
|
53
|
-
if (!sessionId) {
|
|
54
|
-
console.error("TIMEOUT: Did not receive sessionId from SSE.");
|
|
55
|
-
process.exit(1);
|
|
56
|
-
}
|
|
57
|
-
}, 10000);
|
|
58
|
-
}
|
|
59
|
-
test();
|
package/dist/test_sse.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import fetch from "node-fetch";
|
|
2
|
-
async function test() {
|
|
3
|
-
console.log("Connecting to http://localhost:3333/sse...");
|
|
4
|
-
const response = await fetch("http://localhost:3333/sse?apiKey=test-key");
|
|
5
|
-
if (!response.ok) {
|
|
6
|
-
console.error("Failed to connect:", response.status, await response.text());
|
|
7
|
-
return;
|
|
8
|
-
}
|
|
9
|
-
console.log("Headers:", response.headers.raw());
|
|
10
|
-
const body = response.body;
|
|
11
|
-
body.on("data", (chunk) => {
|
|
12
|
-
console.log("Chunk received:", chunk.toString());
|
|
13
|
-
if (chunk.toString().includes("event: endpoint")) {
|
|
14
|
-
console.log("FOUND ENDPOINT EVENT!");
|
|
15
|
-
}
|
|
16
|
-
});
|
|
17
|
-
body.on("end", () => console.log("Connection closed"));
|
|
18
|
-
setTimeout(() => {
|
|
19
|
-
console.log("Closing test...");
|
|
20
|
-
process.exit(0);
|
|
21
|
-
}, 5000);
|
|
22
|
-
}
|
|
23
|
-
test();
|