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

mongodb-js / mongodb-mcp-server / 16350134895

17 Jul 2025 04:04PM UTC coverage: 77.592% (+0.01%) from 77.581%
16350134895

Pull #372

github

web-flow
Merge 25e2b58dd into 84e63f62e
Pull Request #372: chore: Improve access list and connect experienece [MCP-5]

504 of 695 branches covered (72.52%)

Branch coverage included in aggregate %.

61 of 64 new or added lines in 6 files covered. (95.31%)

8 existing lines in 1 file now uncovered.

2879 of 3665 relevant lines covered (78.55%)

28.4 hits per line

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

87.76
/src/common/atlas/accessListUtils.ts
1
import { ApiClient } from "./apiClient.js";
2
import logger, { 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
) {
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
 */
26
export async function ensureCurrentIpInAccessList(apiClient: ApiClient, projectId: string): Promise<void> {
10✔
27
    const entry = await makeCurrentIpAccessListEntry(apiClient, projectId, DEFAULT_ACCESS_LIST_COMMENT);
10✔
28
    try {
10✔
29
        await apiClient.createProjectIpAccessList({
10✔
30
            params: { path: { groupId: projectId } },
10✔
31
            body: [entry],
10✔
32
        });
10✔
33
        logger.debug(
9✔
34
            LogId.atlasIpAccessListAdded,
9✔
35
            "accessListUtils",
9✔
36
            `IP access list created: ${JSON.stringify(entry)}`
9✔
37
        );
9✔
38
    } catch (err) {
9!
39
        if (err instanceof ApiClientError && err.response?.status === 409) {
1✔
40
            // 409 Conflict: entry already exists, log info
41
            logger.debug(
1✔
42
                LogId.atlasIpAccessListAdded,
1✔
43
                "accessListUtils",
1✔
44
                `IP address ${entry.ipAddress} is already present in the access list for project ${projectId}.`
1✔
45
            );
1✔
46
            return;
1✔
47
        }
1!
NEW
48
        logger.warning(
×
NEW
49
            LogId.atlasIpAccessListAddFailure,
×
NEW
50
            "accessListUtils",
×
51
            `Error adding IP access list: ${err instanceof Error ? err.message : String(err)}`
1!
52
        );
1✔
53
    }
1✔
54
}
10✔
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