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

mongodb-js / mongodb-mcp-server / 16296888938

15 Jul 2025 03:00PM UTC coverage: 77.39% (-0.2%) from 77.581%
16296888938

Pull #375

github

web-flow
Merge b7eee8130 into 48bce63a0
Pull Request #375: chore(tests): use the newer `@vitest/eslint-plugin` package

499 of 688 branches covered (72.53%)

Branch coverage included in aggregate %.

0 of 1 new or added line in 1 file covered. (0.0%)

8 existing lines in 1 file now uncovered.

2828 of 3611 relevant lines covered (78.32%)

57.02 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";
4✔
2
import { CallToolResult } from "@modelcontextprotocol/sdk/types.js";
3
import { AtlasToolBase } from "../atlasTool.js";
4✔
4
import { ToolArgs, OperationType } from "../../tool.js";
5
import { Group } from "../../../common/atlas/openapi.js";
6

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

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

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

23
        if (!organizationId) {
2✔
24
            try {
2✔
25
                const organizations = await this.session.apiClient.listOrganizations();
2✔
26
                if (!organizations?.results?.length) {
2!
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];
2✔
32
                if (!firstOrg?.id) {
2!
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;
2✔
38
                assumedOrg = true;
2✔
39
            } catch {
2!
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
        }
2✔
45

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

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

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

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