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

mongodb-js / mongodb-mcp-server / 14669311657

25 Apr 2025 04:38PM UTC coverage: 81.696%. Remained the same
14669311657

Pull #128

github

fmenezes
chore: follow tools structure in atlas tools
Pull Request #128: chore: follow tools structure in atlas tools

128 of 208 branches covered (61.54%)

Branch coverage included in aggregate %.

20 of 20 new or added lines in 11 files covered. (100.0%)

720 of 830 relevant lines covered (86.75%)

44.06 hits per line

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

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

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

15
    protected async execute({ orgId }: ToolArgs<typeof this.argsShape>): Promise<CallToolResult> {
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.");
×
20
        }
21

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

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

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

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