Skip to main content
Glama
mongodb-js

MongoDB MCP Server

Official
by mongodb-js

atlas-list-clusters

Read-only

Retrieve a list of MongoDB Atlas clusters for a specified project to manage and monitor database deployments.

Instructions

List MongoDB Atlas clusters

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
projectIdNoAtlas project ID to filter clusters

Implementation Reference

  • The execute method implements the core logic of the 'atlas-list-clusters' tool, listing clusters across all projects or filtered by a specific project ID using Atlas API calls.
    protected async execute({ projectId }: ToolArgs<typeof this.argsShape>): Promise<CallToolResult> {
        if (!projectId) {
            const data = await this.session.apiClient.listClusterDetails();
    
            return this.formatAllClustersTable(data);
        } else {
            const project = await this.session.apiClient.getGroup({
                params: {
                    path: {
                        groupId: projectId,
                    },
                },
            });
    
            if (!project?.id) {
                throw new Error(`Project with ID "${projectId}" not found.`);
            }
    
            const data = await this.session.apiClient.listClusters({
                params: {
                    path: {
                        groupId: project.id || "",
                    },
                },
            });
    
            return this.formatClustersTable(project, data);
        }
    }
  • Schema definition for tool arguments (projectId optional) and tool metadata including name, description, operation type, and argsShape.
    export const ListClustersArgs = {
        projectId: AtlasArgs.projectId().describe("Atlas project ID to filter clusters").optional(),
    };
    
    export class ListClustersTool extends AtlasToolBase {
        public name = "atlas-list-clusters";
        protected description = "List MongoDB Atlas clusters";
        static operationType: OperationType = "read";
        protected argsShape = {
            ...ListClustersArgs,
        };
  • Re-export of ListClustersTool making it available for aggregation in higher-level tool collections.
    export { ListClustersTool } from "./read/listClusters.js";
  • Helper method to format and return a table of clusters from all projects.
    private formatAllClustersTable(clusters?: PaginatedOrgGroupView): CallToolResult {
        if (!clusters?.results?.length) {
            throw new Error("No clusters found.");
        }
        const formattedClusters = clusters.results
            .map((result) => {
                return (result.clusters || []).map((cluster) => ({
                    projectName: result.groupName,
                    projectId: result.groupId,
                    clusterName: cluster.name,
                }));
            })
            .flat();
        if (!formattedClusters.length) {
            throw new Error("No clusters found.");
        }
    
        return {
            content: formatUntrustedData(
                `Found ${formattedClusters.length} clusters across all projects`,
                JSON.stringify(formattedClusters)
            ),
        };
    }
  • Helper method to format and return a table of clusters (including flex clusters) for a specific project.
    private formatClustersTable(
        project: Group,
        clusters?: PaginatedClusterDescription20240805,
        flexClusters?: PaginatedFlexClusters20241113
    ): CallToolResult {
        // Check if both traditional clusters and flex clusters are absent
        if (!clusters?.results?.length && !flexClusters?.results?.length) {
            return {
                content: [{ type: "text", text: "No clusters found." }],
            };
        }
        const formattedClusters = clusters?.results?.map((cluster) => formatCluster(cluster)) || [];
        const formattedFlexClusters = flexClusters?.results?.map((cluster) => formatFlexCluster(cluster)) || [];
        const allClusters = [...formattedClusters, ...formattedFlexClusters];
    
        return {
            content: formatUntrustedData(
                `Found ${allClusters.length} clusters in project "${project.name}" (${project.id}):`,
                JSON.stringify(allClusters)
            ),
        };
    }
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations already declare readOnlyHint=true and destructiveHint=false, so the agent knows this is a safe read operation. The description adds no behavioral context beyond what annotations provide - no information about rate limits, authentication requirements, pagination, return format, or what 'list' entails (e.g., all clusters vs filtered). With annotations covering safety, a 3 is appropriate as the description doesn't add value but doesn't contradict annotations either.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence with zero wasted words. It's front-loaded with the core purpose and appropriately sized for a simple list operation. Every word earns its place - 'List' (action), 'MongoDB Atlas' (context), 'clusters' (resource).

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a simple read operation with good annotations (readOnlyHint=true, destructiveHint=false) and 100% schema coverage, the description is minimally adequate. However, with no output schema and multiple sibling tools, it should provide more context about what 'list' returns and how it differs from inspection tools. The description meets basic requirements but leaves the agent to infer important contextual details.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100% with the single parameter 'projectId' fully documented in the schema. The description adds no parameter information beyond what's in the schema - it doesn't explain that listing clusters typically requires a project context, or what happens when projectId is omitted. Baseline 3 is correct when schema does all the parameter documentation work.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb ('List') and resource ('MongoDB Atlas clusters'), making the purpose immediately understandable. It distinguishes from some siblings like 'atlas-inspect-cluster' (detailed inspection) and 'atlas-list-alerts' (different resource), but doesn't explicitly differentiate from 'atlas-list-projects' or 'atlas-list-orgs' which list different Atlas entities. The description is specific but could be more precise about sibling differentiation.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention that 'atlas-inspect-cluster' is for detailed inspection of a specific cluster, or that 'atlas-list-projects' might be needed first to get project IDs. There's no context about prerequisites, timing, or exclusions. The agent must infer usage from the name and schema alone.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/mongodb-js/mongodb-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server