list_atlas_clusters
Retrieve all MongoDB Atlas clusters within a specified project to view and manage your database deployments.
Instructions
Lists all clusters in an Atlas project.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| projectId | Yes | The ID of the Atlas project. |
Implementation Reference
- src/index.ts:313-336 (handler)The handler function that executes the list_atlas_clusters tool. It makes an API request to fetch clusters for the given projectId, enhances connection strings, and returns the formatted result.private async listAtlasClusters(input: ListClustersInput) { try { const url = `https://cloud.mongodb.com/api/atlas/v1.0/groups/${input.projectId}/clusters`; const result = await this.makeAtlasRequest(url, 'GET'); // Add appName to connection strings in all clusters this.addAppNameToConnectionStrings(result); return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] }; } catch (error: any) { return { content: [{ type: 'text', text: error.message }], isError: true }; } }
- src/index.ts:37-39 (schema)TypeScript interface defining the input schema for listAtlasClusters: requires projectId.interface ListClustersInput { projectId: string; }
- src/index.ts:487-499 (registration)Tool registration in the ListTools response, including name, description, and inputSchema.name: 'list_atlas_clusters', description: 'Lists all clusters in an Atlas project.', inputSchema: { type: 'object', properties: { projectId: { type: 'string', description: 'The ID of the Atlas project.', }, }, required: ['projectId'], }, }
- src/index.ts:564-566 (registration)Dispatch in CallToolRequest handler that routes to the listAtlasClusters method.case 'list_atlas_clusters': result = await this.listAtlasClusters(input as unknown as ListClustersInput); break;
- src/index.ts:538-542 (schema)Input validation for list_atlas_clusters parameters before execution.case 'list_atlas_clusters': if (!input.projectId) { throw new McpError(ErrorCode.InvalidParams, 'Invalid list clusters arguments'); } break;