@cplace/mcp-server 1.5.2 → 1.6.0

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.
Files changed (57) hide show
  1. package/README.md +44 -0
  2. package/dist/conditional-registration.d.ts.map +1 -1
  3. package/dist/conditional-registration.js +10 -0
  4. package/dist/conditional-registration.js.map +1 -1
  5. package/dist/profiles.d.ts.map +1 -1
  6. package/dist/profiles.js +7 -3
  7. package/dist/profiles.js.map +1 -1
  8. package/dist/tool-metadata.d.ts.map +1 -1
  9. package/dist/tool-metadata.js +8 -0
  10. package/dist/tool-metadata.js.map +1 -1
  11. package/dist/tools/board-widget.d.ts +140 -89
  12. package/dist/tools/board-widget.d.ts.map +1 -1
  13. package/dist/tools/board-widget.js +131 -112
  14. package/dist/tools/board-widget.js.map +1 -1
  15. package/dist/tools/documents.d.ts +18 -0
  16. package/dist/tools/documents.d.ts.map +1 -0
  17. package/dist/tools/documents.js +59 -0
  18. package/dist/tools/documents.js.map +1 -0
  19. package/dist/tools/expert-settings.d.ts +38 -0
  20. package/dist/tools/expert-settings.d.ts.map +1 -0
  21. package/dist/tools/expert-settings.js +145 -0
  22. package/dist/tools/expert-settings.js.map +1 -0
  23. package/dist/tools/job-schedule-trigger.d.ts +16 -0
  24. package/dist/tools/job-schedule-trigger.d.ts.map +1 -0
  25. package/dist/tools/job-schedule-trigger.js +32 -0
  26. package/dist/tools/job-schedule-trigger.js.map +1 -0
  27. package/dist/tools/job-scripts.d.ts +58 -0
  28. package/dist/tools/job-scripts.d.ts.map +1 -0
  29. package/dist/tools/job-scripts.js +215 -0
  30. package/dist/tools/job-scripts.js.map +1 -0
  31. package/dist/tools/layout-richstring-widgets.d.ts.map +1 -1
  32. package/dist/tools/layout-richstring-widgets.js +1 -42
  33. package/dist/tools/layout-richstring-widgets.js.map +1 -1
  34. package/dist/tools/layout.d.ts.map +1 -1
  35. package/dist/tools/layout.js +2 -34
  36. package/dist/tools/layout.js.map +1 -1
  37. package/dist/tools/resource-planner-widget.d.ts +280 -0
  38. package/dist/tools/resource-planner-widget.d.ts.map +1 -0
  39. package/dist/tools/resource-planner-widget.js +539 -0
  40. package/dist/tools/resource-planner-widget.js.map +1 -0
  41. package/dist/tools/widget-tool-helpers.d.ts +7 -0
  42. package/dist/tools/widget-tool-helpers.d.ts.map +1 -0
  43. package/dist/tools/widget-tool-helpers.js +43 -0
  44. package/dist/tools/widget-tool-helpers.js.map +1 -0
  45. package/dist/widget-specifications/cf.cplace.cboard.main.board/_implementation.md +24 -0
  46. package/dist/widget-specifications/cf.cplace.resourceManagement.resourcePlannerDefinition/_implementation.md +42 -0
  47. package/dist/widget-specifications/cf.cplace.resourceManagement.resourcePlannerDefinition/actionSearch.md +10 -0
  48. package/dist/widget-specifications/cf.cplace.resourceManagement.resourcePlannerDefinition/attributesConfiguration.md +30 -0
  49. package/dist/widget-specifications/cf.cplace.resourceManagement.resourcePlannerDefinition/chartSearch.md +10 -0
  50. package/dist/widget-specifications/cf.cplace.resourceManagement.resourcePlannerDefinition/dateCalculation.md +8 -0
  51. package/dist/widget-specifications/cf.cplace.resourceManagement.resourcePlannerDefinition/defaultColumnsConfiguration.md +7 -0
  52. package/dist/widget-specifications/cf.cplace.resourceManagement.resourcePlannerDefinition/searchFirstGroup.md +8 -0
  53. package/dist/widget-specifications/cf.cplace.resourceManagement.resourcePlannerDefinition/searchNode.md +8 -0
  54. package/dist/widget-specifications/cf.cplace.resourceManagement.resourcePlannerDefinition/searchRootNode.md +10 -0
  55. package/dist/widget-specifications/cf.cplace.resourceManagement.resourcePlannerDefinition/searchSecondGroup.md +8 -0
  56. package/dist/widget-specifications/cf.cplace.resourceManagement.resourcePlannerDefinition/treeStructure.md +1 -0
  57. package/package.json +1 -1
@@ -0,0 +1,38 @@
1
+ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
+ import { z } from "zod";
3
+ import { CplaceApiClient } from '../api.js';
4
+ export declare const EXPERT_SETTINGS_TOOL_DEFINITIONS: {
5
+ readonly cplace_get_expert_settings: {
6
+ readonly description: "Retrieves all tenant-wide expert settings for theming: LESS variables, SCSS variables, custom CSS, and custom JavaScript. Also returns whether JavaScript editing is enabled on the server. Requires administrator privileges.";
7
+ readonly inputSchema: {};
8
+ readonly annotations: {
9
+ readonly title: "Get Expert Settings";
10
+ };
11
+ };
12
+ readonly cplace_update_expert_settings: {
13
+ readonly description: "Updates one or more tenant-wide expert settings (LESS, SCSS, CSS, JavaScript). Only provided fields are updated; omitted fields remain unchanged. Send an empty string to clear a setting. Updating LESS or SCSS triggers an asynchronous CSS compilation job — use cplace_get_job to poll compilation status. Requires administrator privileges.";
14
+ readonly inputSchema: {
15
+ readonly less: z.ZodOptional<z.ZodString>;
16
+ readonly scss: z.ZodOptional<z.ZodString>;
17
+ readonly css: z.ZodOptional<z.ZodString>;
18
+ readonly javascript: z.ZodOptional<z.ZodString>;
19
+ };
20
+ readonly annotations: {
21
+ readonly title: "Update Expert Settings";
22
+ };
23
+ };
24
+ readonly cplace_edit_expert_settings: {
25
+ readonly description: "Surgically edit a single expert settings field using str_replace. Finds and replaces exact text within the specified field (LESS, SCSS, CSS, or JavaScript). More token-efficient than full replacement for small changes in large stylesheets or scripts. Updating LESS or SCSS triggers an asynchronous CSS compilation job — use cplace_get_job to poll compilation status. Requires administrator privileges.";
26
+ readonly inputSchema: {
27
+ readonly field: z.ZodEnum<["less", "scss", "css", "javascript"]>;
28
+ readonly old_str: z.ZodString;
29
+ readonly new_str: z.ZodString;
30
+ readonly replace_all: z.ZodOptional<z.ZodBoolean>;
31
+ };
32
+ readonly annotations: {
33
+ readonly title: "Edit Expert Settings";
34
+ };
35
+ };
36
+ };
37
+ export declare function registerExpertSettingsTools(server: McpServer, client: CplaceApiClient): void;
38
+ //# sourceMappingURL=expert-settings.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"expert-settings.d.ts","sourceRoot":"","sources":["../../src/tools/expert-settings.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAW5C,eAAO,MAAM,gCAAgC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA0BnC,CAAC;AAEX,wBAAgB,2BAA2B,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,eAAe,QA0IrF"}
@@ -0,0 +1,145 @@
1
+ import { z } from "zod";
2
+ import { debugLogWithTag } from "../logger.js";
3
+ import { checkResponseSize } from "../utils.js";
4
+ import { applyStrReplace } from '../str-replace-utils.js';
5
+ const TOOL_GET_EXPERT_SETTINGS = 'cplace_get_expert_settings';
6
+ const TOOL_UPDATE_EXPERT_SETTINGS = 'cplace_update_expert_settings';
7
+ const TOOL_EDIT_EXPERT_SETTINGS = 'cplace_edit_expert_settings';
8
+ export const EXPERT_SETTINGS_TOOL_DEFINITIONS = {
9
+ [TOOL_GET_EXPERT_SETTINGS]: {
10
+ description: "Retrieves all tenant-wide expert settings for theming: LESS variables, SCSS variables, custom CSS, and custom JavaScript. Also returns whether JavaScript editing is enabled on the server. Requires administrator privileges.",
11
+ inputSchema: {},
12
+ annotations: { title: "Get Expert Settings" }
13
+ },
14
+ [TOOL_UPDATE_EXPERT_SETTINGS]: {
15
+ description: "Updates one or more tenant-wide expert settings (LESS, SCSS, CSS, JavaScript). Only provided fields are updated; omitted fields remain unchanged. Send an empty string to clear a setting. Updating LESS or SCSS triggers an asynchronous CSS compilation job — use cplace_get_job to poll compilation status. Requires administrator privileges.",
16
+ inputSchema: {
17
+ less: z.string().optional().describe("Custom LESS variables content. Updating triggers async CSS compilation."),
18
+ scss: z.string().optional().describe("Custom SCSS variables content. Updating triggers async CSS compilation."),
19
+ css: z.string().optional().describe("Custom CSS content. Takes effect immediately (no compilation)."),
20
+ javascript: z.string().optional().describe("Custom JavaScript content. Requires server-side JavaScript editing to be enabled. Updates will be rejected if disabled.")
21
+ },
22
+ annotations: { title: "Update Expert Settings" }
23
+ },
24
+ [TOOL_EDIT_EXPERT_SETTINGS]: {
25
+ description: "Surgically edit a single expert settings field using str_replace. Finds and replaces exact text within the specified field (LESS, SCSS, CSS, or JavaScript). More token-efficient than full replacement for small changes in large stylesheets or scripts. Updating LESS or SCSS triggers an asynchronous CSS compilation job — use cplace_get_job to poll compilation status. Requires administrator privileges.",
26
+ inputSchema: {
27
+ field: z.enum(["less", "scss", "css", "javascript"]).describe("The expert settings field to edit. 'javascript' requires server-side JavaScript editing to be enabled."),
28
+ old_str: z.string().describe("The exact string to find in the field content. Must match exactly including whitespace and line breaks."),
29
+ new_str: z.string().describe("The replacement string."),
30
+ replace_all: z.boolean().optional().describe("If true, replace all occurrences. If false (default), requires exactly one match.")
31
+ },
32
+ annotations: { title: "Edit Expert Settings" }
33
+ }
34
+ };
35
+ export function registerExpertSettingsTools(server, client) {
36
+ server.registerTool(TOOL_GET_EXPERT_SETTINGS, EXPERT_SETTINGS_TOOL_DEFINITIONS[TOOL_GET_EXPERT_SETTINGS], async () => {
37
+ debugLogWithTag('EXPERT_SETTINGS', 'Retrieving expert settings');
38
+ try {
39
+ const result = await client.makeApiRequest('json/expert-settings', 'GET');
40
+ const sizeCheck = checkResponseSize(result);
41
+ if (sizeCheck.tooLarge) {
42
+ return {
43
+ content: [{ type: "text", text: `Error: ${sizeCheck.suggestion}` }],
44
+ isError: true
45
+ };
46
+ }
47
+ debugLogWithTag('EXPERT_SETTINGS', 'Successfully retrieved expert settings');
48
+ return {
49
+ content: [{ type: "text", text: JSON.stringify(result, null, 2) }]
50
+ };
51
+ }
52
+ catch (error) {
53
+ return {
54
+ content: [{ type: "text", text: `Error retrieving expert settings: ${error instanceof Error ? error.message : String(error)}` }],
55
+ isError: true
56
+ };
57
+ }
58
+ });
59
+ server.registerTool(TOOL_UPDATE_EXPERT_SETTINGS, EXPERT_SETTINGS_TOOL_DEFINITIONS[TOOL_UPDATE_EXPERT_SETTINGS], async ({ less, scss, css, javascript }) => {
60
+ debugLogWithTag('EXPERT_SETTINGS', 'Updating expert settings');
61
+ const body = {};
62
+ if (less !== undefined)
63
+ body.less = less;
64
+ if (scss !== undefined)
65
+ body.scss = scss;
66
+ if (css !== undefined)
67
+ body.css = css;
68
+ if (javascript !== undefined)
69
+ body.javascript = javascript;
70
+ if (Object.keys(body).length === 0) {
71
+ return {
72
+ content: [{ type: "text", text: "Error: No fields provided. Supply at least one of: less, scss, css, javascript. Use an empty string to clear a setting." }],
73
+ isError: true
74
+ };
75
+ }
76
+ try {
77
+ const result = await client.makeApiRequest('json/expert-settings', 'PATCH', undefined, body);
78
+ const updatedFields = result.updated || Object.keys(body);
79
+ let response = `Successfully updated expert settings: ${updatedFields.join(', ')}`;
80
+ if (result.lessCompilationJobId) {
81
+ response += `\nLESS compilation job started: ${result.lessCompilationJobId} (use cplace_get_job to check status)`;
82
+ }
83
+ if (result.scssCompilationJobId) {
84
+ response += `\nSCSS compilation job started: ${result.scssCompilationJobId} (use cplace_get_job to check status)`;
85
+ }
86
+ debugLogWithTag('EXPERT_SETTINGS', `Successfully updated fields: ${updatedFields.join(', ')}`);
87
+ return {
88
+ content: [{ type: "text", text: response }]
89
+ };
90
+ }
91
+ catch (error) {
92
+ return {
93
+ content: [{ type: "text", text: `Error updating expert settings: ${error instanceof Error ? error.message : String(error)}` }],
94
+ isError: true
95
+ };
96
+ }
97
+ });
98
+ server.registerTool(TOOL_EDIT_EXPERT_SETTINGS, EXPERT_SETTINGS_TOOL_DEFINITIONS[TOOL_EDIT_EXPERT_SETTINGS], async ({ field, old_str, new_str, replace_all = false }) => {
99
+ debugLogWithTag('EXPERT_SETTINGS', `Editing expert settings field '${field}'`);
100
+ try {
101
+ const settings = await client.makeApiRequest('json/expert-settings', 'GET');
102
+ const currentContent = settings[field];
103
+ if (currentContent === undefined || currentContent === null) {
104
+ return {
105
+ content: [{ type: "text", text: `Error: Field '${field}' is not available. ${field === 'javascript' ? 'JavaScript editing may be disabled on the server.' : 'The field has no content.'}` }],
106
+ isError: true
107
+ };
108
+ }
109
+ if (currentContent === '') {
110
+ return {
111
+ content: [{ type: "text", text: `Error: Field '${field}' is empty. Use cplace_update_expert_settings to set initial content.` }],
112
+ isError: true
113
+ };
114
+ }
115
+ const result = applyStrReplace(currentContent, old_str, new_str, replace_all);
116
+ if (!result.success) {
117
+ return {
118
+ content: [{ type: "text", text: `Error: ${result.error}` }],
119
+ isError: true
120
+ };
121
+ }
122
+ const patchBody = { [field]: result.newContent };
123
+ const patchResult = await client.makeApiRequest('json/expert-settings', 'PATCH', undefined, patchBody);
124
+ let response = `Successfully edited '${field}'. Replaced ${result.replacementCount} occurrence(s).`;
125
+ if (patchResult.lessCompilationJobId) {
126
+ response += `\nLESS compilation job started: ${patchResult.lessCompilationJobId} (use cplace_get_job to check status)`;
127
+ }
128
+ if (patchResult.scssCompilationJobId) {
129
+ response += `\nSCSS compilation job started: ${patchResult.scssCompilationJobId} (use cplace_get_job to check status)`;
130
+ }
131
+ debugLogWithTag('EXPERT_SETTINGS', `Successfully edited '${field}' (${result.replacementCount} replacement(s))`);
132
+ return {
133
+ content: [{ type: "text", text: response }]
134
+ };
135
+ }
136
+ catch (error) {
137
+ debugLogWithTag('EXPERT_SETTINGS', `Error: ${error instanceof Error ? error.message : String(error)}`);
138
+ return {
139
+ content: [{ type: "text", text: `Error editing expert settings: ${error instanceof Error ? error.message : String(error)}` }],
140
+ isError: true
141
+ };
142
+ }
143
+ });
144
+ }
145
+ //# sourceMappingURL=expert-settings.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"expert-settings.js","sourceRoot":"","sources":["../../src/tools/expert-settings.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,e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AAC,CAAC;YACjH,OAAO;gBACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAe,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;aACrD,CAAC;QACJ,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,eAAe,CAAC,iBAAiB,EAAE,UAAU,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;YACvG,OAAO;gBACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAe,EAAE,IAAI,EAAE,kCAAkC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,EAAE,CAAC;gBACtI,OAAO,EAAE,IAAI;aACd,CAAC;QACJ,CAAC;IACH,CAAC,CACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,16 @@
1
+ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
+ import { z } from "zod";
3
+ import { CplaceApiClient } from '../api.js';
4
+ export declare const JOB_SCHEDULE_TRIGGER_TOOL_DEFINITIONS: {
5
+ readonly cplace_trigger_job_schedule: {
6
+ readonly description: "Trigger manual execution of a Low-Code Job schedule. Accepts the UID of a job schedule page, validates it, and starts the referenced job script asynchronously. Returns a job ID that can be monitored with cplace_get_job. Use this to run scheduled jobs on-demand without waiting for the next cron cycle.";
7
+ readonly inputSchema: {
8
+ readonly pageUID: z.ZodString;
9
+ };
10
+ readonly annotations: {
11
+ readonly title: "Trigger Job Schedule";
12
+ };
13
+ };
14
+ };
15
+ export declare function registerJobScheduleTriggerTools(server: McpServer, client: CplaceApiClient): void;
16
+ //# sourceMappingURL=job-schedule-trigger.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"job-schedule-trigger.d.ts","sourceRoot":"","sources":["../../src/tools/job-schedule-trigger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAK5C,eAAO,MAAM,qCAAqC;;;;;;;;;;CAQxC,CAAC;AAEX,wBAAgB,+BAA+B,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,eAAe,QA2BzF"}
@@ -0,0 +1,32 @@
1
+ import { z } from "zod";
2
+ import { debugLogWithTag } from "../logger.js";
3
+ const TOOL_TRIGGER_JOB_SCHEDULE = 'cplace_trigger_job_schedule';
4
+ export const JOB_SCHEDULE_TRIGGER_TOOL_DEFINITIONS = {
5
+ [TOOL_TRIGGER_JOB_SCHEDULE]: {
6
+ description: "Trigger manual execution of a Low-Code Job schedule. Accepts the UID of a job schedule page, validates it, and starts the referenced job script asynchronously. Returns a job ID that can be monitored with cplace_get_job. Use this to run scheduled jobs on-demand without waiting for the next cron cycle.",
7
+ inputSchema: {
8
+ pageUID: z.string().describe("The UID of the job schedule page to trigger (e.g., 'page/abc123def456')")
9
+ },
10
+ annotations: { title: "Trigger Job Schedule" }
11
+ }
12
+ };
13
+ export function registerJobScheduleTriggerTools(server, client) {
14
+ server.registerTool(TOOL_TRIGGER_JOB_SCHEDULE, JOB_SCHEDULE_TRIGGER_TOOL_DEFINITIONS[TOOL_TRIGGER_JOB_SCHEDULE], async ({ pageUID }) => {
15
+ debugLogWithTag('JOB_SCHEDULE_TRIGGER', `Triggering job schedule: ${pageUID}`);
16
+ try {
17
+ const result = await client.makeApiRequest('json/job-schedule/trigger', 'POST', undefined, { pageUID });
18
+ debugLogWithTag('JOB_SCHEDULE_TRIGGER', `Successfully triggered job schedule: ${pageUID}`);
19
+ return {
20
+ content: [{ type: "text", text: JSON.stringify(result, null, 2) }]
21
+ };
22
+ }
23
+ catch (error) {
24
+ debugLogWithTag('JOB_SCHEDULE_TRIGGER', `Error: ${error instanceof Error ? error.message : String(error)}`);
25
+ return {
26
+ content: [{ type: "text", text: `Error triggering job schedule: ${error instanceof Error ? error.message : String(error)}` }],
27
+ isError: true
28
+ };
29
+ }
30
+ });
31
+ }
32
+ //# sourceMappingURL=job-schedule-trigger.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"job-schedule-trigger.js","sourceRoot":"","sources":["../../src/tools/job-schedule-trigger.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAE/C,MAAM,yBAAyB,GAAG,6BAA6B,CAAC;AAEhE,MAAM,CAAC,MAAM,qCAAqC,GAAG;IACnD,CAAC,yBAAyB,CAAC,EAAE;QAC3B,WAAW,EAAE,+SAA+S;QAC5T,WAAW,EAAE;YACX,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,yEAAyE,CAAC;SACxG;QACD,WAAW,EAAE,EAAE,KAAK,EAAE,sBAAsB,EAAE;KAC/C;CACO,CAAC;AAEX,MAAM,UAAU,+BAA+B,CAAC,MAAiB,EAAE,MAAuB;IACxF,MAAM,CAAC,YAAY,CAAC,yBAAyB,EAC3C,qCAAqC,CAAC,yBAAyB,CAAC,EAChE,KAAK,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE;QACpB,eAAe,CAAC,sBAAsB,EAAE,4BAA4B,OAAO,EAAE,CAAC,CAAC;QAE/E,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,cAAc,CACxC,2BAA2B,EAC3B,MAAM,EACN,SAAS,EACT,EAAE,OAAO,EAAE,CACZ,CAAC;YAEF,eAAe,CAAC,sBAAsB,EAAE,wCAAwC,OAAO,EAAE,CAAC,CAAC;YAC3F,OAAO;gBACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC;aACnE,CAAC;QACJ,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,eAAe,CAAC,sBAAsB,EAAE,UAAU,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;YAC5G,OAAO;gBACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,kCAAkC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,EAAE,CAAC;gBAC7H,OAAO,EAAE,IAAI;aACd,CAAC;QACJ,CAAC;IACH,CAAC,CACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,58 @@
1
+ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
+ import { z } from "zod";
3
+ import { CplaceApiClient } from '../api.js';
4
+ export declare const JOB_SCRIPTS_TOOL_DEFINITIONS: {
5
+ readonly cplace_get_job_scripts: {
6
+ readonly description: "Get all Low-Code Job scripts in a workspace. Job scripts define the logic for scheduled or manually triggered jobs. Returns script code, enabled status, job configuration (category, enqueue mode, reschedulable), and metadata for each script.";
7
+ readonly inputSchema: {
8
+ readonly workspaceId: z.ZodString;
9
+ };
10
+ readonly annotations: {
11
+ readonly title: "Get Job Scripts";
12
+ };
13
+ };
14
+ readonly cplace_manage_job_script: {
15
+ readonly description: "Create or update a Low-Code Job script entity. Job scripts define JavaScript logic for scheduled or manually triggered jobs. For create: workspaceId, identifier, and script are required. For update: workspaceId and identifier are required, all other fields are optional.";
16
+ readonly inputSchema: {
17
+ readonly operation: z.ZodEnum<["create", "update"]>;
18
+ readonly workspaceId: z.ZodString;
19
+ readonly identifier: z.ZodString;
20
+ readonly script: z.ZodOptional<z.ZodString>;
21
+ readonly localizedNames: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
22
+ readonly description: z.ZodOptional<z.ZodString>;
23
+ readonly enabled: z.ZodOptional<z.ZodBoolean>;
24
+ readonly contextPageId: z.ZodOptional<z.ZodString>;
25
+ readonly jobCategory: z.ZodOptional<z.ZodString>;
26
+ readonly jobCategoryEnqueueMode: z.ZodOptional<z.ZodString>;
27
+ readonly isReschedulable: z.ZodOptional<z.ZodBoolean>;
28
+ };
29
+ readonly annotations: {
30
+ readonly title: "Manage Job Script";
31
+ };
32
+ };
33
+ readonly cplace_edit_job_script: {
34
+ readonly description: "Edit a job script using str_replace — find an exact text match and replace it. Reads the current script, applies the replacement, and writes back. Use this instead of cplace_manage_job_script when making small changes to avoid reproducing the entire script.";
35
+ readonly inputSchema: {
36
+ readonly workspaceId: z.ZodString;
37
+ readonly identifier: z.ZodString;
38
+ readonly old_str: z.ZodString;
39
+ readonly new_str: z.ZodString;
40
+ readonly replace_all: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
41
+ };
42
+ readonly annotations: {
43
+ readonly title: "Edit Job Script";
44
+ };
45
+ };
46
+ readonly cplace_delete_job_script: {
47
+ readonly description: "Delete a job script from a workspace. This permanently removes the script — any scheduled jobs referencing it will no longer execute.";
48
+ readonly inputSchema: {
49
+ readonly workspaceId: z.ZodString;
50
+ readonly identifier: z.ZodString;
51
+ };
52
+ readonly annotations: {
53
+ readonly title: "Delete Job Script";
54
+ };
55
+ };
56
+ };
57
+ export declare function registerJobScriptsTools(server: McpServer, client: CplaceApiClient): void;
58
+ //# sourceMappingURL=job-scripts.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"job-scripts.d.ts","sourceRoot":"","sources":["../../src/tools/job-scripts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAW5C,eAAO,MAAM,4BAA4B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4C/B,CAAC;AAEX,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,eAAe,QAoNjF"}
@@ -0,0 +1,215 @@
1
+ import { z } from "zod";
2
+ import { debugLogWithTag } from "../logger.js";
3
+ import { applyStrReplace } from '../str-replace-utils.js';
4
+ const TOOL_GET_JOB_SCRIPTS = 'cplace_get_job_scripts';
5
+ const TOOL_MANAGE_JOB_SCRIPT = 'cplace_manage_job_script';
6
+ const TOOL_EDIT_JOB_SCRIPT = 'cplace_edit_job_script';
7
+ const TOOL_DELETE_JOB_SCRIPT = 'cplace_delete_job_script';
8
+ export const JOB_SCRIPTS_TOOL_DEFINITIONS = {
9
+ [TOOL_GET_JOB_SCRIPTS]: {
10
+ description: "Get all Low-Code Job scripts in a workspace. Job scripts define the logic for scheduled or manually triggered jobs. Returns script code, enabled status, job configuration (category, enqueue mode, reschedulable), and metadata for each script.",
11
+ inputSchema: {
12
+ workspaceId: z.string().describe("The workspace ID (e.g., 'workspace/abc123')")
13
+ },
14
+ annotations: { title: "Get Job Scripts" }
15
+ },
16
+ [TOOL_MANAGE_JOB_SCRIPT]: {
17
+ description: "Create or update a Low-Code Job script entity. Job scripts define JavaScript logic for scheduled or manually triggered jobs. For create: workspaceId, identifier, and script are required. For update: workspaceId and identifier are required, all other fields are optional.",
18
+ inputSchema: {
19
+ operation: z.enum(["create", "update"]).describe("Operation type: 'create' for new job scripts, 'update' for existing job scripts"),
20
+ workspaceId: z.string().describe("Required: Target workspace ID (e.g., 'workspace/abc123')"),
21
+ identifier: z.string().describe("Required: Unique identifier for the job script within the workspace"),
22
+ script: z.string().optional().describe("⚠️ REQUIRED for create: JavaScript code for the job script. Review cplace Low-Code documentation before writing job scripts."),
23
+ localizedNames: z.record(z.string()).optional().describe("Optional: Localized display names (e.g., {\"en\": \"My Job\", \"de\": \"Mein Job\"})"),
24
+ description: z.string().optional().describe("Optional: Description of the job script (empty string clears it on update)"),
25
+ enabled: z.boolean().optional().describe("For update only: Enable/disable the job script"),
26
+ contextPageId: z.string().optional().describe("Optional: Context page ID for job execution"),
27
+ jobCategory: z.string().optional().describe("Optional: Job category name for grouping related jobs"),
28
+ jobCategoryEnqueueMode: z.string().optional().describe("Optional: How jobs in the same category are enqueued (e.g., 'PARALLEL')"),
29
+ isReschedulable: z.boolean().optional().describe("Optional: Whether the job can be rescheduled after execution")
30
+ },
31
+ annotations: { title: "Manage Job Script" }
32
+ },
33
+ [TOOL_EDIT_JOB_SCRIPT]: {
34
+ description: "Edit a job script using str_replace — find an exact text match and replace it. Reads the current script, applies the replacement, and writes back. Use this instead of cplace_manage_job_script when making small changes to avoid reproducing the entire script.",
35
+ inputSchema: {
36
+ workspaceId: z.string().describe("The workspace ID (e.g., 'workspace/abc123')"),
37
+ identifier: z.string().describe("The unique identifier of the job script to edit"),
38
+ old_str: z.string().describe("The exact text to find in the job script (must match exactly, including whitespace and line breaks)"),
39
+ new_str: z.string().describe("The replacement text. Use empty string to delete the matched text."),
40
+ replace_all: z.boolean().optional().default(false).describe("If true, replace all occurrences of old_str. If false (default), fails when old_str matches more than once.")
41
+ },
42
+ annotations: { title: "Edit Job Script" }
43
+ },
44
+ [TOOL_DELETE_JOB_SCRIPT]: {
45
+ description: "Delete a job script from a workspace. This permanently removes the script — any scheduled jobs referencing it will no longer execute.",
46
+ inputSchema: {
47
+ workspaceId: z.string().describe("The workspace ID (e.g., 'workspace/abc123')"),
48
+ identifier: z.string().describe("The unique identifier of the job script to delete")
49
+ },
50
+ annotations: { title: "Delete Job Script" }
51
+ }
52
+ };
53
+ export function registerJobScriptsTools(server, client) {
54
+ server.registerTool(TOOL_GET_JOB_SCRIPTS, JOB_SCRIPTS_TOOL_DEFINITIONS[TOOL_GET_JOB_SCRIPTS], async ({ workspaceId }) => {
55
+ try {
56
+ const result = await client.makeApiRequest('json/job-scripts', 'GET', { workspaceId });
57
+ return {
58
+ content: [{ type: "text", text: JSON.stringify(result, null, 2) }]
59
+ };
60
+ }
61
+ catch (error) {
62
+ return {
63
+ content: [{ type: "text", text: `Error retrieving job scripts: ${error instanceof Error ? error.message : String(error)}` }],
64
+ isError: true
65
+ };
66
+ }
67
+ });
68
+ server.registerTool(TOOL_MANAGE_JOB_SCRIPT, JOB_SCRIPTS_TOOL_DEFINITIONS[TOOL_MANAGE_JOB_SCRIPT], async (params) => {
69
+ try {
70
+ if (params.operation === "create") {
71
+ if (!params.script) {
72
+ return {
73
+ content: [{ type: "text", text: "Error: Create operation requires the script parameter" }],
74
+ isError: true
75
+ };
76
+ }
77
+ const requestBody = {
78
+ workspaceId: params.workspaceId,
79
+ identifier: params.identifier,
80
+ script: params.script
81
+ };
82
+ if (params.localizedNames) {
83
+ requestBody.localizedNames = params.localizedNames;
84
+ }
85
+ if (params.description) {
86
+ requestBody.description = params.description;
87
+ }
88
+ if (params.contextPageId) {
89
+ requestBody.contextPageId = params.contextPageId;
90
+ }
91
+ if (params.jobCategory) {
92
+ requestBody.jobCategory = params.jobCategory;
93
+ }
94
+ if (params.jobCategoryEnqueueMode) {
95
+ requestBody.jobCategoryEnqueueMode = params.jobCategoryEnqueueMode;
96
+ }
97
+ if (params.isReschedulable !== undefined) {
98
+ requestBody.isReschedulable = params.isReschedulable;
99
+ }
100
+ const result = await client.makeApiRequest('json/job-script', 'POST', undefined, requestBody);
101
+ return {
102
+ content: [{ type: "text", text: JSON.stringify(result, null, 2) }]
103
+ };
104
+ }
105
+ else {
106
+ const requestBody = {
107
+ workspaceId: params.workspaceId,
108
+ scriptIdentifier: params.identifier
109
+ };
110
+ if (params.script !== undefined) {
111
+ requestBody.script = params.script;
112
+ }
113
+ if (params.enabled !== undefined) {
114
+ requestBody.enabled = params.enabled;
115
+ }
116
+ if (params.localizedNames !== undefined) {
117
+ requestBody.localizedNames = params.localizedNames;
118
+ }
119
+ if (params.description !== undefined) {
120
+ requestBody.description = params.description;
121
+ }
122
+ if (params.contextPageId !== undefined) {
123
+ requestBody.contextPageId = params.contextPageId;
124
+ }
125
+ if (params.jobCategory !== undefined) {
126
+ requestBody.jobCategory = params.jobCategory;
127
+ }
128
+ if (params.jobCategoryEnqueueMode !== undefined) {
129
+ requestBody.jobCategoryEnqueueMode = params.jobCategoryEnqueueMode;
130
+ }
131
+ if (params.isReschedulable !== undefined) {
132
+ requestBody.isReschedulable = params.isReschedulable;
133
+ }
134
+ const result = await client.makeApiRequest('json/job-script', 'PATCH', undefined, requestBody);
135
+ return {
136
+ content: [{ type: "text", text: JSON.stringify(result, null, 2) }]
137
+ };
138
+ }
139
+ }
140
+ catch (error) {
141
+ const operationText = params.operation === "create" ? "creating" : "updating";
142
+ return {
143
+ content: [{ type: "text", text: `Error ${operationText} job script: ${error instanceof Error ? error.message : String(error)}` }],
144
+ isError: true
145
+ };
146
+ }
147
+ });
148
+ server.registerTool(TOOL_EDIT_JOB_SCRIPT, JOB_SCRIPTS_TOOL_DEFINITIONS[TOOL_EDIT_JOB_SCRIPT], async ({ workspaceId, identifier, old_str, new_str, replace_all = false }) => {
149
+ debugLogWithTag('EDIT_JOB_SCRIPT', `Editing job script '${identifier}'`);
150
+ try {
151
+ const allScripts = await client.makeApiRequest('json/job-scripts', 'GET', {
152
+ workspaceId
153
+ });
154
+ const scripts = allScripts.data || [];
155
+ const script = scripts.find((s) => s.identifier === identifier);
156
+ if (!script) {
157
+ const availableIds = scripts.map((s) => s.identifier).join(', ');
158
+ return {
159
+ content: [{ type: "text", text: `Error: Job script '${identifier}' not found in workspace. Available identifiers: ${availableIds || '(none)'}` }],
160
+ isError: true
161
+ };
162
+ }
163
+ const currentScript = script.script;
164
+ if (currentScript === undefined || currentScript === null || currentScript === '') {
165
+ return {
166
+ content: [{ type: "text", text: `Error: Job script '${identifier}' has no script content.` }],
167
+ isError: true
168
+ };
169
+ }
170
+ const result = applyStrReplace(currentScript, old_str, new_str, replace_all);
171
+ if (!result.success) {
172
+ return {
173
+ content: [{ type: "text", text: `Error: ${result.error}` }],
174
+ isError: true
175
+ };
176
+ }
177
+ await client.makeApiRequest('json/job-script', 'PATCH', undefined, {
178
+ workspaceId,
179
+ scriptIdentifier: identifier,
180
+ script: result.newContent
181
+ });
182
+ debugLogWithTag('EDIT_JOB_SCRIPT', `Successfully edited job script '${identifier}' (${result.replacementCount} replacement(s))`);
183
+ return {
184
+ content: [{ type: "text", text: `Successfully edited job script '${identifier}'. Replaced ${result.replacementCount} occurrence(s).` }]
185
+ };
186
+ }
187
+ catch (error) {
188
+ debugLogWithTag('EDIT_JOB_SCRIPT', `Error: ${error instanceof Error ? error.message : String(error)}`);
189
+ return {
190
+ content: [{ type: "text", text: `Error editing job script: ${error instanceof Error ? error.message : String(error)}` }],
191
+ isError: true
192
+ };
193
+ }
194
+ });
195
+ server.registerTool(TOOL_DELETE_JOB_SCRIPT, JOB_SCRIPTS_TOOL_DEFINITIONS[TOOL_DELETE_JOB_SCRIPT], async ({ workspaceId, identifier }) => {
196
+ debugLogWithTag('JOB_SCRIPT_DELETE', `Deleting job script '${identifier}'`);
197
+ try {
198
+ const result = await client.makeApiRequest('json/job-script', 'DELETE', {
199
+ workspaceId,
200
+ identifier
201
+ });
202
+ debugLogWithTag('JOB_SCRIPT_DELETE', `Successfully deleted job script '${identifier}'`);
203
+ return {
204
+ content: [{ type: "text", text: JSON.stringify(result, null, 2) }]
205
+ };
206
+ }
207
+ catch (error) {
208
+ return {
209
+ content: [{ type: "text", text: `Error deleting job script: ${error instanceof Error ? error.message : String(error)}` }],
210
+ isError: true
211
+ };
212
+ }
213
+ });
214
+ }
215
+ //# sourceMappingURL=job-scripts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"job-scripts.js","sourceRoot":"","sources":["../../src/tools/job-scripts.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO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,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,EAAE,CAAC;gBACzH,OAAO,EAAE,IAAI;aACd,CAAC;QACJ,CAAC;IACH,CAAC,CACF,CAAC;AACJ,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"layout-richstring-widgets.d.ts","sourceRoot":"","sources":["../../src/tools/layout-richstring-widgets.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAoL5C,eAAO,MAAM,yCAAyC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAsE5C,CAAC;AAMX,wBAAgB,mCAAmC,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,eAAe,QAoJ7F"}
1
+ {"version":3,"file":"layout-richstring-widgets.d.ts","sourceRoot":"","sources":["../../src/tools/layout-richstring-widgets.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAyH5C,eAAO,MAAM,yCAAyC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAsE5C,CAAC;AAMX,wBAAgB,mCAAmC,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,eAAe,QAoJ7F"}
@@ -1,6 +1,7 @@
1
1
  import { z } from "zod";
2
2
  import { debugLogWithTag } from "../logger.js";
3
3
  import { LayoutContextSchema } from './layout.js';
4
+ import { findWidgetById, buildUpdateRequestBody, determineApiEndpoint, buildRequestParams } from './widget-tool-helpers.js';
4
5
  import { richstringInsertWidget, richstringUpdateWidget, richstringDeleteWidget, richstringExtractWidgets, buildContentMap } from './richstring-widgets.js';
5
6
  const TOOL_LAYOUT_RICHSTRING_INSERT_WIDGET = 'cplace_layout_richstring_insert_widget';
6
7
  const TOOL_LAYOUT_RICHSTRING_UPDATE_WIDGET = 'cplace_layout_richstring_update_widget';
@@ -10,48 +11,6 @@ const RICHSTRING_WIDGET_TYPES = [
10
11
  'cf.platform.richString',
11
12
  'cf.cplace.demoWidgets.demoRichString'
12
13
  ];
13
- function determineApiEndpoint(context) {
14
- return context.type === "page" ? "json/pageLayout" : "json/typeLayout";
15
- }
16
- function buildRequestParams(context) {
17
- if (context.type === "page") {
18
- return { pageUID: context.pageUID };
19
- }
20
- else {
21
- return {
22
- workspaceId: context.workspaceId,
23
- typeInternalName: context.typeInternalName,
24
- ...(context.alternativeLayoutName && { alternativeLayoutName: context.alternativeLayoutName })
25
- };
26
- }
27
- }
28
- function buildUpdateRequestBody(context, widgetId, newConfiguration) {
29
- return {
30
- ...buildRequestParams(context),
31
- operation: {
32
- type: "UPDATE",
33
- widgetId,
34
- newConfiguration
35
- }
36
- };
37
- }
38
- function findWidgetById(rows, widgetId) {
39
- for (const row of rows || []) {
40
- for (const column of row.columns || []) {
41
- for (const widget of column.widgets || []) {
42
- if (widget.id === widgetId) {
43
- return widget;
44
- }
45
- if (widget.widgetsLayout?.rows) {
46
- const nested = findWidgetById(widget.widgetsLayout.rows, widgetId);
47
- if (nested)
48
- return nested;
49
- }
50
- }
51
- }
52
- }
53
- return null;
54
- }
55
14
  function extractStringConfigValue(configuration, configAttribute) {
56
15
  if (!configuration)
57
16
  return '';