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 exampleUsage 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
ParametersParameters的直接链接
This method doesn't accept any parameters.
ReturnsReturns的直接链接
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.