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
54 changes: 53 additions & 1 deletion src/tools/deComponents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,55 @@ export function registerDEComponentsTools(
.describe(
"Unregister a component. DANGEROUS ACTION. USE WITH CAUTION.",
),
set_component_instance_props: z
.object({
...DEElementIDSchema,
overrides: z
.array(
z.object({
prop_id: z
.string()
.describe(
"The id of the prop on the component definition. Matches Designer SDK propId.",
),
value: z
.any()
Comment on lines +255 to +256
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think z.any() allows undefined, functions, ect... Is that the behavior that we want or would something like this be better here?

z.union([
  z.string(), z.number(), z.boolean(), z.null(),
  z.record(z.unknown()),
])

.describe(
"Value to set for this prop on the instance. Static primitive (string/number/boolean) or object for bindings. Pass null to reset this prop to its component default.",
),
}),
)
.min(1)
.describe(
"Per-instance prop overrides to apply. Wraps Designer SDK ComponentElement.setProps.",
),
})
.optional()
.describe(
"Set per-instance property overrides on a component instance (e.g., a Heading instance's Text prop, a Button instance's label). Only affects the target instance; does not change component defaults or other instances.",
),
get_component_instance_props: z
.object({
...DEElementIDSchema,
resolved: z
.boolean()
.optional()
.describe(
"If true, return resolved prop values (bindings converted to final output). Defaults to false, which returns raw prop entries including a hasOverride flag per prop.",
),
})
.optional()
.describe(
"Get per-instance prop values on a component instance. Wraps Designer SDK ComponentElement.getProps / getResolvedProps.",
),
reset_component_instance_props: z
.object({
...DEElementIDSchema,
})
.optional()
.describe(
"Reset all per-instance prop overrides on a component instance back to component defaults. Wraps Designer SDK ComponentElement.resetAllProps.",
),
})
.strict()
.refine(
Expand All @@ -257,10 +306,13 @@ export function registerDEComponentsTools(
d.set_component_metadata,
d.rename_component,
d.unregister_component,
d.set_component_instance_props,
d.get_component_instance_props,
d.reset_component_instance_props,
].filter(Boolean).length >= 1,
{
message:
"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, get_component, get_component_metadata, set_component_metadata, rename_component, unregister_component.",
"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, get_component, get_component_metadata, set_component_metadata, rename_component, unregister_component, set_component_instance_props, get_component_instance_props, reset_component_instance_props.",
},
),
),
Expand Down
3 changes: 3 additions & 0 deletions src/tools/rules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ export function registerRulesTools(server: McpServer) {
`-- To close a component view and return to page view, use de_component_tool > close_component_view.\n` +
`-- To rename a component, use de_component_tool > rename_component. Pass component_id and new_name.\n` +
`-- To check if you are currently inside a component view, use de_component_tool > check_if_inside_component_view.\n` +
`-- To set per-instance property overrides on a component instance (e.g., a Heading instance's Text prop, a Button instance's label), use de_component_tool > set_component_instance_props. Pass the instance element id and an overrides array of { prop_id, value } entries. value may be a static primitive (string/number/boolean), a binding object, or null to reset a single prop to its component default. This only affects the targeted instance — it does not change component defaults or other instances. Prefer this over element_tool > set_text for props on component instances.\n` +
`-- To read per-instance prop values on a component instance, use de_component_tool > get_component_instance_props. Pass the instance element id. Optionally set resolved=true to get resolved values (bindings converted); default returns raw prop entries including a hasOverride flag per prop.\n` +
`-- To clear all per-instance overrides on a component instance back to component defaults, use de_component_tool > reset_component_instance_props. Pass the instance element id.\n` +
`\n` +
`Element Snapshot Tool Usage:\n` +
`-- To get a visual snapshot of an element, section, or component, use element_snapshot_tool. Pass the element ID to capture its current visual state as an image.\n` +
Expand Down