Mastra.getTool()
.getTool() 方法依註冊鍵從 Mastra 級 registry 取得 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
Tool 在 Mastra
tools registry 中的註冊鍵。