# 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 doesn't accept any parameters.

## Returns

**servers** (`Record<string, MCPServerBase> | 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) - Retrieve an MCP server by its registry key
- [Mastra.getMCPServerById()](https://mastra.ai/reference/core/getMCPServerById) - Retrieve an MCP server by its intrinsic `id` property

## See also

- [MCP overview](https://mastra.ai/docs/mcp/overview)
- [MCP server reference](https://mastra.ai/reference/tools/mcp-server)