Skip to content

Commit 2ceb9b8

Browse files
committed
fix: resolve MCP tool validation errors in beta server
## Issue 1: Site publishing fails with customDomains validation error **Error:** ``` "message": "Validation Error: [\"Value (customDomains)'s type should be array\"]", "code": "validation_error" ``` **Root cause:** Incorrect Zod chaining order in sites.ts. When `.default()` comes before `.optional()`, the field can still be `undefined`, causing the Webflow API to reject the request. **Fix:** Changed customDomains schema from: ```typescript z.array(z.string()).default([]).optional() ``` To: ```typescript z.array(z.string()).optional().default([]) ``` This ensures customDomains always defaults to an empty array instead of potentially being undefined. **Files changed:** - mcp-server-beta/src/tools/sites.ts ## Issue 2: Empty error messages in element_snapshot_tool **Error:** ```json { "name": "Error", "message": "", "error": {} } ``` **Root cause:** When element_snapshot_tool's RPC call fails with an empty message, the error handler creates `new Error("")`, resulting in unhelpful empty error messages. **Fix:** Added fallback error message with response details: ```typescript new Error( message || \`Element snapshot failed with status: \${status}. Response: \${JSON.stringify({ status, message, data })}\` ) ``` **Files changed:** - mcp-server-beta/src/tools/deElement.ts **Testing:** These fixes target the beta server only for validation before rolling out to stable.
1 parent 6fd3183 commit 2ceb9b8

2 files changed

Lines changed: 7 additions & 2 deletions

File tree

src/tools/deElement.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -539,7 +539,12 @@ export const registerDEElementTools = (server: McpServer, rpc: RPCType) => {
539539
],
540540
};
541541
}
542-
return formatErrorResponse(new Error(message));
542+
return formatErrorResponse(
543+
new Error(
544+
message ||
545+
`Element snapshot failed with status: ${status}. Response: ${JSON.stringify({ status, message, data })}`
546+
)
547+
);
543548
} catch (error) {
544549
return formatErrorResponse(error);
545550
}

src/tools/sites.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,8 @@ export function registerSiteTools(
7979
.describe("Unique identifier for the site."),
8080
customDomains: z
8181
.array(z.string())
82-
.default([])
8382
.optional()
83+
.default([])
8484
.describe(
8585
"Array of custom domains to publish the site to.",
8686
),

0 commit comments

Comments
 (0)