@dypai-ai/mcp 1.6.11 → 1.6.12

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dypai-ai/mcp",
3
- "version": "1.6.11",
3
+ "version": "1.6.12",
4
4
  "description": "DYPAI MCP Server — AI agent toolkit for building and deploying full-stack apps",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
@@ -105,10 +105,12 @@ async function resolveLocal(rootDir, endpoint, mapsCtx, projectId = null) {
105
105
  return {
106
106
  workflow_code: effective.data.workflowCode,
107
107
  workflowSource: entry.source === "flow" ? "flow" : "legacy-yaml",
108
+ method: entry.method || effective.data.method || "GET",
108
109
  source: {
109
110
  mode: "local",
110
111
  file: entry.file || `flows/${endpoint}.flow.ts`,
111
112
  workflowSource: entry.source === "flow" ? "flow" : "legacy-yaml",
113
+ method: entry.method || effective.data.method || "GET",
112
114
  },
113
115
  }
114
116
  }
@@ -198,18 +200,20 @@ async function resolveDraft(projectId, endpoint) {
198
200
  }
199
201
  return {
200
202
  workflow_code,
203
+ method: payload.method || match.method || "GET",
201
204
  source: {
202
205
  mode: "draft",
203
206
  draft_id: match.id,
204
207
  created_at: match.created_at,
205
208
  created_by: match.created_by,
209
+ method: payload.method || match.method || "GET",
206
210
  },
207
211
  }
208
212
  }
209
213
 
210
214
  async function resolveLive(projectId, endpoint) {
211
215
  // Look up the deployed row directly. system.endpoints.workflow_code is jsonb.
212
- const sql = `SELECT id, name, workflow_code, updated_at
216
+ const sql = `SELECT id, name, method, workflow_code, updated_at
213
217
  FROM system.endpoints
214
218
  WHERE name = '${endpoint.replace(/'/g, "''")}'
215
219
  LIMIT 1`
@@ -237,10 +241,12 @@ async function resolveLive(projectId, endpoint) {
237
241
  }
238
242
  return {
239
243
  workflow_code,
244
+ method: row.method || "GET",
240
245
  source: {
241
246
  mode: "live",
242
247
  endpoint_id: row.id,
243
248
  updated_at: row.updated_at,
249
+ method: row.method || "GET",
244
250
  },
245
251
  }
246
252
  }
@@ -288,6 +294,8 @@ async function resolveEndpointWorkflow({ endpoint, mode, rootDir, targetProjectI
288
294
 
289
295
  function buildSourceMeta(mode, resolved) {
290
296
  const sourceMeta = { mode }
297
+ const method = String(resolved.method || resolved.source?.method || "GET").toUpperCase()
298
+ sourceMeta.method = method
291
299
  if (mode === "local") {
292
300
  sourceMeta.file = resolved.source.file
293
301
  sourceMeta.workflowSource = resolved.workflowSource || resolved.source.workflowSource || "legacy-yaml"
@@ -302,6 +310,68 @@ function buildSourceMeta(mode, resolved) {
302
310
  return sourceMeta
303
311
  }
304
312
 
313
+ function sdkError(message, extra = {}) {
314
+ return {
315
+ message: String(message || "Endpoint execution failed"),
316
+ ...extra,
317
+ }
318
+ }
319
+
320
+ export function endpointResultFromDebugResponse(response) {
321
+ if (!response || typeof response !== "object" || Array.isArray(response)) {
322
+ return response
323
+ }
324
+
325
+ // Engine debug responses wrap the public endpoint body in `result` and add
326
+ // debug-only metadata beside it. The SDK only exposes the public body under
327
+ // `data`, never the debug wrapper.
328
+ if (
329
+ Object.prototype.hasOwnProperty.call(response, "result")
330
+ && (
331
+ Object.prototype.hasOwnProperty.call(response, "execution")
332
+ || Object.prototype.hasOwnProperty.call(response, "trace")
333
+ || Object.prototype.hasOwnProperty.call(response, "execution_id")
334
+ )
335
+ ) {
336
+ return response.result
337
+ }
338
+
339
+ return response
340
+ }
341
+
342
+ export function sdkResponseFromEndpointTest(response) {
343
+ return {
344
+ data: endpointResultFromDebugResponse(response),
345
+ error: null,
346
+ }
347
+ }
348
+
349
+ function failedSdkResponse(message, extra = {}) {
350
+ return {
351
+ data: null,
352
+ error: sdkError(message, extra),
353
+ }
354
+ }
355
+
356
+ export function frontendUsageForEndpoint({ endpoint, method = "GET", input = {} } = {}) {
357
+ const httpMethod = String(method || "GET").toUpperCase()
358
+ const sdkMethod = httpMethod.toLowerCase()
359
+ const usesBody = ["POST", "PUT", "PATCH"].includes(httpMethod)
360
+ const hasInput = input && typeof input === "object" && !Array.isArray(input) && Object.keys(input).length > 0
361
+
362
+ return {
363
+ sdk_contract: "DYPAI SDK methods return { data, error }. The endpoint response body is inside data.",
364
+ correct_pattern: usesBody
365
+ ? `const { data, error } = await dypai.api.${sdkMethod}(${JSON.stringify(endpoint)}, body); if (error) throw error;`
366
+ : `const { data, error } = await dypai.api.${sdkMethod}(${JSON.stringify(endpoint)}, { params }); if (error) throw error;`,
367
+ params_or_body: usesBody
368
+ ? "For this HTTP method, pass request fields as the body argument."
369
+ : "For GET/DELETE endpoints, pass filters/query fields inside { params }.",
370
+ tested_input: hasInput ? input : undefined,
371
+ do_not: "Do not read endpoint fields from the top-level SDK response (for example res.items). Use data?.items.",
372
+ }
373
+ }
374
+
305
375
  // ─── Tool ───────────────────────────────────────────────────────────────────
306
376
 
307
377
  export const dypaiTestEndpointTool = {
@@ -507,6 +577,8 @@ export const dypaiTestEndpointTool = {
507
577
  endpoint,
508
578
  source: sourceMetaRun,
509
579
  as_user: as_user || null,
580
+ sdk_response: failedSdkResponse(result),
581
+ frontend_usage: frontendUsageForEndpoint({ endpoint, method: sourceMetaRun.method, input }),
510
582
  error: result.length > 2000 ? result.slice(0, 2000) + "...[truncated]" : result,
511
583
  hint: "The remote returned a raw error string (no per-node trace available). Read the error above for the root cause.",
512
584
  }
@@ -517,6 +589,8 @@ export const dypaiTestEndpointTool = {
517
589
  endpoint,
518
590
  source: sourceMetaRun,
519
591
  as_user: as_user || null,
592
+ sdk_response: failedSdkResponse(`Unexpected response type from remote test_workflow: ${typeof result}`),
593
+ frontend_usage: frontendUsageForEndpoint({ endpoint, method: sourceMetaRun.method, input }),
520
594
  error: `Unexpected response type from remote test_workflow: ${typeof result}`,
521
595
  raw_response: result,
522
596
  }
@@ -536,6 +610,8 @@ export const dypaiTestEndpointTool = {
536
610
  endpoint,
537
611
  source: sourceMetaRun,
538
612
  as_user: as_user || null,
613
+ sdk_response: sdkResponseFromEndpointTest(result),
614
+ frontend_usage: frontendUsageForEndpoint({ endpoint, method: sourceMetaRun.method, input }),
539
615
  ...(stopAtStep ? { stop_at_step: stopAtStep } : {}),
540
616
  ...(step_outputs && Object.keys(step_outputs).length ? { step_outputs } : {}),
541
617
  ...safeSummary,
@@ -549,6 +625,8 @@ export const dypaiTestEndpointTool = {
549
625
  error: `Execution failed: ${e.message}`,
550
626
  endpoint,
551
627
  source: sourceMetaRun,
628
+ sdk_response: failedSdkResponse(e.message),
629
+ frontend_usage: frontendUsageForEndpoint({ endpoint, method: sourceMetaRun.method, input }),
552
630
  hint: stopAtStep
553
631
  ? "Verify stop_at_step with operation:'list_steps'. For full trace use trace_mode:'full'."
554
632
  : "If the error is cryptic, try trace_mode: 'full' or search_logs with include_trace:true.",