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

mongodb-js / mongodb-mcp-server / 17161333946

22 Aug 2025 05:03PM UTC coverage: 81.909% (-0.1%) from 82.022%
17161333946

Pull #471

github

web-flow
Merge 903825dd4 into 49707be70
Pull Request #471: fix: atlas connectCluster defaults to readOnly DB roles - MCP-125

874 of 1092 branches covered (80.04%)

Branch coverage included in aggregate %.

25 of 25 new or added lines in 2 files covered. (100.0%)

49 existing lines in 10 files now uncovered.

4360 of 5298 relevant lines covered (82.3%)

70.64 hits per line

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

65.57
/src/tools/atlas/read/listProjects.ts
1
import type { CallToolResult } from "@modelcontextprotocol/sdk/types.js";
2
import { AtlasToolBase } from "../atlasTool.js";
2✔
3
import type { OperationType } from "../../tool.js";
4
import { formatUntrustedData } from "../../tool.js";
2✔
5
import { z } from "zod";
2✔
6
import type { ToolArgs } from "../../tool.js";
7

8
export class ListProjectsTool extends AtlasToolBase {
2✔
9
    public name = "atlas-list-projects";
80✔
10
    protected description = "List MongoDB Atlas projects";
80✔
11
    public operationType: OperationType = "read";
80✔
12
    protected argsShape = {
80✔
13
        orgId: z.string().describe("Atlas organization ID to filter projects").optional(),
80✔
14
    };
80✔
15

16
    protected async execute({ orgId }: ToolArgs<typeof this.argsShape>): Promise<CallToolResult> {
2✔
17
        const orgData = await this.session.apiClient.listOrganizations();
1✔
18

19
        if (!orgData?.results?.length) {
1!
20
            return {
×
UNCOV
21
                content: [{ type: "text", text: "No organizations found in your MongoDB Atlas account." }],
×
UNCOV
22
            };
×
UNCOV
23
        }
×
24

25
        const orgs: Record<string, string> = orgData.results
1✔
26
            .map((org) => [org.id || "", org.name])
1!
27
            .filter(([id]) => id)
1✔
28
            .reduce((acc, [id, name]) => ({ ...acc, [id as string]: name }), {});
1✔
29

30
        const data = orgId
1!
31
            ? await this.session.apiClient.listOrganizationProjects({
×
32
                  params: {
×
33
                      path: {
×
34
                          orgId,
×
UNCOV
35
                      },
×
UNCOV
36
                  },
×
UNCOV
37
              })
×
38
            : await this.session.apiClient.listProjects();
1✔
39

40
        if (!data?.results?.length) {
1!
UNCOV
41
            return {
×
UNCOV
42
                content: [{ type: "text", text: `No projects found in organization ${orgId}.` }],
×
UNCOV
43
            };
×
UNCOV
44
        }
×
45

46
        // Format projects as a table
47
        const rows = data.results
1✔
48
            .map((project) => {
1✔
49
                const createdAt = project.created ? new Date(project.created).toLocaleString() : "N/A";
19!
50
                const orgName = orgs[project.orgId] ?? "N/A";
19!
51
                return `${project.name} | ${project.id} | ${orgName} | ${project.orgId} | ${createdAt}`;
19✔
52
            })
1✔
53
            .join("\n");
1✔
54
        const formattedProjects = `Project Name | Project ID | Organization Name | Organization ID | Created At
1✔
55
----------------| ----------------| ----------------| ----------------| ----------------
56
${rows}`;
1✔
57
        return {
1✔
58
            content: formatUntrustedData(`Found ${rows.length} projects`, formattedProjects),
1✔
59
        };
1✔
60
    }
1✔
61
}
2✔
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