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

mongodb-js / mongodb-mcp-server / 14667012576

25 Apr 2025 02:31PM UTC coverage: 81.696%. Remained the same
14667012576

Pull #125

github

fmenezes
fix: duplicated v on version bump
Pull Request #125: fix: duplicated v on version bump

128 of 208 branches covered (61.54%)

Branch coverage included in aggregate %.

720 of 830 relevant lines covered (86.75%)

44.18 hits per line

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

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

7
export class CreateProjectTool extends AtlasToolBase {
31✔
8
    protected name = "atlas-create-project";
27✔
9
    protected description = "Create a MongoDB Atlas project";
27✔
10
    protected operationType: OperationType = "create";
27✔
11
    protected argsShape = {
27✔
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
                organizationId = organizations.results[0].id;
1✔
32
                assumedOrg = true;
1✔
33
            } catch {
34
                throw new Error(
×
35
                    "Could not search for organizations in your MongoDB Atlas account, please provide an organization ID or create one first."
36
                );
37
            }
38
        }
39

40
        const input = {
1✔
41
            name: projectName,
42
            orgId: organizationId,
43
        } as Group;
44

45
        const group = await this.session.apiClient.createProject({
1✔
46
            body: input,
47
        });
48

49
        if (!group?.id) {
1!
50
            throw new Error("Failed to create project");
×
51
        }
52

53
        return {
1✔
54
            content: [
55
                {
56
                    type: "text",
57
                    text: `Project "${projectName}" created successfully${assumedOrg ? ` (using organizationId ${organizationId}).` : ""}.`,
1!
58
                },
59
            ],
60
        };
61
    }
62
}
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