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
Tool 在 Mastra
tools 注册表中的注册键。