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

Mastra.listTools()

The .listTools() method returns the tools configured on a Mastra instance. The returned record uses Mastra registration keys and tool instances as values.

Usage example
Usage example的直接链接

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

Parameters
Parameters的直接链接

This method doesn't accept any parameters.

Returns
Returns的直接链接

tools:

TTools | undefined
The Mastra-level tool registry, where each key is a registration key and each value is a tool instance. Returns undefined when no registry is available.

This method lists the Mastra-level registry. It doesn't include tools that exist only in a function-based Agent tools callback.

On this page