Aller au contenu principal

Mastra.getTool()

La méthode .getTool() récupère un Tool depuis le registre au niveau de Mastra à partir de sa clé d’enregistrement.

Exemple d’utilisation
Lien direct vers Exemple d’utilisation

Enregistrez un Tool sous la clé weather, puis utilisez cette clé pour le récupérer.

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')

Paramètres
Lien direct vers Paramètres

name:

TToolName extends keyof TTools
Clé d’enregistrement du Tool dans le registre Mastra tools.