跳到主要内容

Mastra.listTools()

.listTools() 方法返回 Mastra 实例上配置的 Tool。返回记录以 Mastra 注册键作为键,以 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 tools = mastra.listTools()
const weather = tools?.weather

参数
参数的直接链接

此方法不接受任何参数。

返回值
返回值的直接链接

tools:

TTools | undefined
Mastra 级 Tool 注册表,其中每个键都是注册键,每个值都是 Tool 实例。没有可用注册表时返回 undefined

此方法列出 Mastra 级注册表,不包括仅存在于函数式 Agent tools 回调中的 Tool。