Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ validation errors, and summarize what each process does.
| `run-task` | Send a task to a deployed process |
| `list-node-tasks` | List tasks currently sitting in a node |
| `list-task-history` | Show task execution history |
| `get-node-stat` | Return time-series in/out statistics for a node |
| `delete-task` | Remove a task from a node |
| `modify-task` | Update task parameters |
| `create-process` | Create a new empty process in a folder |
Expand Down
1 change: 1 addition & 0 deletions plugins/corezoid/mcp-server/mcp_handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ var toolHandlers = map[string]toolHandler{
// tasks
"list-task-history": handleListTaskHistory,
"list-node-tasks": handleListNodeTasks,
"get-node-stat": handleGetNodeStat,
"modify-task": handleModifyTask,
"delete-task": handleDeleteTask,

Expand Down
52 changes: 52 additions & 0 deletions plugins/corezoid/mcp-server/mcp_handlers_tasks.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,58 @@ func handleListNodeTasks(ctx context.Context, args map[string]interface{}) (stri
return string(data), false
}

// handleGetNodeStat returns time-series in/out statistics for a process node
// over a caller-specified time window. The interval parameter controls bucket
// granularity ("day" or "hour", default "day").
func handleGetNodeStat(ctx context.Context, args map[string]interface{}) (string, bool) {
processID, err := intArg(args, "process_id")
if err != nil {
return "Error: " + err.Error(), true
}
nodeID, err := strArg(args, "node_id")
if err != nil {
return "Error: " + err.Error(), true
}
start, err := intArg(args, "start")
if err != nil {
return "Error: " + err.Error(), true
}
end, err := intArg(args, "end")
if err != nil {
return "Error: " + err.Error(), true
}
interval := "day"
if v, ok := args["interval"].(string); ok && v != "" {
interval = v
}
timezoneOffset := 0
if n, err := intArg(args, "timezone_offset"); err == nil {
timezoneOffset = n
}

v := NewValidator(ctx, processID)
ops := []map[string]any{
{
"obj": "stat",
"type": "show",
"group": "time",
"conv_id": processID,
"node_id": nodeID,
"company_id": v.WorkspaceID,
"start": start,
"end": end,
"interval": interval,
"timezone_offset": timezoneOffset,
},
}
resp, err := v.req("get_node_stat", ops)
if err != nil {
return fmt.Sprintf("Error: %v", err), true
}
data, _ := json.MarshalIndent(resp, "", " ")
return string(data), false
}

// handleModifyTask updates the data payload of an existing task. Either
// task_id or ref must be supplied to identify the task.
func handleModifyTask(ctx context.Context, args map[string]interface{}) (string, bool) {
Expand Down
1 change: 1 addition & 0 deletions plugins/corezoid/mcp-server/mcp_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ func runMCPServer() {
ID: req.ID,
Result: map[string]interface{}{
"tools": toolRegistry,

},
})

Expand Down
34 changes: 34 additions & 0 deletions plugins/corezoid/mcp-server/tools_registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,40 @@ var toolRegistry = []mcpTool{
"required": []string{"process_id", "node_id"},
},
},
{
Name: "get-node-stat",
Description: "Return time-series statistics (in/out counts) for a node over a time range. node_id is the ID shown in the Corezoid UI archive URL (/diagram/{node_id}/archive). ops[0]['data'] contains [{\"date\":\"YYYY-MM-DD\",\"in\":N,\"out\":M}] for non-zero buckets. ops[0]['title'] is the node title.",
InputSchema: map[string]interface{}{
"type": "object",
"properties": map[string]interface{}{
"process_id": map[string]interface{}{
"type": "integer",
"description": "Corezoid process (conv) ID",
},
"node_id": map[string]interface{}{
"type": "string",
"description": "Node ID from the Corezoid UI archive URL",
},
"start": map[string]interface{}{
"type": "integer",
"description": "Unix timestamp — start of the period",
},
"end": map[string]interface{}{
"type": "integer",
"description": "Unix timestamp — end of the period",
},
"interval": map[string]interface{}{
"type": "string",
"description": "Aggregation bucket: 'day' or 'hour' (default: 'day')",
},
"timezone_offset": map[string]interface{}{
"type": "integer",
"description": "UTC offset in minutes, negative westward (e.g. -180 for UTC+3, default: 0)",
},
},
"required": []string{"process_id", "node_id", "start", "end"},
},
},
{
Name: "modify-task",
Description: "Modify an existing task's data. The task will continue from the node where it was paused with the updated data. At least one of task_id or ref must be provided.",
Expand Down
Loading