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

mongodb-js / mongodb-mcp-server / 16123662219

07 Jul 2025 05:25PM UTC coverage: 60.879% (-13.3%) from 74.187%
16123662219

Pull #343

github

web-flow
Merge 24298edad into 5b7ba55e0
Pull Request #343: fix: turn atlas-connect-cluster async

183 of 411 branches covered (44.53%)

Branch coverage included in aggregate %.

0 of 34 new or added lines in 1 file covered. (0.0%)

129 existing lines in 15 files now uncovered.

704 of 1046 relevant lines covered (67.3%)

59.03 hits per line

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

0.0
/src/common/atlas/cluster.ts
1
import { ClusterDescription20240805, FlexClusterDescription20241113 } from "./openapi.js";
2
import { ApiClient } from "./apiClient.js";
3
import logger, { LogId } from "../../logger.js";
4

5
export interface Cluster {
6
    name?: string;
7
    instanceType: "FREE" | "DEDICATED" | "FLEX";
8
    instanceSize?: string;
9
    state?: "IDLE" | "CREATING" | "UPDATING" | "DELETING" | "REPAIRING";
10
    mongoDBVersion?: string;
11
    connectionString?: string;
12
}
13

14
export function formatFlexCluster(cluster: FlexClusterDescription20241113): Cluster {
15
    return {
×
16
        name: cluster.name,
17
        instanceType: "FLEX",
18
        instanceSize: undefined,
19
        state: cluster.stateName,
20
        mongoDBVersion: cluster.mongoDBVersion,
21
        connectionString: cluster.connectionStrings?.standardSrv || cluster.connectionStrings?.standard,
×
22
    };
23
}
24

25
export function formatCluster(cluster: ClusterDescription20240805): Cluster {
UNCOV
26
    const regionConfigs = (cluster.replicationSpecs || [])
×
27
        .map(
28
            (replicationSpec) =>
UNCOV
29
                (replicationSpec.regionConfigs || []) as {
×
30
                    providerName: string;
31
                    electableSpecs?: {
32
                        instanceSize: string;
33
                    };
34
                    readOnlySpecs?: {
35
                        instanceSize: string;
36
                    };
37
                    analyticsSpecs?: {
38
                        instanceSize: string;
39
                    };
40
                }[]
41
        )
42
        .flat()
43
        .map((regionConfig) => {
UNCOV
44
            return {
×
45
                providerName: regionConfig.providerName,
46
                instanceSize:
47
                    regionConfig.electableSpecs?.instanceSize ||
×
48
                    regionConfig.readOnlySpecs?.instanceSize ||
49
                    regionConfig.analyticsSpecs?.instanceSize,
50
            };
51
        });
52

UNCOV
53
    const instanceSize = regionConfigs[0]?.instanceSize ?? "UNKNOWN";
×
UNCOV
54
    const clusterInstanceType = instanceSize == "M0" ? "FREE" : "DEDICATED";
×
55

UNCOV
56
    return {
×
57
        name: cluster.name,
58
        instanceType: clusterInstanceType,
59
        instanceSize: clusterInstanceType == "DEDICATED" ? instanceSize : undefined,
×
60
        state: cluster.stateName,
61
        mongoDBVersion: cluster.mongoDBVersion,
62
        connectionString: cluster.connectionStrings?.standardSrv || cluster.connectionStrings?.standard,
×
63
    };
64
}
65

66
export async function inspectCluster(apiClient: ApiClient, projectId: string, clusterName: string): Promise<Cluster> {
UNCOV
67
    try {
×
UNCOV
68
        const cluster = await apiClient.getCluster({
×
69
            params: {
70
                path: {
71
                    groupId: projectId,
72
                    clusterName,
73
                },
74
            },
75
        });
UNCOV
76
        return formatCluster(cluster);
×
77
    } catch (error) {
78
        try {
×
79
            const cluster = await apiClient.getFlexCluster({
×
80
                params: {
81
                    path: {
82
                        groupId: projectId,
83
                        name: clusterName,
84
                    },
85
                },
86
            });
87
            return formatFlexCluster(cluster);
×
88
        } catch (flexError) {
89
            const err = flexError instanceof Error ? flexError : new Error(String(flexError));
×
90
            logger.error(LogId.atlasInspectFailure, "inspect-cluster", `error inspecting cluster: ${err.message}`);
×
91
            throw error;
×
92
        }
93
    }
94
}
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