Function: defineTool()
defineTool<
T>(definition):ToolDefinition<T>
Defined in: packages/core/src/utils/tools.ts:394
Define a tool with raw JSON Schema for input validation.
Type Parameters
T
T extends (...args) => unknown
Parameters
definition
Returns
Deprecated
Use tool() or defineZodTool() instead — they provide Zod-based
type inference and support the full v6+ feature set (requiresApproval,
toModelOutput, callers, etc.) that this raw-JSON-schema form lacks.
Will be removed in the next major version.
Example
const weatherTool = defineTool({
name: 'get_weather',
description: 'Get weather info',
inputSchema: {
type: 'object',
properties: {
location: { type: 'string' }
},
required: ['location']
},
execute: async ({ location }) => {
return { temp: 22, condition: 'sunny' };
}
});