---
title: "Reference: Mastra.listMCPServers() | Core"
description: "Documentation for the `Mastra.listMCPServers()` method in Mastra, which retrieves all registered MCP server instances."
packages:
  - "@mastra/core"
---

# 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

<PropertiesTable
  content={[
    {
      name: "servers",
      type: "Record<string, MCPServerBase> | undefined",
      description:
        "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()](/reference/v1/core/getMCPServer) - Retrieve an MCP server by its registry key
- [Mastra.getMCPServerById()](/reference/v1/core/getMCPServerById) - Retrieve an MCP server by its intrinsic `id` property

## See Also

- [MCP overview](/docs/v1/mcp/overview)
- [MCP server reference](/reference/v1/tools/mcp-server)
