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

mongodb-js / mongodb-mcp-server / 14590701503

22 Apr 2025 08:50AM UTC coverage: 50.118% (-0.9%) from 50.98%
14590701503

Pull #82

github

blva
lint
Pull Request #82: add create project tool

23 of 150 branches covered (15.33%)

Branch coverage included in aggregate %.

8 of 31 new or added lines in 3 files covered. (25.81%)

4 existing lines in 1 file now uncovered.

401 of 696 relevant lines covered (57.61%)

36.62 hits per line

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

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

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

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

NEW
24
        if (!organizationId) {
×
NEW
25
            try {
×
NEW
26
                const organizations = await this.session.apiClient.listOrganizations();
×
NEW
27
                if (!organizations?.results?.length) {
×
NEW
28
                    return {
×
29
                        content: [
30
                            {
31
                                type: "text",
32
                                text: "No organizations were found in your MongoDB Atlas account. Please create an organization first.",
33
                            },
34
                        ],
35
                        isError: true,
36
                    };
37
                }
NEW
38
                organizationId = organizations.results[0].id;
×
NEW
39
                assumedOrg = true;
×
40
            } catch {
NEW
41
                return {
×
42
                    content: [
43
                        {
44
                            type: "text",
45
                            text: "Could not search for organizations in your MongoDB Atlas account, please provide an organization ID or create one first.",
46
                        },
47
                    ],
48
                    isError: true,
49
                };
50
            }
51
        }
52

NEW
53
        const input = {
×
54
            name: projectName,
55
            orgId: organizationId,
56
        } as Group;
57

NEW
58
        await this.session.apiClient.createProject({
×
59
            body: input,
60
        });
61

NEW
62
        return {
×
63
            content: [
64
                {
65
                    type: "text",
66
                    text: `Project "${projectName}" created successfully${assumedOrg ? ` (using organizationId ${organizationId}).` : ""}.`,
×
67
                },
68
            ],
69
        };
70
    }
71
}
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