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

mongodb-js / mongodb-mcp-server / 16076959781

04 Jul 2025 03:28PM UTC coverage: 74.187% (-0.1%) from 74.286%
16076959781

Pull #339

github

web-flow
Merge 905959cd5 into d7d4aa9ae
Pull Request #339: chore: reinstate telemetry/docker change after revert MCP-49

233 of 394 branches covered (59.14%)

Branch coverage included in aggregate %.

20 of 24 new or added lines in 1 file covered. (83.33%)

816 of 1020 relevant lines covered (80.0%)

59.0 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

© 2025 Coveralls, Inc