fix: resolve MCP tool validation errors in beta server#106
Merged
viratatwebflow merged 1 commit intosaifrom Apr 6, 2026
Merged
fix: resolve MCP tool validation errors in beta server#106viratatwebflow merged 1 commit intosaifrom
viratatwebflow merged 1 commit intosaifrom
Conversation
## 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.
viratatwebflow
approved these changes
Apr 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR fixes two validation errors in the beta MCP server that were causing tool failures in production.
Issue 1: Site Publishing Fails with customDomains Validation Error
Production Error:
{ "message": "Validation Error: [\"Value (customDomains)'s type should be array\"]", "code": "validation_error", "statusCode": 400 }Event ID:
evt_3BlCAWmNUYSYB94s8VTWyvCJ5d0Actor: kelly@vector.co
Timestamp: Apr 1, 2026, 10:35:26 AM
Root Cause:
Incorrect Zod chaining order in
sites.ts. When.default([])comes before.optional(), the field can still beundefined, causing the Webflow API to reject the request.Before:
After:
Why this works:
In Zod,
.optional().default([])ensures that if the field is omitted, it defaults to[]. With the original order, the field could beundefinedeven with.default([]), which caused the API validation to fail.Issue 2: Empty Error Messages in element_snapshot_tool
Production Error:
{ "name": "Error", "message": "", "error": {} }Event ID:
evt_3BpOqtX0Z2ZbizQ06We4pzL88rgResource: element_snapshot_tool
Timestamp: Apr 2, 2026, 10:18:58 PM
Root Cause:
When
element_snapshot_tool's RPC call fails and returns an emptymessage, the error handler createsnew Error(""), resulting in unhelpful debugging information.Before:
After:
Why this works:
Provides a fallback error message with full response details when the RPC call returns an empty message, making debugging significantly easier.
Testing
mcp-server-beta)Files Changed
mcp-server-beta/src/tools/sites.ts- Fixed customDomains Zod chainingmcp-server-beta/src/tools/deElement.ts- Fixed empty error messagesNext Steps
After validation in beta: