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

Tools API

The Tools API provides methods to interact with and execute tools available in the Mastra platform.

Getting all tools
Getting all tools的直接链接

Retrieve a list of all available tools:

const tools = await mastraClient.listTools()

Working with a specific tool
Working with a specific tool的直接链接

Get an instance of a specific tool:

const tool = mastraClient.getTool('tool-id')

Tool methods
Tool methods的直接链接

Get Tool Details
Get Tool Details的直接链接

Retrieve detailed information about a tool:

const details = await tool.details()

Execute Tool
Execute Tool的直接链接

Execute a tool with specific arguments:

const result = await tool.execute({
args: {
param1: 'value1',
param2: 'value2',
},
threadId: 'thread-1', // Optional: Thread context
resourceId: 'resource-1', // Optional: Resource identifier
})