Skip to content

Commit 93c6c92

Browse files
JooHyung Parkclaude
andcommitted
[ai-assisted] fix(mcp): coerce string params to numbers in set_fill_color, set_stroke_color, set_corner_radius
MCP clients may pass numeric parameters as strings. Add Number() coercion in the WebSocket client transform layer so Figma plugin validation doesn't reject them with "Expected number, received string". Also adds a missing transform handler for set_corner_radius. Co-Authored-By: Claude <noreply@anthropic.com>
1 parent e21a68e commit 93c6c92

1 file changed

Lines changed: 14 additions & 9 deletions

File tree

src/main/server/shared/websocket-client.ts

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -203,23 +203,28 @@ export class WebSocketClient {
203203
transformedParams = {
204204
nodeId: params.nodeId,
205205
color: {
206-
r: params.r,
207-
g: params.g,
208-
b: params.b,
209-
a: params.a ?? 1,
206+
r: Number(params.r),
207+
g: Number(params.g),
208+
b: Number(params.b),
209+
a: Number(params.a ?? 1),
210210
},
211211
};
212212
} else if (command === 'set_stroke_color' && 'r' in params && 'g' in params && 'b' in params) {
213213
// Transform: { nodeId, r, g, b, a, weight } → { nodeId, color: { r, g, b, a }, weight }
214214
transformedParams = {
215215
nodeId: params.nodeId,
216216
color: {
217-
r: params.r,
218-
g: params.g,
219-
b: params.b,
220-
a: params.a ?? 1,
217+
r: Number(params.r),
218+
g: Number(params.g),
219+
b: Number(params.b),
220+
a: Number(params.a ?? 1),
221221
},
222-
weight: params.weight ?? 1,
222+
weight: Number(params.weight ?? 1),
223+
};
224+
} else if (command === 'set_corner_radius' && 'radius' in params) {
225+
transformedParams = {
226+
...params,
227+
radius: Number(params.radius),
223228
};
224229
}
225230

0 commit comments

Comments
 (0)