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

mongodb-js / mongodb-mcp-server / 16292877152

15 Jul 2025 12:10PM UTC coverage: 77.385% (+2.1%) from 75.27%
16292877152

push

github

web-flow
chore(tests): switch to vitest (#363)

498 of 687 branches covered (72.49%)

Branch coverage included in aggregate %.

0 of 27 new or added lines in 2 files covered. (0.0%)

293 existing lines in 26 files now uncovered.

2828 of 3611 relevant lines covered (78.32%)

28.46 hits per line

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

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

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

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

18
        if (!orgData?.results?.length) {
1!
19
            throw new Error("No organizations found in your MongoDB Atlas account.");
×
UNCOV
20
        }
×
21

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

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

37
        if (!data?.results?.length) {
1!
38
            throw new Error("No projects found in your MongoDB Atlas account.");
×
UNCOV
39
        }
×
40

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