> Discover all available pages from the documentation index: https://mastra.zisheng.pro/zh-TW/llms.txt # Mastra.listMCPServers() `.listMCPServers()` 方法用於取得 Mastra 執行個體中註冊的所有 MCP server 執行個體。傳回記錄以註冊鍵(`mcpServers` 設定中的鍵)作為鍵。 ## 使用範例 ```typescript // Register MCP servers const server1 = new MCPServer({ id: 'server-one', name: 'Server One', version: '1.0.0', tools: {/* ... */}, }) const server2 = new MCPServer({ id: 'server-two', name: 'Server Two', version: '1.0.0', tools: {/* ... */}, }) export const mastra = new Mastra({ mcpServers: { firstServer: server1, // Registry key: 'firstServer' secondServer: server2, // Registry key: 'secondServer' }, }) // List all registered servers const servers = mastra.listMCPServers() // Returns: { firstServer: MCPServerBase, secondServer: MCPServerBase } ``` ## 參數 此方法不接受任何參數。 ## 傳回值 **servers** (`Record | undefined`): 包含所有已註冊 MCP server 執行個體的記錄,其中鍵為註冊鍵(來自 mcpServers 設定),值為 MCPServerBase 執行個體;如果未註冊 server,則為 undefined。 ## 相關方法 - [Mastra.getMCPServer()](https://mastra.zisheng.pro/zh-TW/reference/core/getMCPServer): 依註冊鍵取得 MCP server - [Mastra.getMCPServerById()](https://mastra.zisheng.pro/zh-TW/reference/core/getMCPServerById): 依本身的 `id` 屬性取得 MCP server ## 另請參閱 - [MCP 概覽](https://mastra.zisheng.pro/zh-TW/docs/mcp/overview) - [MCP server 參考](https://mastra.zisheng.pro/zh-TW/reference/tools/mcp-server)