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

mongodb-js / mongodb-mcp-server / 14594832497

22 Apr 2025 12:31PM UTC coverage: 53.54% (+0.3%) from 53.208%
14594832497

Pull #88

github

nirinchev
fix tests
Pull Request #88: fix: tweak the connect tool to prefer preconfigured connection string

32 of 147 branches covered (21.77%)

Branch coverage included in aggregate %.

9 of 11 new or added lines in 2 files covered. (81.82%)

399 of 658 relevant lines covered (60.64%)

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

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

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

24
        if (!organizationId) {
×
25
            try {
×
26
                const organizations = await this.session.apiClient.listOrganizations();
×
27
                if (!organizations?.results?.length) {
×
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
                }
38
                organizationId = organizations.results[0].id;
×
39
                assumedOrg = true;
×
40
            } catch {
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

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

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

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

© 2026 Coveralls, Inc