Skip to main content

工具 API

🌐 Tools API

工具 API 提供了与 Mastra 平台中可用工具进行交互和执行的方法。

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

获取所有工具
Direct link to 获取所有工具

🌐 Getting All Tools

检索所有可用工具的列表:

🌐 Retrieve a list of all available tools:

const tools = await mastraClient.listTools();

使用特定工具
Direct link to 使用特定工具

🌐 Working with a Specific Tool

获取特定工具的一个实例:

🌐 Get an instance of a specific tool:

const tool = mastraClient.getTool("tool-id");

工具方法
Direct link to 工具方法

🌐 Tool Methods

获取工具详情
Direct link to 获取工具详情

🌐 Get Tool Details

检索有关工具的详细信息:

🌐 Retrieve detailed information about a tool:

const details = await tool.details();

执行工具
Direct link to 执行工具

🌐 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
});