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

mongodb-js / mongodb-mcp-server / 14614164106

23 Apr 2025 09:00AM UTC coverage: 76.675% (+23.5%) from 53.208%
14614164106

Pull #83

github

fmenezes
fix: styles
Pull Request #83: chore: add atlas tests

81 of 152 branches covered (53.29%)

Branch coverage included in aggregate %.

28 of 39 new or added lines in 6 files covered. (71.79%)

4 existing lines in 3 files now uncovered.

560 of 684 relevant lines covered (81.87%)

26.26 hits per line

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

73.33
/src/tools/atlas/createProject.ts
1
import { z } from "zod";
16✔
2
import { CallToolResult } from "@modelcontextprotocol/sdk/types.js";
3
import { AtlasToolBase } from "./atlasTool.js";
16✔
4
import { ToolArgs, OperationType } from "../tool.js";
5
import { Group } from "../../common/atlas/openapi.js";
6

7
export class CreateProjectTool extends AtlasToolBase {
16✔
8
    protected name = "atlas-create-project";
16✔
9
    protected description = "Create a MongoDB Atlas project";
16✔
10
    protected operationType: OperationType = "create";
16✔
11
    protected argsShape = {
16✔
12
        projectName: z.string().optional().describe("Name for the new project"),
13
        organizationId: z.string().optional().describe("Organization ID for the new project"),
14
    };
15

16
    protected async execute({ projectName, organizationId }: ToolArgs<typeof this.argsShape>): Promise<CallToolResult> {
17
        this.session.ensureAuthenticated();
1✔
18
        let assumedOrg = false;
1✔
19

20
        if (!projectName) {
1!
21
            projectName = "Atlas Project";
×
22
        }
23

24
        if (!organizationId) {
1✔
25
            try {
1✔
26
                const organizations = await this.session.apiClient.listOrganizations();
1✔
27
                if (!organizations?.results?.length) {
1!
NEW
28
                    throw new Error(
×
29
                        "No organizations were found in your MongoDB Atlas account. Please create an organization first."
30
                    );
31
                }
32
                organizationId = organizations.results[0].id;
1✔
33
                assumedOrg = true;
1✔
34
            } catch {
NEW
35
                throw new Error(
×
36
                    "Could not search for organizations in your MongoDB Atlas account, please provide an organization ID or create one first."
37
                );
38
            }
39
        }
40

41
        const input = {
1✔
42
            name: projectName,
43
            orgId: organizationId,
44
        } as Group;
45

46
        const group = await this.session.apiClient.createProject({
1✔
47
            body: input,
48
        });
49

50
        if (!group?.id) {
1!
NEW
51
            throw new Error("Failed to create project");
×
52
        }
53

54
        return {
1✔
55
            content: [
56
                {
57
                    type: "text",
58
                    text: `Project "${projectName}" created successfully${assumedOrg ? ` (using organizationId ${organizationId}).` : ""}.`,
1!
59
                },
60
            ],
61
        };
62
    }
63
}
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