fix(mcp): webFetchInput emits 'URL is required' for a missing url (#4510) (#4541)

The omniroute_web_fetch input schema (#4510) used z.string().min(1, "URL is
required") for the url field, but .min() only fires for an empty string. A
MISSING url (webFetchInput.parse({})) fails the z.string() type check first and
emitted the default Zod v4 message ("expected string, received undefined"), so
the existing test 'webFetchInput rejects missing URL' (expecting /URL is
required/) failed on the full unit suite — a latent base red on release/v3.8.33.

Add the custom message to the type check: z.string({ error: "URL is required" }).
Now both the missing-field and empty-string cases emit 'URL is required'; a valid
url still passes. No other web_fetch behavior changes.

Co-authored-by: Diego Rodrigues de Sa e Souza <diego.souza@cdwasolutions.com.br>
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Diego Rodrigues de Sa e Souza
2026-06-21 15:43:55 -03:00
committed by GitHub
parent 2b21bb60d9
commit 4d3a9fd3df

View File

@@ -462,7 +462,7 @@ export const webSearchTool: McpToolDefinition<typeof webSearchInput, typeof webS
// --- Tool 10: omniroute_web_fetch ---
export const webFetchInput = z.object({
url: z
.string()
.string({ error: "URL is required" })
.min(1, "URL is required")
.describe("The URL to fetch content from"),
provider: z