Skip to content

Commit 0aef978

Browse files
mknudsen01claude
andcommitted
Add instance_props_tool MCP registration for component props
Registers a new Designer Extension tool (instance_props_tool) that forwards get/search/set instance prop actions to the bridge app via RPC. Includes Zod schemas for all 33 bindable value types. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent a370c10 commit 0aef978

3 files changed

Lines changed: 135 additions & 1 deletion

File tree

src/mcp.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {
1313
registerSiteTools,
1414
registerDEStyleTools,
1515
registerDEVariableTools,
16+
registerDEInstancePropsTools,
1617
registerRulesTools,
1718
registerLocalDeMCPConnectionTools,
1819
registerCommentsTools,
@@ -63,7 +64,7 @@ export function registerTools(
6364

6465
export function registerWorkflowTools(
6566
server: McpServer,
66-
getAccessToken: () => string
67+
getAccessToken: () => string,
6768
) {
6869
registerWorkflowsTools(server, getAccessToken);
6970
}
@@ -75,6 +76,7 @@ export function registerDesignerTools(server: McpServer, rpc: RPCType) {
7576
registerDEPagesTools(server, rpc);
7677
registerDEStyleTools(server, rpc);
7778
registerDEVariableTools(server, rpc);
79+
registerDEInstancePropsTools(server, rpc);
7880
}
7981

8082
export function registerMiscTools(server: McpServer) {

src/tools/deInstanceProps.ts

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2+
import { RPCType } from "../types/RPCType";
3+
import z from "zod/v3";
4+
import { DEElementIDSchema, SiteIdSchema } from "../schemas";
5+
import { formatErrorResponse, formatResponse } from "../utils";
6+
7+
export function registerDEInstancePropsTools(server: McpServer, rpc: RPCType) {
8+
const instancePropsToolRPCCall = async (siteId: string, actions: any) => {
9+
return rpc.callTool("instance_props_tool", {
10+
siteId,
11+
actions: actions || [],
12+
});
13+
};
14+
15+
server.registerTool(
16+
"instance_props_tool",
17+
{
18+
title: "Designer Instance Props Tool",
19+
annotations: {
20+
readOnlyHint: false,
21+
openWorldHint: true,
22+
},
23+
description:
24+
"Designer tool - Get, search, and set component instance properties (props). Use this to read prop values, search props by value type, and set static values or data bindings on component instances.",
25+
inputSchema: {
26+
...SiteIdSchema,
27+
actions: z.array(
28+
z
29+
.object({
30+
get_instance_props: z
31+
.object({
32+
...DEElementIDSchema,
33+
})
34+
.optional()
35+
.describe(
36+
"Get a quick summary of all props on a component instance. Returns propId, value, and hasOverride for each prop.",
37+
),
38+
search_instance_props: z
39+
.object({
40+
...DEElementIDSchema,
41+
value_type: z
42+
.enum([
43+
"string",
44+
"textContent",
45+
"richText",
46+
"boolean",
47+
"color",
48+
"date",
49+
"link",
50+
"url",
51+
"email",
52+
"phone",
53+
"file",
54+
"videoUrl",
55+
"video",
56+
"image",
57+
"imageAsset",
58+
"cmsImage",
59+
"imageSet",
60+
"number",
61+
"enum",
62+
"option",
63+
"slot",
64+
"reference",
65+
"referenceSet",
66+
"variant",
67+
"filter",
68+
"sort",
69+
"selectedItems",
70+
"visibility",
71+
"booleanFilter",
72+
"altText",
73+
"id",
74+
])
75+
.optional()
76+
.describe(
77+
"Optional filter to only return props of a specific value type.",
78+
),
79+
})
80+
.optional()
81+
.describe(
82+
"Search instance props with full detail including display labels, binding metadata, and resolved values. Optionally filter by value type.",
83+
),
84+
set_instance_props: z
85+
.object({
86+
...DEElementIDSchema,
87+
props: z
88+
.array(
89+
z.object({
90+
propId: z.string().describe("The prop ID to set."),
91+
value: z
92+
.any()
93+
.describe(
94+
"The value to set. Can be a static value (string, number, boolean, null to reset), or a binding object ({ sourceType: 'cms', collectionId, fieldId } or { sourceType: 'prop', propId } or { sourceType: 'page', fieldKey }).",
95+
),
96+
}),
97+
)
98+
.describe(
99+
"Array of prop entries to set on the component instance.",
100+
),
101+
})
102+
.optional()
103+
.describe(
104+
"Set property values on a component instance. Supports static values, data bindings, and resetting overrides (value: null).",
105+
),
106+
})
107+
.strict()
108+
.refine(
109+
(d) =>
110+
[
111+
d.get_instance_props,
112+
d.search_instance_props,
113+
d.set_instance_props,
114+
].filter(Boolean).length >= 1,
115+
{
116+
message:
117+
"Provide at least one of get_instance_props, search_instance_props, set_instance_props.",
118+
},
119+
),
120+
),
121+
},
122+
},
123+
async ({ siteId, actions }) => {
124+
try {
125+
return formatResponse(await instancePropsToolRPCCall(siteId, actions));
126+
} catch (error) {
127+
return formatErrorResponse(error);
128+
}
129+
},
130+
);
131+
}

src/tools/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ export { registerDEElementTools } from "./deElement";
1616
export { registerDEPagesTools } from "./dePages";
1717
export { registerDEStyleTools } from "./deStyle";
1818
export { registerDEVariableTools } from "./deVariable";
19+
export { registerDEInstancePropsTools } from "./deInstanceProps";
1920

2021
// Rules Tools
2122
export { registerRulesTools } from "./rules";

0 commit comments

Comments
 (0)