Skip to content

Commit 3165397

Browse files
refactor: update validation logic to allow multiple actions in tools
- Modified validation checks in various tools (cms, comments, components, deAsset, deComponents, deElement, dePages, deStyle, deVariable, enterprise, scripts, sites) to require at least one action instead of exactly one. - Updated error messages to reflect the new validation criteria, enhancing user guidance for input requirements.
1 parent f53e470 commit 3165397

13 files changed

Lines changed: 152 additions & 128 deletions

src/tools/cms.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -478,10 +478,10 @@ export function registerCmsTools(
478478
d.update_collection_items,
479479
d.publish_collection_items,
480480
d.delete_collection_items,
481-
].filter(Boolean).length === 1,
481+
].filter(Boolean).length >= 1,
482482
{
483483
message:
484-
"Provide exactly one of get_collection_list, get_collection_details, create_collection, create_collection_static_field, create_collection_option_field, create_collection_reference_field, update_collection_field, list_collection_items, create_collection_items, update_collection_items, publish_collection_items, delete_collection_items.",
484+
"Provide at least one of get_collection_list, get_collection_details, create_collection, create_collection_static_field, create_collection_option_field, create_collection_reference_field, update_collection_field, list_collection_items, create_collection_items, update_collection_items, publish_collection_items, delete_collection_items.",
485485
}
486486
)
487487
),

src/tools/comments.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -260,10 +260,10 @@ export function registerCommentsTools(
260260
d.list_comment_threads,
261261
d.get_comment_thread,
262262
d.list_comment_replies,
263-
].filter(Boolean).length === 1,
263+
].filter(Boolean).length >= 1,
264264
{
265265
message:
266-
"Provide exactly one of list_comment_threads, get_comment_thread, list_comment_replies.",
266+
"Provide at least one of list_comment_threads, get_comment_thread, list_comment_replies.",
267267
}
268268
)
269269
)

src/tools/components.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -260,10 +260,10 @@ export function registerComponentsTools(
260260
d.update_component_content,
261261
d.get_component_properties,
262262
d.update_component_properties,
263-
].filter(Boolean).length === 1,
263+
].filter(Boolean).length >= 1,
264264
{
265265
message:
266-
"Provide exactly one of list_components, get_component_content, update_component_content, get_component_properties, update_component_properties.",
266+
"Provide at least one of list_components, get_component_content, update_component_content, get_component_properties, update_component_properties.",
267267
}
268268
)
269269
),

src/tools/deAsset.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,10 @@ export function registerDEAssetTools(server: McpServer, rpc: RPCType) {
9797
d.create_folder,
9898
d.get_all_assets_and_folders,
9999
d.update_asset,
100-
].filter(Boolean).length === 1,
100+
].filter(Boolean).length >= 1,
101101
{
102102
message:
103-
"Provide exactly one of create_folder, get_all_assets_and_folders, update_asset.",
103+
"Provide at least one of create_folder, get_all_assets_and_folders, update_asset.",
104104
}
105105
)
106106
),

src/tools/deComponents.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,10 @@ export function registerDEComponentsTools(server: McpServer, rpc: RPCType) {
9595
d.close_component_view,
9696
d.get_all_components,
9797
d.rename_component,
98-
].filter(Boolean).length === 1,
98+
].filter(Boolean).length >= 1,
9999
{
100100
message:
101-
"Provide exactly one of check_if_inside_component_view, transform_element_to_component, insert_component_instance, open_component_view, close_component_view, get_all_components, rename_component.",
101+
"Provide at least one of check_if_inside_component_view, transform_element_to_component, insert_component_instance, open_component_view, close_component_view, get_all_components, rename_component.",
102102
}
103103
)
104104
),

src/tools/deElement.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -262,10 +262,10 @@ export const registerDEElementTools = (server: McpServer, rpc: RPCType) => {
262262
d.set_link,
263263
d.set_heading_level,
264264
d.set_image_asset,
265-
].filter(Boolean).length === 1,
265+
].filter(Boolean).length >= 1,
266266
{
267267
message:
268-
"Provide exactly one of get_all_elements, get_selected_element, select_element, add_or_update_attribute, remove_attribute, update_id_attribute, set_text, set_style, set_link, set_heading_level, set_image_asset.",
268+
"Provide at least one of get_all_elements, get_selected_element, select_element, add_or_update_attribute, remove_attribute, update_id_attribute, set_text, set_style, set_link, set_heading_level, set_image_asset.",
269269
}
270270
)
271271
),

src/tools/dePages.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,10 @@ export function registerDEPagesTools(server: McpServer, rpc: RPCType) {
8484
d.create_page_folder,
8585
d.get_current_page,
8686
d.switch_page,
87-
].filter(Boolean).length === 1,
87+
].filter(Boolean).length >= 1,
8888
{
8989
message:
90-
"Provide exactly one of create_page, create_page_folder, get_current_page, switch_page.",
90+
"Provide at least one of create_page, create_page_folder, get_current_page, switch_page.",
9191
}
9292
)
9393
),

src/tools/deStyle.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,10 +154,10 @@ export function registerDEStyleTools(server: McpServer, rpc: RPCType) {
154154
.refine(
155155
(d) =>
156156
[d.create_style, d.get_styles, d.update_style].filter(Boolean)
157-
.length === 1,
157+
.length >= 1,
158158
{
159159
message:
160-
"Provide exactly one of create_style, get_styles, update_style.",
160+
"Provide at least one of create_style, get_styles, update_style.",
161161
}
162162
)
163163
),

src/tools/deVariable.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,10 +228,10 @@ export function registerDEVariableTools(server: McpServer, rpc: RPCType) {
228228
d.update_number_variable,
229229
d.update_percentage_variable,
230230
d.update_font_family_variable,
231-
].filter(Boolean).length === 1,
231+
].filter(Boolean).length >= 1,
232232
{
233233
message:
234-
"Provide exactly one of create_variable_collection, create_variable_mode, get_variable_collections, get_variables, create_color_variable, create_size_variable, create_number_variable, create_percentage_variable, create_font_family_variable, update_color_variable, update_size_variable, update_number_variable, update_percentage_variable, update_font_family_variable.",
234+
"Provide at least one of create_variable_collection, create_variable_mode, get_variable_collections, get_variables, create_color_variable, create_size_variable, create_number_variable, create_percentage_variable, create_font_family_variable, update_color_variable, update_size_variable, update_number_variable, update_percentage_variable, update_font_family_variable.",
235235
}
236236
)
237237
),

src/tools/enterprise.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -436,10 +436,10 @@ export function registerEnterpriseTools(
436436
d.delete_robots_txt,
437437
d.add_well_known_file,
438438
d.remove_well_known_files,
439-
].filter(Boolean).length === 1,
439+
].filter(Boolean).length >= 1,
440440
{
441441
message:
442-
"Provide exactly one of list_301_redirects, create_301_redirect, update_301_redirect, delete_301_redirect, get_robots_txt, update_robots_txt, replace_robots_txt, delete_robots_txt, add_well_known_file, remove_well_known_files.",
442+
"Provide at least one of list_301_redirects, create_301_redirect, update_301_redirect, delete_301_redirect, get_robots_txt, update_robots_txt, replace_robots_txt, delete_robots_txt, add_well_known_file, remove_well_known_files.",
443443
}
444444
)
445445
)

0 commit comments

Comments
 (0)