Function: defineTool()
defineTool(
__namedParameters):Tool
Defined in: tool.ts:307
Builds a Tool from a method that returns data instead of a
CallToolResult, which is what most hand-written tools want.
Parameters
| Parameter | Type |
|---|---|
__namedParameters | DefineToolParams |
Returns
Example
const getCampaign = defineTool({
name: 'get-campaign',
description: 'Get a campaign by id.',
inputSchema: z.object({ campaignId: z.string() }),
method: ({ campaignId }) => findCampaign(campaignId as string),
notFoundMessage: 'Campaign not found',
});