跳到主要内容
非官方简体中文翻译,内容版权归 Mastra 所有,遵循 Apache-2.0 许可。

Mastra.getTool()

The .getTool() method retrieves a tool from the Mastra-level registry by its registration key.

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

Parameters
Parameters的直接链接

name:

TToolName extends keyof TTools
The registration key of the tool in the Mastra tools registry.
On this page