viewgate-mcp 1.0.22 → 1.0.24

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.
Files changed (2) hide show
  1. package/dist/index.js +38 -12
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -53,13 +53,15 @@ function createMcpServer(apiKey, personalKey) {
53
53
  type: "object",
54
54
  properties: {
55
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 (default: 'pending,bug_fixing')", default: "pending,bug_fixing" }
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." }
57
59
  },
58
60
  },
59
61
  },
60
62
  {
61
63
  name: "mark_annotation_ready",
62
- 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. IMPORTANT: The 'appliedChanges' summary MUST be written in the 'preferredLanguage' specified by 'get_annotations' output. DO NOT use English if the preferred language is Spanish.",
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'.",
63
65
  inputSchema: {
64
66
  type: "object",
65
67
  properties: {
@@ -109,7 +111,7 @@ function createMcpServer(apiKey, personalKey) {
109
111
  },
110
112
  {
111
113
  name: "sync_endpoints",
112
- description: "Synchronizes a batch of backend endpoints with the ViewGate server. High-performance batch processing for language-agnostic mapping (Express, Java, .NET, Python, etc.). IMPORTANT: The 'description' for each endpoint MUST be written in the project's preferred language (e.g., Spanish if preferredLanguage is 'es').",
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.",
113
115
  inputSchema: {
114
116
  type: "object",
115
117
  properties: {
@@ -176,7 +178,19 @@ function createMcpServer(apiKey, personalKey) {
176
178
  const args = request.params.arguments;
177
179
  const limit = args.limit || 3;
178
180
  const statuses = args.status || 'pending,bug_fixing';
179
- const response = await fetch(`${BACKEND_URL}/api/mcp/annotations?status=${statuses}&limit=${limit}&lock=true`, {
181
+ const search = args.search || '';
182
+ const key = args.key || '';
183
+ let fetchUrl = `${BACKEND_URL}/api/mcp/annotations?lock=true`;
184
+ if (statuses && statuses !== 'all')
185
+ fetchUrl += `&status=${statuses}`;
186
+ if (limit)
187
+ fetchUrl += `&limit=${limit}`;
188
+ if (search)
189
+ fetchUrl += `&search=${encodeURIComponent(search)}`;
190
+ if (key)
191
+ fetchUrl += `&key=${encodeURIComponent(key)}`;
192
+ console.error(`[MCP] Fetching annotations from: ${fetchUrl}`);
193
+ const response = await fetch(fetchUrl, {
180
194
  headers: {
181
195
  'x-api-key': apiKey,
182
196
  ...(personalKey ? { 'x-personal-key': personalKey } : {})
@@ -185,14 +199,24 @@ function createMcpServer(apiKey, personalKey) {
185
199
  if (!response.ok) {
186
200
  throw new Error(`Backend responded with ${response.status}`);
187
201
  }
188
- const data = (await response.json());
189
- const rawAnnotations = Array.isArray(data) ? data : (data?.data || data?.annotations || []);
202
+ const rawData = (await response.json());
203
+ let rawAnnotations = Array.isArray(rawData) ? rawData : (rawData?.data || rawData?.annotations || []);
190
204
  if (!Array.isArray(rawAnnotations)) {
191
205
  return {
192
- content: [{ type: "text", text: "Error: Invalid format" }],
206
+ content: [{ type: "text", text: "Error: Invalid format from backend" }],
193
207
  isError: true
194
208
  };
195
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
+ }
196
220
  const priorityMap = {
197
221
  'urgente': 4,
198
222
  'urgent': 4,
@@ -254,13 +278,13 @@ The user has requested the following corrections:
254
278
  ${pendingCorrection.author ? `Requested by: ${pendingCorrection.author.name}` : ''}
255
279
  PLEASE ENSURE THESE SPECIFIC ISSUES ARE ADDRESSED IN YOUR FIX.` : ''}
256
280
 
257
- ### 🔬 SURGICAL FIX PROTOCOL (Language: ${data.preferredLanguage || 'en'})
281
+ ### 🔬 SURGICAL FIX PROTOCOL (Language: ${rawData.preferredLanguage || 'en'})
258
282
  1. **PRIMARY**: Search for \`data-vg-id="${ann.reference?.vgId}"\`.
259
283
  2. **SECONDARY**: Check \`${file}\` L${line} (Fiber Source).
260
284
  3. **TERTIARY**: Match Tag(\`${ann.reference?.tag}\`) + Role(\`${ann.reference?.fingerprint?.role}\`) + Text("${ann.reference?.text?.slice(0, 30)}").
261
285
  4. **VALIDATE**: Confirm parent context matches \`${ann.reference?.parentContext?.slice(0, 50).replace(/`/g, "'")}...\`.
262
286
 
263
- IMPORTANT: All your analysis and implementation comments MUST BE IN ${data.preferredLanguage === 'es' ? 'SPANISH' : 'ENGLISH'}.
287
+ IMPORTANT: All your analysis and implementation comments MUST BE IN ${rawData.preferredLanguage === 'es' ? 'SPANISH' : 'ENGLISH'}.
264
288
 
265
289
  Confidence: [vgId: ${ann.reference?.confidence?.vgId || 0}, Fiber: ${ann.reference?.confidence?.fiber || 0}, Fingerprint: ${ann.reference?.confidence?.fingerprint || 0}]
266
290
  Instruction: ${ann.message}${pendingCorrection ? `\nCorrection Needed: ${pendingCorrection.text}` : ''}`
@@ -271,7 +295,7 @@ Instruction: ${ann.message}${pendingCorrection ? `\nCorrection Needed: ${pending
271
295
  {
272
296
  type: "text",
273
297
  text: JSON.stringify({
274
- preferredLanguage: data.preferredLanguage || 'en',
298
+ preferredLanguage: rawData.preferredLanguage || 'en',
275
299
  annotations: annotationsWithTips
276
300
  }, null, 2),
277
301
  },
@@ -344,12 +368,13 @@ Instruction: ${ann.message}${pendingCorrection ? `\nCorrection Needed: ${pending
344
368
  throw new Error(`Backend responded with ${response.status}`);
345
369
  }
346
370
  const data = (await response.json());
371
+ const backlogNodes = Array.isArray(data) ? data : (data.data || data.backlog || []);
347
372
  return {
348
373
  content: [{
349
374
  type: "text",
350
375
  text: JSON.stringify({
351
376
  preferredLanguage: data.preferredLanguage || 'en',
352
- backlog: data.data || []
377
+ backlog: backlogNodes
353
378
  }, null, 2)
354
379
  }]
355
380
  };
@@ -427,10 +452,11 @@ Instruction: ${ann.message}${pendingCorrection ? `\nCorrection Needed: ${pending
427
452
  throw new Error(`Backend responded with ${response.status}`);
428
453
  }
429
454
  const data = (await response.json());
455
+ const endpointsList = Array.isArray(data) ? data : (data.endpoints || data.routes || data.data || []);
430
456
  return {
431
457
  content: [{
432
458
  type: "text",
433
- text: JSON.stringify(data.endpoints || [], null, 2)
459
+ text: JSON.stringify(endpointsList, null, 2)
434
460
  }]
435
461
  };
436
462
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "viewgate-mcp",
3
- "version": "1.0.22",
3
+ "version": "1.0.24",
4
4
  "main": "dist/index.js",
5
5
  "bin": {
6
6
  "viewgate-mcp": "./dist/index.js"