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

mongodb-js / mongodb-mcp-server / 16275099623

14 Jul 2025 06:42PM UTC coverage: 77.524% (+2.3%) from 75.27%
16275099623

Pull #363

github

web-flow
Merge 3f10cbde7 into 184841400
Pull Request #363: chore(tests): switch to vitest

499 of 688 branches covered (72.53%)

Branch coverage included in aggregate %.

0 of 26 new or added lines in 2 files covered. (0.0%)

291 existing lines in 26 files now uncovered.

2833 of 3610 relevant lines covered (78.48%)

28.87 hits per line

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

90.54
/src/tools/atlas/create/createAccessList.ts
1
import { z } from "zod";
2✔
2
import { CallToolResult } from "@modelcontextprotocol/sdk/types.js";
3
import { AtlasToolBase } from "../atlasTool.js";
2✔
4
import { ToolArgs, OperationType } from "../../tool.js";
5

6
const DEFAULT_COMMENT = "Added by Atlas MCP";
2✔
7

8
export class CreateAccessListTool extends AtlasToolBase {
2✔
9
    public name = "atlas-create-access-list";
34✔
10
    protected description = "Allow Ip/CIDR ranges to access your MongoDB Atlas clusters.";
34✔
11
    public operationType: OperationType = "create";
34✔
12
    protected argsShape = {
34✔
13
        projectId: z.string().describe("Atlas project ID"),
34✔
14
        ipAddresses: z
34✔
15
            .array(z.string().ip({ version: "v4" }))
34✔
16
            .describe("IP addresses to allow access from")
34✔
17
            .optional(),
34✔
18
        cidrBlocks: z.array(z.string().cidr()).describe("CIDR blocks to allow access from").optional(),
34✔
19
        currentIpAddress: z.boolean().describe("Add the current IP address").default(false),
34✔
20
        comment: z.string().describe("Comment for the access list entries").default(DEFAULT_COMMENT).optional(),
34✔
21
    };
34✔
22

23
    protected async execute({
2✔
24
        projectId,
1✔
25
        ipAddresses,
1✔
26
        cidrBlocks,
1✔
27
        comment,
1✔
28
        currentIpAddress,
1✔
29
    }: ToolArgs<typeof this.argsShape>): Promise<CallToolResult> {
1✔
30
        if (!ipAddresses?.length && !cidrBlocks?.length && !currentIpAddress) {
1!
31
            throw new Error("One of  ipAddresses, cidrBlocks, currentIpAddress must be provided.");
×
UNCOV
32
        }
×
33

34
        const ipInputs = (ipAddresses || []).map((ipAddress) => ({
1!
35
            groupId: projectId,
2✔
36
            ipAddress,
2✔
37
            comment: comment || DEFAULT_COMMENT,
2✔
38
        }));
1✔
39

40
        if (currentIpAddress) {
1✔
41
            const currentIp = await this.session.apiClient.getIpInfo();
1✔
42
            const input = {
1✔
43
                groupId: projectId,
1✔
44
                ipAddress: currentIp.currentIpv4Address,
1✔
45
                comment: comment || DEFAULT_COMMENT,
1✔
46
            };
1✔
47
            ipInputs.push(input);
1✔
48
        }
1✔
49

50
        const cidrInputs = (cidrBlocks || []).map((cidrBlock) => ({
1!
51
            groupId: projectId,
2✔
52
            cidrBlock,
2✔
53
            comment: comment || DEFAULT_COMMENT,
2✔
54
        }));
1✔
55

56
        const inputs = [...ipInputs, ...cidrInputs];
1✔
57

58
        await this.session.apiClient.createProjectIpAccessList({
1✔
59
            params: {
1✔
60
                path: {
1✔
61
                    groupId: projectId,
1✔
62
                },
1✔
63
            },
1✔
64
            body: inputs,
1✔
65
        });
1✔
66

67
        return {
1✔
68
            content: [
1✔
69
                {
1✔
70
                    type: "text",
1✔
71
                    text: `IP/CIDR ranges added to access list for project ${projectId}.`,
1✔
72
                },
1✔
73
            ],
1✔
74
        };
1✔
75
    }
1✔
76
}
2✔
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