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

mongodb-js / mongodb-mcp-server / 14618487127

23 Apr 2025 12:45PM UTC coverage: 78.42% (+1.7%) from 76.675%
14618487127

Pull #91

github

nirinchev
PR comments
Pull Request #91: chore: add tests for metadata actions

90 of 161 branches covered (55.9%)

Branch coverage included in aggregate %.

22 of 23 new or added lines in 4 files covered. (95.65%)

30 existing lines in 12 files now uncovered.

575 of 687 relevant lines covered (83.7%)

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

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

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

1✔
24
        if (!organizationId) {
1✔
25
            try {
1✔
26
                const organizations = await this.session.apiClient.listOrganizations();
1!
UNCOV
27
                if (!organizations?.results?.length) {
×
28
                    throw new Error(
29
                        "No organizations were found in your MongoDB Atlas account. Please create an organization first."
30
                    );
31
                }
1✔
32
                organizationId = organizations.results[0].id;
1✔
33
                assumedOrg = true;
UNCOV
34
            } catch {
×
35
                throw new Error(
36
                    "Could not search for organizations in your MongoDB Atlas account, please provide an organization ID or create one first."
37
                );
38
            }
39
        }
40

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

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

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

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