@mgsoftwarebv/mg-dashboard-mcp 2.2.1 → 2.2.2
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 +30 -46
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -16,11 +16,14 @@ var TERMINAL_STATUSES = /* @__PURE__ */ new Set([
|
|
|
16
16
|
"INTERRUPTED",
|
|
17
17
|
"EXPIRED"
|
|
18
18
|
]);
|
|
19
|
-
var
|
|
19
|
+
var TRIGGER_SERVER_ID = "03659d55-e194-400d-b82a-bf6457371ded";
|
|
20
|
+
var COMPOSE_PROJECT = "mg-dashboard-supabase-trigger";
|
|
21
|
+
var PG_CONTAINER = `${COMPOSE_PROJECT}-postgres-1`;
|
|
22
|
+
var WA_CONTAINER = `${COMPOSE_PROJECT}-webapp-1`;
|
|
20
23
|
var TRIGGER_TOOLS = [
|
|
21
24
|
{
|
|
22
25
|
name: "trigger-list",
|
|
23
|
-
description:
|
|
26
|
+
description: 'List all Trigger.dev projects. Returns the project slug and name. Use the slug as the "project" parameter in other trigger-* tools.',
|
|
24
27
|
inputSchema: {
|
|
25
28
|
type: "object",
|
|
26
29
|
properties: {}
|
|
@@ -32,7 +35,7 @@ var TRIGGER_TOOLS = [
|
|
|
32
35
|
inputSchema: {
|
|
33
36
|
type: "object",
|
|
34
37
|
properties: {
|
|
35
|
-
project: { type: "string", description:
|
|
38
|
+
project: { type: "string", description: 'Project slug from trigger-list (e.g. "mg-dashboard-bHfS")' },
|
|
36
39
|
status: {
|
|
37
40
|
type: "string",
|
|
38
41
|
description: "Comma-separated status filter: QUEUED,EXECUTING,COMPLETED,FAILED,CRASHED,CANCELED,SYSTEM_FAILURE"
|
|
@@ -49,7 +52,7 @@ var TRIGGER_TOOLS = [
|
|
|
49
52
|
inputSchema: {
|
|
50
53
|
type: "object",
|
|
51
54
|
properties: {
|
|
52
|
-
project: { type: "string", description: "
|
|
55
|
+
project: { type: "string", description: "Project slug from trigger-list" },
|
|
53
56
|
runId: { type: "string", description: "Run ID (e.g. run_xxxxx)" }
|
|
54
57
|
},
|
|
55
58
|
required: ["project", "runId"]
|
|
@@ -61,7 +64,7 @@ var TRIGGER_TOOLS = [
|
|
|
61
64
|
inputSchema: {
|
|
62
65
|
type: "object",
|
|
63
66
|
properties: {
|
|
64
|
-
project: { type: "string", description: "
|
|
67
|
+
project: { type: "string", description: "Project slug from trigger-list" },
|
|
65
68
|
taskId: { type: "string", description: 'Task identifier (e.g. "hello-world", "execute-pipeline")' },
|
|
66
69
|
payload: { type: "string", description: "JSON payload string to pass to the task (optional)" },
|
|
67
70
|
waitSeconds: { type: "number", description: "Max seconds to wait for completion (default 60, max 300)" }
|
|
@@ -75,7 +78,7 @@ var TRIGGER_TOOLS = [
|
|
|
75
78
|
inputSchema: {
|
|
76
79
|
type: "object",
|
|
77
80
|
properties: {
|
|
78
|
-
project: { type: "string", description: "
|
|
81
|
+
project: { type: "string", description: "Project slug from trigger-list" },
|
|
79
82
|
runId: { type: "string", description: "Run ID to cancel (e.g. run_xxxxx)" }
|
|
80
83
|
},
|
|
81
84
|
required: ["project", "runId"]
|
|
@@ -87,7 +90,7 @@ var TRIGGER_TOOLS = [
|
|
|
87
90
|
inputSchema: {
|
|
88
91
|
type: "object",
|
|
89
92
|
properties: {
|
|
90
|
-
project: { type: "string", description: "
|
|
93
|
+
project: { type: "string", description: "Project slug from trigger-list" },
|
|
91
94
|
runId: { type: "string", description: "Run ID to replay (e.g. run_xxxxx)" }
|
|
92
95
|
},
|
|
93
96
|
required: ["project", "runId"]
|
|
@@ -103,12 +106,11 @@ var TRIGGER_TOOL_MODULE_MAP = {
|
|
|
103
106
|
"trigger-cancel-run": "ci_cd",
|
|
104
107
|
"trigger-replay-run": "ci_cd"
|
|
105
108
|
};
|
|
106
|
-
async function discoverInstance(
|
|
107
|
-
const
|
|
108
|
-
const wa = `${project}-webapp-1`;
|
|
109
|
+
async function discoverInstance(projectSlug, conn, proxy, sshExec2) {
|
|
110
|
+
const sql = `SELECT re.\\"apiKey\\" FROM \\"RuntimeEnvironment\\" re JOIN \\"Project\\" p ON re.\\"projectId\\" = p.id WHERE p.slug='${projectSlug}' AND re.slug='prod' LIMIT 1`;
|
|
109
111
|
const cmd = [
|
|
110
|
-
`PORT=$(docker port "${
|
|
111
|
-
`KEY=$(docker exec "${
|
|
112
|
+
`PORT=$(docker port "${WA_CONTAINER}" 3000/tcp 2>/dev/null | head -1 | sed 's/.*://')`,
|
|
113
|
+
`KEY=$(docker exec "${PG_CONTAINER}" psql -U postgres -d main -t -A -c "${sql}" 2>/dev/null | tr -d '[:space:]')`,
|
|
112
114
|
'echo "$PORT|$KEY"'
|
|
113
115
|
].join(" && ");
|
|
114
116
|
const result = await sshExec2(conn, cmd, proxy);
|
|
@@ -118,18 +120,18 @@ async function discoverInstance(project, conn, proxy, sshExec2) {
|
|
|
118
120
|
const apiKey2 = sepIdx > 0 ? output.substring(sepIdx + 1) : "";
|
|
119
121
|
if (!port) {
|
|
120
122
|
throw new Error(
|
|
121
|
-
`Could not find webapp port for ${
|
|
123
|
+
`Could not find webapp port for ${WA_CONTAINER}. Is the container running?`
|
|
122
124
|
);
|
|
123
125
|
}
|
|
124
126
|
if (!apiKey2) {
|
|
125
127
|
throw new Error(
|
|
126
|
-
`Could not get API key
|
|
128
|
+
`Could not get API key for project "${projectSlug}". Check if the project slug is correct (use trigger-list).`
|
|
127
129
|
);
|
|
128
130
|
}
|
|
129
131
|
return { port, apiKey: apiKey2 };
|
|
130
132
|
}
|
|
131
133
|
async function triggerApi(conn, proxy, sshExec2, instance, method, path, body) {
|
|
132
|
-
const parts = ["curl", "-s", "--max-time", "30"];
|
|
134
|
+
const parts = ["curl", "-s", "-g", "--max-time", "30"];
|
|
133
135
|
if (method !== "GET") parts.push("-X", method);
|
|
134
136
|
parts.push(`"http://localhost:${instance.port}${path}"`);
|
|
135
137
|
parts.push(`-H "Authorization: Bearer ${instance.apiKey}"`);
|
|
@@ -191,35 +193,22 @@ function formatRunDetail(run) {
|
|
|
191
193
|
}
|
|
192
194
|
async function handleTriggerTool(name, args2, deps) {
|
|
193
195
|
const { sshExec: sshExec2, getServerConnection: getServerConnection2 } = deps;
|
|
194
|
-
const
|
|
196
|
+
const { conn, proxy } = await getServerConnection2(TRIGGER_SERVER_ID);
|
|
195
197
|
switch (name) {
|
|
196
198
|
// -----------------------------------------------------------------
|
|
197
199
|
case "trigger-list": {
|
|
198
|
-
const
|
|
199
|
-
const
|
|
200
|
-
|
|
201
|
-
"for PG in $(docker ps --format '{{.Names}}' | grep -E 'trigger.*-postgres-[0-9]+$'); do",
|
|
202
|
-
` PROJECT=$(echo "$PG" | sed 's/-postgres-[0-9]*$//')`,
|
|
203
|
-
' WA="${PROJECT}-webapp-1"',
|
|
204
|
-
` PORT=$(docker port "$WA" 3000/tcp 2>/dev/null | head -1 | sed 's/.*://')`,
|
|
205
|
-
` STATUS=$(docker inspect -f '{{.State.Status}}' "$WA" 2>/dev/null || echo 'not_found')`,
|
|
206
|
-
` RUNNING=$(docker ps --filter "label=com.docker.compose.project=\${PROJECT}" --format '{{.Names}}' 2>/dev/null | wc -l)`,
|
|
207
|
-
` TOTAL=$(docker ps -a --filter "label=com.docker.compose.project=\${PROJECT}" --format '{{.Names}}' 2>/dev/null | wc -l)`,
|
|
208
|
-
' echo "${PROJECT}|${PORT:-?}|${STATUS}|${RUNNING}/${TOTAL}"',
|
|
209
|
-
" FOUND=1",
|
|
210
|
-
"done",
|
|
211
|
-
'[ "$FOUND" = "0" ] && echo "NO_INSTANCES"'
|
|
212
|
-
].join("\n");
|
|
213
|
-
const result = await sshExec2(conn, script, proxy);
|
|
200
|
+
const sql = 'SELECT slug, name FROM \\"Project\\" ORDER BY name';
|
|
201
|
+
const cmd = `docker exec "${PG_CONTAINER}" psql -U postgres -d main -t -A -c "${sql}" 2>/dev/null`;
|
|
202
|
+
const result = await sshExec2(conn, cmd, proxy);
|
|
214
203
|
const output = result.stdout.trim();
|
|
215
|
-
if (!output
|
|
216
|
-
return { content: [{ type: "text", text: "No Trigger.dev
|
|
204
|
+
if (!output) {
|
|
205
|
+
return { content: [{ type: "text", text: "No Trigger.dev projects found." }] };
|
|
217
206
|
}
|
|
218
|
-
const header = `${"
|
|
219
|
-
const sep = "-".repeat(
|
|
207
|
+
const header = `${"SLUG".padEnd(25)} NAME`;
|
|
208
|
+
const sep = "-".repeat(55);
|
|
220
209
|
const lines = output.split("\n").map((line) => {
|
|
221
|
-
const [
|
|
222
|
-
return `${(
|
|
210
|
+
const [slug, name2] = line.split("|");
|
|
211
|
+
return `${(slug || "").padEnd(25)} ${name2 || ""}`;
|
|
223
212
|
});
|
|
224
213
|
return { content: [{ type: "text", text: `${header}
|
|
225
214
|
${sep}
|
|
@@ -228,12 +217,11 @@ ${lines.join("\n")}` }] };
|
|
|
228
217
|
// -----------------------------------------------------------------
|
|
229
218
|
case "trigger-runs": {
|
|
230
219
|
const project = String(args2.project);
|
|
231
|
-
const { conn, proxy } = await getServerConnection2(serverId);
|
|
232
220
|
const instance = await discoverInstance(project, conn, proxy, sshExec2);
|
|
233
221
|
const limit = Math.min(Math.max(Number(args2.limit) || 20, 1), 100);
|
|
234
|
-
const queryParts = [`page
|
|
235
|
-
if (args2.status) queryParts.push(`filter
|
|
236
|
-
if (args2.taskIdentifier) queryParts.push(`filter
|
|
222
|
+
const queryParts = [`page%5Bsize%5D=${limit}`];
|
|
223
|
+
if (args2.status) queryParts.push(`filter%5Bstatus%5D=${String(args2.status)}`);
|
|
224
|
+
if (args2.taskIdentifier) queryParts.push(`filter%5BtaskIdentifier%5D=${String(args2.taskIdentifier)}`);
|
|
237
225
|
const rawJson = await triggerApi(
|
|
238
226
|
conn,
|
|
239
227
|
proxy,
|
|
@@ -256,7 +244,6 @@ ${rawJson.substring(0, 500)}` }] };
|
|
|
256
244
|
case "trigger-run-detail": {
|
|
257
245
|
const project = String(args2.project);
|
|
258
246
|
const runId = String(args2.runId);
|
|
259
|
-
const { conn, proxy } = await getServerConnection2(serverId);
|
|
260
247
|
const instance = await discoverInstance(project, conn, proxy, sshExec2);
|
|
261
248
|
const rawJson = await triggerApi(
|
|
262
249
|
conn,
|
|
@@ -280,7 +267,6 @@ ${rawJson.substring(0, 500)}` }] };
|
|
|
280
267
|
const project = String(args2.project);
|
|
281
268
|
const taskId = String(args2.taskId);
|
|
282
269
|
const waitSeconds = Math.min(Math.max(Number(args2.waitSeconds) || 60, 5), 300);
|
|
283
|
-
const { conn, proxy } = await getServerConnection2(serverId);
|
|
284
270
|
conn.timeout = (waitSeconds + 30) * 1e3;
|
|
285
271
|
const instance = await discoverInstance(project, conn, proxy, sshExec2);
|
|
286
272
|
let payload = "{}";
|
|
@@ -350,7 +336,6 @@ ${triggerJson.substring(0, 500)}` }] };
|
|
|
350
336
|
case "trigger-cancel-run": {
|
|
351
337
|
const project = String(args2.project);
|
|
352
338
|
const runId = String(args2.runId);
|
|
353
|
-
const { conn, proxy } = await getServerConnection2(serverId);
|
|
354
339
|
const instance = await discoverInstance(project, conn, proxy, sshExec2);
|
|
355
340
|
const rawJson = await triggerApi(
|
|
356
341
|
conn,
|
|
@@ -378,7 +363,6 @@ ${rawJson.substring(0, 500)}` }] };
|
|
|
378
363
|
case "trigger-replay-run": {
|
|
379
364
|
const project = String(args2.project);
|
|
380
365
|
const runId = String(args2.runId);
|
|
381
|
-
const { conn, proxy } = await getServerConnection2(serverId);
|
|
382
366
|
const instance = await discoverInstance(project, conn, proxy, sshExec2);
|
|
383
367
|
const rawJson = await triggerApi(
|
|
384
368
|
conn,
|