{"record":{"id":"10b262736b3314ac","repo":"mastra-ai/mastra","slug":"invalid-arguments-for-firecrawl-deep-research","errorCode":null,"errorMessage":"Invalid arguments for firecrawl_deep_research","messagePattern":"Invalid arguments for firecrawl_deep_research","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/mcp/src/__fixtures__/fire-crawl-complex-schema.ts","lineNumber":843,"sourceCode":"\n          if (response.warning) {\n            safeLog('warning', response.warning);\n          }\n\n          return result;\n        } catch (error) {\n          const errorMessage = error instanceof Error ? error.message : String(error);\n\n          return {\n            content: [{ type: 'text', text: trimResponseText(errorMessage) }],\n            isError: true,\n          };\n        }\n      }\n\n      case 'firecrawl_deep_research': {\n        if (!args || typeof args !== 'object' || !('query' in args)) {\n          throw new Error('Invalid arguments for firecrawl_deep_research');\n        }\n\n        try {\n          const researchStartTime = Date.now();\n          safeLog('info', `Starting deep research for query: ${args.query}`);\n\n          const response = await client.deepResearch(\n            args.query as string,\n            {\n              maxDepth: args.maxDepth as number,\n              timeLimit: args.timeLimit as number,\n              maxUrls: args.maxUrls as number,\n            },\n            activity => {\n              safeLog('info', `Research activity: ${activity.message} (Depth: ${activity.depth})`);\n            },\n            source => {\n              safeLog('info', `Research source found: ${source.url}${source.title ? ` - ${source.title}` : ''}`);","sourceCodeStart":825,"sourceCodeEnd":861,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/mcp/src/__fixtures__/fire-crawl-complex-schema.ts#L825-L861","documentation":"firecrawl_deep_research has no dedicated predicate; it manually checks that args is a non-null object containing a `query` key, throwing this error otherwise. Deep research drives a long-running multi-step Firecrawl job, so the guard ensures a research query actually exists before spending API credits.","triggerScenarios":"args is null/undefined, not an object, or lacks a `query` property — e.g. calling the tool with {}, with only optional params like maxDepth/maxUrls, or with the query field misspelled (q, topic, question).","commonSituations":"LLM client calls the tool with only optional parameters; client code renamed the field after a schema update; arguments dropped in transport so an empty object arrives.","solutions":["Always pass `query` as a non-empty string: { query: \"your research question\" }.","Check for typos in the parameter name (must be exactly `query`).","Review the firecrawl_deep_research tool schema to confirm required fields for your server version.","If an LLM generates the args, include the query field explicitly in the prompt/template or schema example."],"exampleFix":"// before\nfirecrawl_deep_research({ maxDepth: 3 })\n// after\nfirecrawl_deep_research({ query: \"state of AI regulation 2026\", maxDepth: 3 })","handlingStrategy":"validation","validationCode":"function canCallDeepResearch(args) {\n  return (\n    !!args &&\n    typeof args === 'object' &&\n    'query' in args &&\n    typeof args.query === 'string' &&\n    args.query.trim().length > 0\n  );\n}\nif (!canCallDeepResearch(args)) throw new TypeError('firecrawl_deep_research requires a non-empty string query');","typeGuard":"function isDeepResearchArgs(a: unknown): a is { query: string; maxDepth?: number; maxUrls?: number; timeLimit?: number } {\n  return typeof a === 'object' && a !== null && 'query' in a &&\n    typeof (a as any).query === 'string' && (a as any).query.length > 0;\n}","tryCatchPattern":"try {\n  return await firecrawlDeepResearch(args);\n} catch (e) {\n  if (e instanceof Error && e.message.includes('Invalid arguments for firecrawl_deep_research')) {\n    console.error('deep_research args must include query; got:', JSON.stringify(args));\n    throw new TypeError('Provide { query: string } to firecrawl_deep_research');\n  }\n  throw e;\n}","preventionTips":["Build tool args from a typed interface so `query` is required at compile time.","Watch for renamed/mislabeled fields (q, topic) when prompts change.","Validate args object existence before invoking tools from dynamic/LLM flows.","Keep tool schemas in sync with server definitions after upgrades."],"tags":["mcp","validation","tool-arguments","firecrawl"],"backgroundTag":"invalid-tool-arguments","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}