viewgate-mcp 1.0.1 → 1.0.3

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 +84 -4
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1,4 +1,17 @@
1
1
  #!/usr/bin/env node
2
+ // MCP protocol over Stdio REQUIRES that stdout is ONLY used for JSON-RPC.
3
+ // We redirect all console.log to console.error as early as possible.
4
+ console.log = console.error;
5
+ // Also catch raw process.stdout.write to prevent pollution from dependencies
6
+ const originalStdoutWrite = process.stdout.write.bind(process.stdout);
7
+ process.stdout.write = (...args) => {
8
+ const str = args[0].toString();
9
+ // Only allow JSON-RPC messages (which start with {)
10
+ if (str.startsWith('{')) {
11
+ return originalStdoutWrite(...args);
12
+ }
13
+ return process.stderr.write(...args);
14
+ };
2
15
  import express from "express";
3
16
  import { Server } from "@modelcontextprotocol/sdk/server/index.js";
4
17
  import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
@@ -8,10 +21,6 @@ import fetch from "node-fetch";
8
21
  import cors from "cors";
9
22
  import dotenv from "dotenv";
10
23
  dotenv.config();
11
- // MCP protocol over Stdio REQUIRES that stdout is ONLY used for JSON-RPC.
12
- // We redirect all console.log to console.error to avoid polluting stdout.
13
- const originalLog = console.log;
14
- console.log = console.error;
15
24
  const port = process.env.PORT || 3000;
16
25
  const BACKEND_URL = process.env.BACKEND_URL || "https://view-gate.vercel.app";
17
26
  // Store active sessions for SSE: sessionId -> { server, transport }
@@ -60,6 +69,35 @@ function createMcpServer(apiKey) {
60
69
  },
61
70
  required: ["id", "originalMessage", "appliedChanges"]
62
71
  },
72
+ },
73
+ {
74
+ name: "planning",
75
+ description: "Planning tool for backlog tickets. CALL WITHOUT ARGUMENTS to fetch backlog tickets that need analysis. CALL WITH 'results' to submit AI analysis in batch. Rules: complejidad (1-3), incertidumbre (1-3), impacto (1-3), riesgo (1-3), tipo (AI-friendly|AI-assisted|Human-critical).",
76
+ inputSchema: {
77
+ type: "object",
78
+ properties: {
79
+ results: {
80
+ type: "array",
81
+ items: {
82
+ type: "object",
83
+ properties: {
84
+ id: { type: "string", description: "The ticket/annotation ID" },
85
+ complejidad: { type: "number", minimum: 1, maximum: 3 },
86
+ incertidumbre: { type: "number", minimum: 1, maximum: 3 },
87
+ impacto: { type: "number", minimum: 1, maximum: 3 },
88
+ riesgo: { type: "number", minimum: 1, maximum: 3 },
89
+ tipo: { type: "string", enum: ["AI-friendly", "AI-assisted", "Human-critical"] },
90
+ aiAnalysis: { type: "string", description: "Reasoning or summary of the analysis" }
91
+ },
92
+ required: ["id", "complejidad", "incertidumbre", "impacto", "riesgo", "tipo", "aiAnalysis"]
93
+ }
94
+ },
95
+ force: {
96
+ type: "boolean",
97
+ description: "If true, overwrites existing planning data."
98
+ }
99
+ }
100
+ }
63
101
  }
64
102
  ],
65
103
  };
@@ -179,6 +217,48 @@ function createMcpServer(apiKey) {
179
217
  };
180
218
  }
181
219
  }
220
+ case "planning": {
221
+ try {
222
+ const args = request.params.arguments;
223
+ if (!args.results) {
224
+ // Fetch Backlog Mode
225
+ const response = await fetch(`${BACKEND_URL}/api/mcp/backlog`, {
226
+ headers: { 'x-api-key': apiKey }
227
+ });
228
+ if (!response.ok) {
229
+ throw new Error(`Backend responded with ${response.status}`);
230
+ }
231
+ const data = (await response.json());
232
+ return {
233
+ content: [{ type: "text", text: JSON.stringify(data.data || [], null, 2) }]
234
+ };
235
+ }
236
+ else {
237
+ // Submit Results Mode
238
+ const response = await fetch(`${BACKEND_URL}/api/mcp/annotations/batch-planning`, {
239
+ method: 'PATCH',
240
+ headers: {
241
+ 'Content-Type': 'application/json',
242
+ 'x-api-key': apiKey
243
+ },
244
+ body: JSON.stringify({ results: args.results, force: args.force })
245
+ });
246
+ if (!response.ok) {
247
+ throw new Error(`Backend responded with ${response.status}`);
248
+ }
249
+ const result = await response.json();
250
+ return {
251
+ content: [{ type: "text", text: `Planning results processed: ${JSON.stringify(result, null, 2)}` }]
252
+ };
253
+ }
254
+ }
255
+ catch (error) {
256
+ return {
257
+ content: [{ type: "text", text: `Error in planning tool: ${error.message}` }],
258
+ isError: true
259
+ };
260
+ }
261
+ }
182
262
  default:
183
263
  throw new Error("Unknown tool");
184
264
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "viewgate-mcp",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "main": "dist/index.js",
5
5
  "bin": {
6
6
  "viewgate-mcp": "./dist/index.js"