跳至主要內容

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 registry,其中每個鍵都是註冊鍵,每個值都是 Tool 執行個體。沒有可用 registry 時傳回 undefined

此方法列出 Mastra 級 registry,不包括僅存在於函式型 Agent tools callback 中的 Tool。