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

mongodb-js / mongodb-mcp-server / 17657973871

11 Sep 2025 09:37PM UTC coverage: 81.59% (+0.4%) from 81.188%
17657973871

Pull #524

github

web-flow
Merge 7617674d0 into d6b84c7bd
Pull Request #524: chore: update smithery dockerfile to be closer to the official one

962 of 1279 branches covered (75.22%)

Branch coverage included in aggregate %.

4866 of 5864 relevant lines covered (82.98%)

46.3 hits per line

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

90.91
/src/tools/atlas/create/createAccessList.ts
1
import { z } from "zod";
2✔
2
import { type OperationType, type ToolArgs } from "../../tool.js";
3
import type { CallToolResult } from "@modelcontextprotocol/sdk/types.js";
4
import { AtlasToolBase } from "../atlasTool.js";
2✔
5
import { makeCurrentIpAccessListEntry, DEFAULT_ACCESS_LIST_COMMENT } from "../../../common/atlas/accessListUtils.js";
2✔
6
import { AtlasArgs, CommonArgs } from "../../args.js";
2✔
7

8
export const CreateAccessListArgs = {
2✔
9
    projectId: AtlasArgs.projectId().describe("Atlas project ID"),
2✔
10
    ipAddresses: z.array(AtlasArgs.ipAddress()).describe("IP addresses to allow access from").optional(),
2✔
11
    cidrBlocks: z.array(AtlasArgs.cidrBlock()).describe("CIDR blocks to allow access from").optional(),
2✔
12
    currentIpAddress: z.boolean().describe("Add the current IP address").default(false),
2✔
13
    comment: CommonArgs.string()
2✔
14
        .describe("Comment for the access list entries")
2✔
15
        .default(DEFAULT_ACCESS_LIST_COMMENT)
2✔
16
        .optional(),
2✔
17
};
2✔
18

19
export class CreateAccessListTool extends AtlasToolBase {
2✔
20
    public name = "atlas-create-access-list";
61✔
21
    protected description = "Allow Ip/CIDR ranges to access your MongoDB Atlas clusters.";
61✔
22
    public operationType: OperationType = "create";
61✔
23
    protected argsShape = {
61✔
24
        ...CreateAccessListArgs,
61✔
25
    };
61✔
26

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

38
        const ipInputs = (ipAddresses || []).map((ipAddress) => ({
1!
39
            groupId: projectId,
2✔
40
            ipAddress,
2✔
41
            comment: comment || DEFAULT_ACCESS_LIST_COMMENT,
2✔
42
        }));
1✔
43

44
        if (currentIpAddress) {
1✔
45
            const input = await makeCurrentIpAccessListEntry(
1✔
46
                this.session.apiClient,
1✔
47
                projectId,
1✔
48
                comment || DEFAULT_ACCESS_LIST_COMMENT
1✔
49
            );
1✔
50
            ipInputs.push(input);
1✔
51
        }
1✔
52

53
        const cidrInputs = (cidrBlocks || []).map((cidrBlock) => ({
1!
54
            groupId: projectId,
2✔
55
            cidrBlock,
2✔
56
            comment: comment || DEFAULT_ACCESS_LIST_COMMENT,
2✔
57
        }));
1✔
58

59
        const inputs = [...ipInputs, ...cidrInputs];
1✔
60

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

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