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

mongodb-js / mongodb-mcp-server / 16292766252

15 Jul 2025 12:05PM UTC coverage: 77.587%. First build
16292766252

Pull #363

github

web-flow
Merge b254655f9 into ab6aae635
Pull Request #363: chore(tests): switch to vitest MCP-65

501 of 690 branches covered (72.61%)

Branch coverage included in aggregate %.

0 of 27 new or added lines in 2 files covered. (0.0%)

2836 of 3611 relevant lines covered (78.54%)

28.75 hits per line

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

66.15
/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";
34✔
9
    protected description = "Create a MongoDB Atlas project";
34✔
10
    public operationType: OperationType = "create";
34✔
11
    protected argsShape = {
34✔
12
        projectName: z.string().optional().describe("Name for the new project"),
34✔
13
        organizationId: z.string().optional().describe("Organization ID for the new project"),
34✔
14
    };
34✔
15

16
    protected async execute({ projectName, organizationId }: ToolArgs<typeof this.argsShape>): Promise<CallToolResult> {
2✔
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 {
1!
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
        }
1✔
45

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

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

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

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

© 2025 Coveralls, Inc