メインコンテンツへ移動

Mastra.getTool()

.getTool() メソッドは、Mastra レベルのレジストリから登録キーで Tool を取得します。

使用例
使用例への直接リンク

weather キーで Tool を登録し、そのキーを使って取得します。

src/mastra/index.ts
import { Mastra } from '@mastra/core/mastra'
import { weatherTool } from './tools/weather-tool'

export const mastra = new Mastra({
tools: {
weather: weatherTool,
},
})

const tool = mastra.getTool('weather')

パラメーター
パラメーターへの直接リンク

name:

TToolName extends keyof TTools
Mastra の tools レジストリにある Tool の登録キー。