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

mongodb-js / mongodb-mcp-server / 16021803645

02 Jul 2025 09:46AM UTC coverage: 75.857%. Remained the same
16021803645

Pull #338

github

web-flow
Merge 96af690c7 into fd28e63fb
Pull Request #338: fix: Broken internal urls in readme

235 of 392 branches covered (59.95%)

Branch coverage included in aggregate %.

827 of 1008 relevant lines covered (82.04%)

59.61 hits per line

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

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

7
export class CreateProjectTool extends AtlasToolBase {
8
    protected name = "atlas-create-project";
33✔
9
    protected description = "Create a MongoDB Atlas project";
33✔
10
    protected operationType: OperationType = "create";
33✔
11
    protected argsShape = {
33✔
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
        let assumedOrg = false;
1✔
18

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

23
        if (!organizationId) {
1✔
24
            try {
1✔
25
                const organizations = await this.session.apiClient.listOrganizations();
1✔
26
                if (!organizations?.results?.length) {
1!
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];
1✔
32
                if (!firstOrg?.id) {
1!
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;
1✔
38
                assumedOrg = true;
1✔
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 = {
1✔
47
            name: projectName,
48
            orgId: organizationId,
49
        } as Group;
50

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

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

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