• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

mongodb-js / mongodb-mcp-server / 14671884465

25 Apr 2025 07:17PM UTC coverage: 67.88% (-14.6%) from 82.446%
14671884465

Pull #134

github

web-flow
chore(deps-dev): bump mongodb-runner from 5.8.2 to 5.8.3

Bumps [mongodb-runner](https://github.com/mongodb-js/devtools-shared) from 5.8.2 to 5.8.3.
- [Commits](https://github.com/mongodb-js/devtools-shared/commits)

---
updated-dependencies:
- dependency-name: mongodb-runner
  dependency-version: 5.8.3
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Pull Request #134: chore(deps-dev): bump mongodb-runner from 5.8.2 to 5.8.3

99 of 212 branches covered (46.7%)

Branch coverage included in aggregate %.

628 of 859 relevant lines covered (73.11%)

43.31 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

15.22
/src/tools/atlas/read/listClusters.ts
1
import { z } from "zod";
31✔
2
import { CallToolResult } from "@modelcontextprotocol/sdk/types.js";
3
import { AtlasToolBase } from "../atlasTool.js";
31✔
4
import { ToolArgs, OperationType } from "../../tool.js";
5
import { PaginatedClusterDescription20240805, PaginatedOrgGroupView, Group } from "../../../common/atlas/openapi.js";
6

7
export class ListClustersTool extends AtlasToolBase {
31✔
8
    protected name = "atlas-list-clusters";
23✔
9
    protected description = "List MongoDB Atlas clusters";
23✔
10
    protected operationType: OperationType = "read";
23✔
11
    protected argsShape = {
23✔
12
        projectId: z.string().describe("Atlas project ID to filter clusters").optional(),
13
    };
14

15
    protected async execute({ projectId }: ToolArgs<typeof this.argsShape>): Promise<CallToolResult> {
16
        if (!projectId) {
×
17
            const data = await this.session.apiClient.listClustersForAllProjects();
×
18

19
            return this.formatAllClustersTable(data);
×
20
        } else {
21
            const project = await this.session.apiClient.getProject({
×
22
                params: {
23
                    path: {
24
                        groupId: projectId,
25
                    },
26
                },
27
            });
28

29
            if (!project?.id) {
×
30
                throw new Error(`Project with ID "${projectId}" not found.`);
×
31
            }
32

33
            const data = await this.session.apiClient.listClusters({
×
34
                params: {
35
                    path: {
36
                        groupId: project.id || "",
×
37
                    },
38
                },
39
            });
40

41
            return this.formatClustersTable(project, data);
×
42
        }
43
    }
44

45
    private formatAllClustersTable(clusters?: PaginatedOrgGroupView): CallToolResult {
46
        if (!clusters?.results?.length) {
×
47
            throw new Error("No clusters found.");
×
48
        }
49
        const formattedClusters = clusters.results
×
50
            .map((result) => {
51
                return (result.clusters || []).map((cluster) => {
×
52
                    return { ...result, ...cluster, clusters: undefined };
×
53
                });
54
            })
55
            .flat();
56
        if (!formattedClusters.length) {
×
57
            throw new Error("No clusters found.");
×
58
        }
59
        const rows = formattedClusters
×
60
            .map((cluster) => {
61
                return `${cluster.groupName} (${cluster.groupId}) | ${cluster.name}`;
×
62
            })
63
            .join("\n");
64
        return {
×
65
            content: [
66
                {
67
                    type: "text",
68
                    text: `Project | Cluster Name
69
----------------|----------------
70
${rows}`,
71
                },
72
            ],
73
        };
74
    }
75

76
    private formatClustersTable(project: Group, clusters?: PaginatedClusterDescription20240805): CallToolResult {
77
        if (!clusters?.results?.length) {
×
78
            throw new Error("No clusters found.");
×
79
        }
80
        const rows = clusters.results
×
81
            .map((cluster) => {
82
                const connectionString = cluster.connectionStrings?.standard || "N/A";
×
83
                const mongoDBVersion = cluster.mongoDBVersion || "N/A";
×
84
                return `${cluster.name} | ${cluster.stateName} | ${mongoDBVersion} | ${connectionString}`;
×
85
            })
86
            .join("\n");
87
        return {
×
88
            content: [
89
                {
90
                    type: "text",
91
                    text: `Here are your MongoDB Atlas clusters in project "${project.name}" (${project.id}):`,
92
                },
93
                {
94
                    type: "text",
95
                    text: `Cluster Name | State | MongoDB Version | Connection String
96
----------------|----------------|----------------|----------------|----------------
97
${rows}`,
98
                },
99
            ],
100
        };
101
    }
102
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc