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

mongodb-js / mongodb-mcp-server / 17383377495

01 Sep 2025 04:51PM UTC coverage: 80.767% (-0.2%) from 80.945%
17383377495

Pull #500

github

web-flow
Merge 114c7457f into d471cdd0d
Pull Request #500: feat: add more details about atlas connect flow - MCP-124

893 of 1190 branches covered (75.04%)

Branch coverage included in aggregate %.

34 of 47 new or added lines in 2 files covered. (72.34%)

14 existing lines in 2 files now uncovered.

4541 of 5538 relevant lines covered (82.0%)

39.88 hits per line

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

82.69
/src/common/atlas/accessListUtils.ts
1
import type { ApiClient } from "./apiClient.js";
2
import { LogId } from "../logger.js";
2✔
3
import { ApiClientError } from "./apiClientError.js";
2✔
4

5
export const DEFAULT_ACCESS_LIST_COMMENT = "Added by MongoDB MCP Server to enable tool access";
2✔
6

7
export async function makeCurrentIpAccessListEntry(
11✔
8
    apiClient: ApiClient,
11✔
9
    projectId: string,
11✔
10
    comment: string = DEFAULT_ACCESS_LIST_COMMENT
11✔
11
): Promise<{ groupId: string; ipAddress: string; comment: string }> {
11✔
12
    const { currentIpv4Address } = await apiClient.getIpInfo();
11✔
13
    return {
11✔
14
        groupId: projectId,
11✔
15
        ipAddress: currentIpv4Address,
11✔
16
        comment,
11✔
17
    };
11✔
18
}
11✔
19

20
/**
21
 * Ensures the current public IP is in the access list for the given Atlas project.
22
 * If the IP is already present, this is a no-op.
23
 * @param apiClient The Atlas API client instance
24
 * @param projectId The Atlas project ID
25
 * @returns Promise<boolean> - true if a new IP access list entry was created, false if it already existed
26
 */
27
export async function ensureCurrentIpInAccessList(apiClient: ApiClient, projectId: string): Promise<boolean> {
10✔
28
    const entry = await makeCurrentIpAccessListEntry(apiClient, projectId, DEFAULT_ACCESS_LIST_COMMENT);
10✔
29
    try {
10✔
30
        await apiClient.createProjectIpAccessList({
10✔
31
            params: { path: { groupId: projectId } },
10✔
32
            body: [entry],
10✔
33
        });
10✔
34
        apiClient.logger.debug({
9✔
35
            id: LogId.atlasIpAccessListAdded,
9✔
36
            context: "accessListUtils",
9✔
37
            message: `IP access list created: ${JSON.stringify(entry)}`,
9✔
38
        });
9✔
39
        return true;
9✔
40
    } catch (err) {
9!
41
        if (err instanceof ApiClientError && err.response?.status === 409) {
1✔
42
            // 409 Conflict: entry already exists, log info
43
            apiClient.logger.debug({
1✔
44
                id: LogId.atlasIpAccessListAdded,
1✔
45
                context: "accessListUtils",
1✔
46
                message: `IP address ${entry.ipAddress} is already present in the access list for project ${projectId}.`,
1✔
47
            });
1✔
48
            return false;
1✔
49
        }
1!
50
        apiClient.logger.warning({
×
51
            id: LogId.atlasIpAccessListAddFailure,
×
52
            context: "accessListUtils",
×
53
            message: `Error adding IP access list: ${err instanceof Error ? err.message : String(err)}`,
1!
54
        });
1✔
55
    }
1!
NEW
56
    return false;
×
UNCOV
57
}
×
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