nana800-mcp-server 1.0.0 → 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.
- package/dist/index.js +67 -22
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -445,25 +445,61 @@ 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
|
+
cachedNodesInfo = await client.get("/info/nodes_info");
|
|
453
|
+
return cachedNodesInfo;
|
|
454
|
+
};
|
|
455
|
+
var validateTriggerType = async (triggerType) => {
|
|
456
|
+
const info = await getNodesInfo();
|
|
457
|
+
const availableTypes = info.trigger_types.map((t) => t.key);
|
|
458
|
+
return { valid: availableTypes.includes(triggerType), availableTypes };
|
|
459
|
+
};
|
|
460
|
+
var validateActionType = async (actionType) => {
|
|
461
|
+
const info = await getNodesInfo();
|
|
462
|
+
const availableTypes = info.action_types.map((t) => t.key);
|
|
463
|
+
return { valid: availableTypes.includes(actionType), availableTypes };
|
|
464
|
+
};
|
|
448
465
|
var registerNodeTools = (server) => {
|
|
466
|
+
server.tool(
|
|
467
|
+
"get_nodes_info",
|
|
468
|
+
"Get information about available node types (trigger_types, action_types) and their configuration options. Call this first to see available types before creating nodes.",
|
|
469
|
+
{},
|
|
470
|
+
async () => {
|
|
471
|
+
const client = getApiClient();
|
|
472
|
+
const result = await client.get("/info/nodes_info");
|
|
473
|
+
return {
|
|
474
|
+
content: [{ type: "text", text: JSON.stringify(result, null, 2) }]
|
|
475
|
+
};
|
|
476
|
+
}
|
|
477
|
+
);
|
|
449
478
|
server.tool(
|
|
450
479
|
"node_create_trigger",
|
|
451
|
-
"Create a new trigger node in a scheme. Triggers start the execution of automation workflows.",
|
|
480
|
+
"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
481
|
{
|
|
453
482
|
scheme: z3.string().optional().describe("The scheme ID where the trigger will be created (uses MCP_SCHEME_ID env if not provided)"),
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
slug: z3.string().optional().describe("URL-friendly identifier for code_action triggers")
|
|
483
|
+
trigger_type: z3.string().describe("Type of trigger (e.g., WEBHOOK, INTERVAL, CODE_ACTION)"),
|
|
484
|
+
slug: z3.string().optional().describe("URL-friendly identifier for the trigger"),
|
|
485
|
+
description: z3.string().optional().describe("Description of what this trigger does")
|
|
458
486
|
},
|
|
459
|
-
async ({ scheme,
|
|
487
|
+
async ({ scheme, trigger_type, slug, description }) => {
|
|
460
488
|
try {
|
|
489
|
+
const validation = await validateTriggerType(trigger_type);
|
|
490
|
+
if (!validation.valid) {
|
|
491
|
+
return {
|
|
492
|
+
content: [{ type: "text", text: JSON.stringify({
|
|
493
|
+
success: false,
|
|
494
|
+
error: `Invalid trigger_type "${trigger_type}". Available types: ${validation.availableTypes.join(", ")}`
|
|
495
|
+
}, null, 2) }]
|
|
496
|
+
};
|
|
497
|
+
}
|
|
461
498
|
const resolvedSchemeId = getSchemeId(scheme);
|
|
462
499
|
const client = getApiClient();
|
|
463
|
-
const body = { scheme: resolvedSchemeId,
|
|
464
|
-
if (node_name) body.node_name = node_name;
|
|
465
|
-
if (node_description) body.node_description = node_description;
|
|
500
|
+
const body = { scheme: resolvedSchemeId, trigger_type };
|
|
466
501
|
if (slug) body.slug = slug;
|
|
502
|
+
if (description) body.description = description;
|
|
467
503
|
const result = await client.post("/node/create/trigger", body);
|
|
468
504
|
return {
|
|
469
505
|
content: [{ type: "text", text: JSON.stringify(result, null, 2) }]
|
|
@@ -477,20 +513,29 @@ var registerNodeTools = (server) => {
|
|
|
477
513
|
);
|
|
478
514
|
server.tool(
|
|
479
515
|
"node_create_action",
|
|
480
|
-
"Create a new action node in a scheme. Actions perform operations like sending emails, making HTTP requests, etc.",
|
|
516
|
+
"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.",
|
|
481
517
|
{
|
|
482
518
|
scheme: z3.string().optional().describe("The scheme ID where the action will be created (uses MCP_SCHEME_ID env if not provided)"),
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
519
|
+
action_type: z3.string().describe("Type of action (e.g., REQUEST, CONDITION, TG_BOT_MESSAGE_SEND, SET_CONTEXT_PARAM_DATA)"),
|
|
520
|
+
slug: z3.string().optional().describe("URL-friendly identifier for the action"),
|
|
521
|
+
description: z3.string().optional().describe("Description of what this action does")
|
|
486
522
|
},
|
|
487
|
-
async ({ scheme,
|
|
523
|
+
async ({ scheme, action_type, slug, description }) => {
|
|
488
524
|
try {
|
|
525
|
+
const validation = await validateActionType(action_type);
|
|
526
|
+
if (!validation.valid) {
|
|
527
|
+
return {
|
|
528
|
+
content: [{ type: "text", text: JSON.stringify({
|
|
529
|
+
success: false,
|
|
530
|
+
error: `Invalid action_type "${action_type}". Available types: ${validation.availableTypes.join(", ")}`
|
|
531
|
+
}, null, 2) }]
|
|
532
|
+
};
|
|
533
|
+
}
|
|
489
534
|
const resolvedSchemeId = getSchemeId(scheme);
|
|
490
535
|
const client = getApiClient();
|
|
491
|
-
const body = { scheme: resolvedSchemeId,
|
|
492
|
-
if (
|
|
493
|
-
if (
|
|
536
|
+
const body = { scheme: resolvedSchemeId, action_type };
|
|
537
|
+
if (slug) body.slug = slug;
|
|
538
|
+
if (description) body.description = description;
|
|
494
539
|
const result = await client.post("/node/create/action", body);
|
|
495
540
|
return {
|
|
496
541
|
content: [{ type: "text", text: JSON.stringify(result, null, 2) }]
|
|
@@ -507,14 +552,14 @@ var registerNodeTools = (server) => {
|
|
|
507
552
|
"Update an existing node properties",
|
|
508
553
|
{
|
|
509
554
|
node_id: z3.string().describe("The unique ID of the node to update"),
|
|
510
|
-
|
|
511
|
-
|
|
555
|
+
slug: z3.string().optional().describe("New slug/identifier for the node"),
|
|
556
|
+
description: z3.string().optional().describe("New description")
|
|
512
557
|
},
|
|
513
|
-
async ({ node_id,
|
|
558
|
+
async ({ node_id, slug, description }) => {
|
|
514
559
|
const client = getApiClient();
|
|
515
560
|
const body = {};
|
|
516
|
-
if (
|
|
517
|
-
if (
|
|
561
|
+
if (slug !== void 0) body.slug = slug;
|
|
562
|
+
if (description !== void 0) body.description = description;
|
|
518
563
|
const result = await client.put(`/node/update/${node_id}`, body);
|
|
519
564
|
return {
|
|
520
565
|
content: [{ type: "text", text: JSON.stringify(result, null, 2) }]
|