# Mastra.listMCPServers() The `.listMCPServers()` method is used to retrieve all MCP server instances that have been registered in the Mastra instance. The returned record uses registry keys (the keys from the `mcpServers` configuration) as keys. ## Usage example ```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 } ``` ## Parameters This method does not accept any parameters. ## Returns ### servers: Record\ | undefined A record of all registered MCP server instances, where keys are the registry keys (from mcpServers configuration) and values are MCPServerBase instances, or undefined if no servers are registered. ## Related Methods - [Mastra.getMCPServer()](https://mastra.ai/reference/core/getMCPServer/llms.txt) - Retrieve an MCP server by its registry key - [Mastra.getMCPServerById()](https://mastra.ai/reference/core/getMCPServerById/llms.txt) - Retrieve an MCP server by its intrinsic `id` property ## See Also - [MCP overview](https://mastra.ai/docs/mcp/overview/llms.txt) - [MCP server reference](https://mastra.ai/reference/tools/mcp-server/llms.txt)