> Discover all available pages from the documentation index: https://mastra.zisheng.pro/ja/llms.txt # Mastra.getMCPServerById() `.getMCPServerById()` メソッドは、固有の `id` プロパティで MCP Server インスタンスを取得します。レジストリキー(設定で使用したキー)で取得するには、代わりに `.getMCPServer()` を使用します。 ## 使用例 ```typescript // Register an MCP server with a registry key const myServer = new MCPServer({ id: 'my-mcp-server', name: 'My Server', version: '1.0.0', tools: {/* ... */}, }) export const mastra = new Mastra({ mcpServers: { customKey: myServer, // 'customKey' is the registry key }, }) // Retrieve by intrinsic ID const server = mastra.getMCPServerById('my-mcp-server') // Alternatively, retrieve by registry key const serverByKey = mastra.getMCPServer('customKey') ``` ## パラメータ **serverId** (`string`): MCP Server 自体の id プロパティ(Server のインスタンス化時に設定)。 **version** (`string`): 任意。指定した場合は、バージョンが一致する Server だけを返します。 ## 戻り値 **server** (`MCPServerBase | undefined`): 指定した id(指定されている場合は version も)が一致する MCP Server インスタンス。見つからない場合は undefined。 ## 注意事項 - Server の `id` は構築時にスラッグ化されるため、`'myMcpServer'` は `'my-mcp-server'` になります - 複数の Server が同じ `id` で異なるバージョンを持つ場合、識別するには `version` パラメータを指定する必要があります - `version` を指定せず、複数のバージョンが存在する場合、このメソッドは最初に一致したものを返します ## 関連メソッド - [Mastra.getMCPServer()](https://mastra.zisheng.pro/ja/reference/core/getMCPServer): レジストリキーで MCP Server を取得 - [Mastra.listMCPServers()](https://mastra.zisheng.pro/ja/reference/core/listMCPServers): 登録済みのすべての MCP Server を一覧表示 ## 関連情報 - [MCP の概要](https://mastra.zisheng.pro/ja/docs/mcp/overview) - [MCP Server リファレンス](https://mastra.zisheng.pro/ja/reference/tools/mcp-server)