> Discover all available pages from the documentation index: https://mastra.zisheng.pro/llms.txt # Mastra.getTool() `.getTool()` 方法按注册键从 Mastra 级注册表获取 Tool。 ## 使用示例 使用 `weather` 键注册 Tool,然后使用该键获取它。 ```typescript import { Mastra } from '@mastra/core/mastra' import { weatherTool } from './tools/weather-tool' export const mastra = new Mastra({ tools: { weather: weatherTool, }, }) const tool = mastra.getTool('weather') ``` ## 参数 **name** (`TToolName extends keyof TTools`): Tool 在 Mastra tools 注册表中的注册键。 ## 相关内容 - [在 Agent 之间共享 Tool](https://mastra.zisheng.pro/docs/agents/using-tools) - [Mastra 类](https://mastra.zisheng.pro/reference/core/mastra-class) - [Mastra.getToolById()](https://mastra.zisheng.pro/reference/core/getToolById) - [Mastra.listTools()](https://mastra.zisheng.pro/reference/core/listTools)