Mastra.getTool()
The .getTool() method retrieves a tool from the Mastra-level registry by its registration key.
Usage exampleDirect link to Usage example
Register a tool under the weather key, then use that key to retrieve it.
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')
ParametersDirect link to Parameters
name:
TToolName extends keyof TTools
The registration key of the tool in the Mastra
tools registry.