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

mongodb-js / mongodb-mcp-server / 17158105595

22 Aug 2025 02:33PM UTC coverage: 72.664% (-9.4%) from 82.024%
17158105595

push

github

web-flow
chore(deps): bump the npm_and_yarn group with 2 updates (#415)

749 of 884 branches covered (84.73%)

Branch coverage included in aggregate %.

3730 of 5280 relevant lines covered (70.64%)

64.72 hits per line

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

22.41
/src/tools/atlas/create/createProject.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
import { Group } from "../../../common/atlas/openapi.js";
6

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

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

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

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

46
        const input = {
×
47
            name: projectName,
×
48
            orgId: organizationId,
×
49
        } as Group;
×
50

51
        const group = await this.session.apiClient.createProject({
×
52
            body: input,
×
53
        });
×
54

55
        if (!group?.id) {
×
56
            throw new Error("Failed to create project");
×
57
        }
×
58

59
        return {
×
60
            content: [
×
61
                {
×
62
                    type: "text",
×
63
                    text: `Project "${projectName}" created successfully${assumedOrg ? ` (using organizationId ${organizationId}).` : ""}.`,
×
64
                },
×
65
            ],
×
66
        };
×
67
    }
×
68
}
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

© 2026 Coveralls, Inc