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

mongodb-js / mongodb-mcp-server / 16779406063

06 Aug 2025 02:11PM UTC coverage: 81.424% (-0.4%) from 81.781%
16779406063

Pull #420

github

web-flow
Merge cc01ac54e into a35d18dd6
Pull Request #420: chore: allow logging unredacted messages MCP-103

679 of 874 branches covered (77.69%)

Branch coverage included in aggregate %.

161 of 291 new or added lines in 16 files covered. (55.33%)

7 existing lines in 4 files now uncovered.

3485 of 4240 relevant lines covered (82.19%)

63.42 hits per line

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

52.38
/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";
2✔
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 {
2✔
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 {
2✔
26
    const regionConfigs = (cluster.replicationSpecs || [])
4!
27
        .map(
4✔
28
            (replicationSpec) =>
4✔
29
                (replicationSpec.regionConfigs || []) as {
4!
30
                    providerName: string;
31
                    electableSpecs?: {
32
                        instanceSize: string;
33
                    };
34
                    readOnlySpecs?: {
35
                        instanceSize: string;
36
                    };
37
                    analyticsSpecs?: {
38
                        instanceSize: string;
39
                    };
40
                }[]
41
        )
4✔
42
        .flat()
4✔
43
        .map((regionConfig) => {
4✔
44
            return {
4✔
45
                providerName: regionConfig.providerName,
4✔
46
                instanceSize:
4✔
47
                    regionConfig.electableSpecs?.instanceSize ||
4!
48
                    regionConfig.readOnlySpecs?.instanceSize ||
×
49
                    regionConfig.analyticsSpecs?.instanceSize,
×
50
            };
4✔
51
        });
4✔
52

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

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

66
export async function inspectCluster(apiClient: ApiClient, projectId: string, clusterName: string): Promise<Cluster> {
3✔
67
    try {
3✔
68
        const cluster = await apiClient.getCluster({
3✔
69
            params: {
3✔
70
                path: {
3✔
71
                    groupId: projectId,
3✔
72
                    clusterName,
3✔
73
                },
3✔
74
            },
3✔
75
        });
3✔
76
        return formatCluster(cluster);
3✔
77
    } catch (error) {
3!
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));
×
NEW
90
            logger.error({
×
NEW
91
                id: LogId.atlasInspectFailure,
×
NEW
92
                context: "inspect-cluster",
×
NEW
93
                message: `error inspecting cluster: ${err.message}`,
×
NEW
94
            });
×
95
            throw error;
×
96
        }
×
97
    }
×
98
}
3✔
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