{"record":{"id":"36ec9846fb8d7248","repo":"mastra-ai/mastra","slug":"invalid-arguments-for-firecrawl-crawl","errorCode":null,"errorMessage":"Invalid arguments for firecrawl_crawl","messagePattern":"Invalid arguments for firecrawl_crawl","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/mcp/src/__fixtures__/fire-crawl-complex-schema.ts","lineNumber":711,"sourceCode":"        const { url, ...options } = args;\n        const response = await client.mapUrl(url, {\n          ...options,\n        });\n        if ('error' in response) {\n          throw new Error(response.error);\n        }\n        if (!response.links) {\n          throw new Error('No links received from Firecrawl API');\n        }\n        return {\n          content: [{ type: 'text', text: trimResponseText(response.links.join('\\n')) }],\n          isError: false,\n        };\n      }\n\n      case 'firecrawl_crawl': {\n        if (!isCrawlOptions(args)) {\n          throw new Error('Invalid arguments for firecrawl_crawl');\n        }\n        const { url, ...options } = args;\n        const response = await withRetry(async () => client.asyncCrawlUrl(url, { ...options }), 'crawl operation');\n\n        if (!response.success) {\n          throw new Error(response.error);\n        }\n\n        return {\n          content: [\n            {\n              type: 'text',\n              text: trimResponseText(`Started crawl for ${url} with job ID: ${response.id}`),\n            },\n          ],\n          isError: false,\n        };\n      }","sourceCodeStart":693,"sourceCodeEnd":729,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/mcp/src/__fixtures__/fire-crawl-complex-schema.ts#L693-L729","documentation":"The firecrawl_crawl branch validates args with `isCrawlOptions` (object with string `url`). On failure it throws before starting the async crawl via `withRetry(() => client.asyncCrawlUrl(...))`.","triggerScenarios":"Calling firecrawl_crawl with a missing or non-string `url`, or a non-object payload — e.g. `{\"arguments\":{\"limit\":10}}`.","commonSituations":"The LLM passes only crawl tuning options (limit, maxDepth) and forgets `url`, or nests the URL under a wrong key like `startUrl`.","solutions":["Always include a string `url` as the crawl starting point.","Use the exact key name `url`, not `startUrl`/`baseUrl`.","Validate arguments against the tool's inputSchema in the calling client."],"exampleFix":"// before\nfirecrawl_crawl({ 'startUrl': 'https://example.com', limit: 10 })\n// after\nfirecrawl_crawl({ 'url': 'https://example.com', limit: 10 })","handlingStrategy":"validation","validationCode":"if (!args || typeof args !== 'object' || typeof (args as any).url !== 'string') {\n  throw new TypeError('firecrawl_crawl requires { url: string, limit?, maxDepth? }');\n}","typeGuard":"function isCrawlOptions(a: unknown): a is { url: string } & Record<string, unknown> {\n  return typeof a === 'object' && a !== null && 'url' in a && typeof (a as { url: unknown }).url === 'string';\n}","tryCatchPattern":"try {\n  await callTool({ name: 'firecrawl_crawl', arguments: { url, limit: 10 } });\n} catch (e) {\n  if ((e as Error).message === 'Invalid arguments for firecrawl_crawl') {\n    // repair payload so url is present and a string, then retry\n  }\n}","preventionTips":["Always supply `url` first; put tuning options (limit, maxDepth) second.","Avoid alias keys like startUrl/baseUrl — the guard only accepts `url`.","Unit-test client payload builders against the tool's inputSchema."],"tags":["mcp","validation","type-guard"],"backgroundTag":"invalid-tool-arguments","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}