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

mongodb-js / mongodb-mcp-server / 16271253098

14 Jul 2025 03:37PM UTC coverage: 75.779%. First build
16271253098

Pull #359

github

web-flow
Merge f0a83b00b into b10990b77
Pull Request #359: feat: add streamable http [MCP-55]

388 of 602 branches covered (64.45%)

Branch coverage included in aggregate %.

24 of 30 new or added lines in 2 files covered. (80.0%)

901 of 1099 relevant lines covered (81.98%)

114.56 hits per line

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

48.57
/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 {
26
    const regionConfigs = (cluster.replicationSpecs || [])
6!
27
        .map(
28
            (replicationSpec) =>
29
                (replicationSpec.regionConfigs || []) as {
6!
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) => {
44
            return {
6✔
45
                providerName: regionConfig.providerName,
46
                instanceSize:
47
                    regionConfig.electableSpecs?.instanceSize ||
6!
48
                    regionConfig.readOnlySpecs?.instanceSize ||
49
                    regionConfig.analyticsSpecs?.instanceSize,
50
            };
51
        });
52

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

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

66
export async function inspectCluster(apiClient: ApiClient, projectId: string, clusterName: string): Promise<Cluster> {
67
    try {
4✔
68
        const cluster = await apiClient.getCluster({
4✔
69
            params: {
70
                path: {
71
                    groupId: projectId,
72
                    clusterName,
73
                },
74
            },
75
        });
76
        return formatCluster(cluster);
4✔
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