{"record":{"id":"1ba88da06de3ea84","repo":"mastra-ai/mastra","slug":"tool-parameters-are-required","errorCode":null,"errorMessage":"Tool parameters are required","messagePattern":"Tool parameters are required","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/core/src/tools/tool-builder/builder.ts","lineNumber":927,"sourceCode":"              errorMessage: String(err),\n              argsJson: safeStringify(args),\n              model: model?.modelId ?? '',\n            },\n          },\n          err,\n        );\n        toolSpan?.error({ error: mastraError, attributes: { success: false } });\n        logger.trackException(mastraError, { ...logData, ...rest, model: logModelObject, args });\n        throw mastraError;\n      }\n    };\n  }\n\n  buildV5() {\n    const builtTool = this.build();\n\n    if (!builtTool.parameters) {\n      throw new Error('Tool parameters are required');\n    }\n\n    const base = {\n      ...builtTool,\n      inputSchema: builtTool.parameters,\n      onInputStart: 'onInputStart' in this.originalTool ? this.originalTool.onInputStart : undefined,\n      onInputDelta: 'onInputDelta' in this.originalTool ? this.originalTool.onInputDelta : undefined,\n      onInputAvailable: 'onInputAvailable' in this.originalTool ? this.originalTool.onInputAvailable : undefined,\n      onOutput: 'onOutput' in this.originalTool ? this.originalTool.onOutput : undefined,\n    };\n\n    // For provider-defined tools, exclude execute and add name as per v5 spec\n    if (builtTool.type === 'provider-defined') {\n      const { execute, parameters, ...rest } = base;\n      // Prefer the preserved provider name (e.g. \"web_search\" from V5 SDK\n      // factories) over the ID-derived name (e.g. \"web_search_20250305\").\n      const name =\n        ('name' in builtTool && typeof builtTool.name === 'string' ? builtTool.name : null) ||","sourceCodeStart":909,"sourceCodeEnd":945,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/core/src/tools/tool-builder/builder.ts#L909-L945","documentation":"The v5 tool builder's buildV5() requires the built tool to have a parameters (input schema) object, which it maps to inputSchema. Tools without any input schema cannot be represented in the v5 tool contract, so CoreToolBuilder throws 'Tool parameters are required'.","triggerScenarios":"Calling createTool().buildV5() (or the v5 path via agent/tool conversion) on a tool defined with no inputSchema/parameters, e.g. createTool({ id, execute }) with the schema omitted.","commonSituations":"Migrating legacy tools that had optional schemas; defining zero-argument tools by simply omitting inputSchema instead of an empty-object schema; refactor that removed inputSchema assuming it was optional in v5.","solutions":["Add an inputSchema to the tool definition, using z.object({}) for tools that take no input.","If the tool genuinely has no inputs, define parameters as an empty object schema rather than omitting it.","Check that your builder chain (inputSchema/parameters step) is not conditionally skipped."],"exampleFix":"// before\ncreateTool({ id: 'ping', execute: async () => 'pong' });\n// after\nimport { z } from 'zod';\ncreateTool({ id: 'ping', inputSchema: z.object({}), execute: async () => 'pong' });","handlingStrategy":"validation","validationCode":"import { z } from 'zod';\nif (!toolDef.inputSchema) {\n  toolDef.inputSchema = z.object({}); // zero-argument tools still need a schema\n}","typeGuard":"function hasInputSchema(t: { inputSchema?: unknown }): t is { inputSchema: object } {\n  return t.inputSchema != null;\n}","tryCatchPattern":"try {\n  const built = builder.buildV5();\n} catch (e) {\n  if (String(e.message) === 'Tool parameters are required') {\n    // add inputSchema: z.object({}) and rebuild\n  } else throw e;\n}","preventionTips":["Always declare inputSchema on createTool, even z.object({}) for no-input tools.","Add a lint/test asserting every tool definition includes inputSchema.","Review tool definitions when migrating from versions where schemas were optional."],"tags":["tool-builder","input-schema","v5","validation"],"backgroundTag":"missing-input-schema","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}