> Discover all available pages from the documentation index: https://mastra.zisheng.pro/zh-TW/llms.txt # Mastra.getTool() `.getTool()` 方法依註冊鍵從 Mastra 級 registry 取得 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 registry 中的註冊鍵。 ## 相關內容 - [在 Agent 之間共享 Tool](https://mastra.zisheng.pro/zh-TW/docs/agents/using-tools) - [Mastra 類別](https://mastra.zisheng.pro/zh-TW/reference/core/mastra-class) - [Mastra.getToolById()](https://mastra.zisheng.pro/zh-TW/reference/core/getToolById) - [Mastra.listTools()](https://mastra.zisheng.pro/zh-TW/reference/core/listTools)