跳至主要內容

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。