• 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

86.27
/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(
13✔
8
    apiClient: ApiClient,
13✔
9
    projectId: string,
13✔
10
    comment: string = DEFAULT_ACCESS_LIST_COMMENT
13✔
11
) {
13✔
12
    const { currentIpv4Address } = await apiClient.getIpInfo();
13✔
13
    return {
13✔
14
        groupId: projectId,
13✔
15
        ipAddress: currentIpv4Address,
13✔
16
        comment,
13✔
17
    };
13✔
18
}
13✔
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> {
12✔
27
    const entry = await makeCurrentIpAccessListEntry(apiClient, projectId, DEFAULT_ACCESS_LIST_COMMENT);
12✔
28
    try {
12✔
29
        await apiClient.createProjectIpAccessList({
12✔
30
            params: { path: { groupId: projectId } },
12✔
31
            body: [entry],
12✔
32
        });
12✔
33
        logger.debug({
10✔
34
            id: LogId.atlasIpAccessListAdded,
10✔
35
            context: "accessListUtils",
10✔
36
            message: `IP access list created: ${JSON.stringify(entry)}`,
10✔
37
        });
10✔
38
    } catch (err) {
10✔
39
        if (err instanceof ApiClientError && err.response?.status === 409) {
2✔
40
            // 409 Conflict: entry already exists, log info
41
            logger.debug({
2✔
42
                id: LogId.atlasIpAccessListAdded,
2✔
43
                context: "accessListUtils",
2✔
44
                message: `IP address ${entry.ipAddress} is already present in the access list for project ${projectId}.`,
2✔
45
            });
2✔
46
            return;
2✔
47
        }
2!
NEW
48
        logger.warning({
×
NEW
49
            id: LogId.atlasIpAccessListAddFailure,
×
NEW
50
            context: "accessListUtils",
×
51
            message: `Error adding IP access list: ${err instanceof Error ? err.message : String(err)}`,
2!
52
        });
2✔
53
    }
2✔
54
}
12✔
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