nana800-mcp-server 1.0.1 → 1.0.4
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 +50 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -445,10 +445,40 @@ var registerSchemeTools = (server) => {
|
|
|
445
445
|
|
|
446
446
|
// src/tools/node.tools.ts
|
|
447
447
|
import { z as z3 } from "zod";
|
|
448
|
+
var cachedNodesInfo = null;
|
|
449
|
+
var getNodesInfo = async () => {
|
|
450
|
+
if (cachedNodesInfo) return cachedNodesInfo;
|
|
451
|
+
const client = getApiClient();
|
|
452
|
+
const response = await client.get("/info/nodes_info");
|
|
453
|
+
cachedNodesInfo = response.data;
|
|
454
|
+
return cachedNodesInfo;
|
|
455
|
+
};
|
|
456
|
+
var validateTriggerType = async (triggerType) => {
|
|
457
|
+
const info = await getNodesInfo();
|
|
458
|
+
const availableTypes = info.trigger_types.map((t) => t.key);
|
|
459
|
+
return { valid: availableTypes.includes(triggerType), availableTypes };
|
|
460
|
+
};
|
|
461
|
+
var validateActionType = async (actionType) => {
|
|
462
|
+
const info = await getNodesInfo();
|
|
463
|
+
const availableTypes = info.action_types.map((t) => t.key);
|
|
464
|
+
return { valid: availableTypes.includes(actionType), availableTypes };
|
|
465
|
+
};
|
|
448
466
|
var registerNodeTools = (server) => {
|
|
467
|
+
server.tool(
|
|
468
|
+
"get_nodes_info",
|
|
469
|
+
"Get information about available node types (trigger_types, action_types) and their configuration options. Call this first to see available types before creating nodes.",
|
|
470
|
+
{},
|
|
471
|
+
async () => {
|
|
472
|
+
const client = getApiClient();
|
|
473
|
+
const result = await client.get("/info/nodes_info");
|
|
474
|
+
return {
|
|
475
|
+
content: [{ type: "text", text: JSON.stringify(result, null, 2) }]
|
|
476
|
+
};
|
|
477
|
+
}
|
|
478
|
+
);
|
|
449
479
|
server.tool(
|
|
450
480
|
"node_create_trigger",
|
|
451
|
-
"Create a new trigger node in a scheme. Triggers start the execution of automation workflows.",
|
|
481
|
+
"Create a new trigger node in a scheme. Triggers start the execution of automation workflows. Call get_nodes_info first to see available types.",
|
|
452
482
|
{
|
|
453
483
|
scheme: z3.string().optional().describe("The scheme ID where the trigger will be created (uses MCP_SCHEME_ID env if not provided)"),
|
|
454
484
|
trigger_type: z3.string().describe("Type of trigger (e.g., WEBHOOK, INTERVAL, CODE_ACTION)"),
|
|
@@ -457,6 +487,15 @@ var registerNodeTools = (server) => {
|
|
|
457
487
|
},
|
|
458
488
|
async ({ scheme, trigger_type, slug, description }) => {
|
|
459
489
|
try {
|
|
490
|
+
const validation = await validateTriggerType(trigger_type);
|
|
491
|
+
if (!validation.valid) {
|
|
492
|
+
return {
|
|
493
|
+
content: [{ type: "text", text: JSON.stringify({
|
|
494
|
+
success: false,
|
|
495
|
+
error: `Invalid trigger_type "${trigger_type}". Available types: ${validation.availableTypes.join(", ")}`
|
|
496
|
+
}, null, 2) }]
|
|
497
|
+
};
|
|
498
|
+
}
|
|
460
499
|
const resolvedSchemeId = getSchemeId(scheme);
|
|
461
500
|
const client = getApiClient();
|
|
462
501
|
const body = { scheme: resolvedSchemeId, trigger_type };
|
|
@@ -475,7 +514,7 @@ var registerNodeTools = (server) => {
|
|
|
475
514
|
);
|
|
476
515
|
server.tool(
|
|
477
516
|
"node_create_action",
|
|
478
|
-
"Create a new action node in a scheme. Actions perform operations like sending emails, making HTTP requests, etc.",
|
|
517
|
+
"Create a new action node in a scheme. Actions perform operations like sending emails, making HTTP requests, etc. Call get_nodes_info first to see available types.",
|
|
479
518
|
{
|
|
480
519
|
scheme: z3.string().optional().describe("The scheme ID where the action will be created (uses MCP_SCHEME_ID env if not provided)"),
|
|
481
520
|
action_type: z3.string().describe("Type of action (e.g., REQUEST, CONDITION, TG_BOT_MESSAGE_SEND, SET_CONTEXT_PARAM_DATA)"),
|
|
@@ -484,6 +523,15 @@ var registerNodeTools = (server) => {
|
|
|
484
523
|
},
|
|
485
524
|
async ({ scheme, action_type, slug, description }) => {
|
|
486
525
|
try {
|
|
526
|
+
const validation = await validateActionType(action_type);
|
|
527
|
+
if (!validation.valid) {
|
|
528
|
+
return {
|
|
529
|
+
content: [{ type: "text", text: JSON.stringify({
|
|
530
|
+
success: false,
|
|
531
|
+
error: `Invalid action_type "${action_type}". Available types: ${validation.availableTypes.join(", ")}`
|
|
532
|
+
}, null, 2) }]
|
|
533
|
+
};
|
|
534
|
+
}
|
|
487
535
|
const resolvedSchemeId = getSchemeId(scheme);
|
|
488
536
|
const client = getApiClient();
|
|
489
537
|
const body = { scheme: resolvedSchemeId, action_type };
|