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

mongodb-js / mongodb-mcp-server / 17159941478

22 Aug 2025 03:54PM UTC coverage: 81.682% (-0.3%) from 82.022%
17159941478

Pull #465

github

web-flow
Merge 9874379ed into 99a9b6a04
Pull Request #465: fix: wrap more tool responses in untrusted-user-data tags

852 of 1073 branches covered (79.4%)

Branch coverage included in aggregate %.

98 of 119 new or added lines in 17 files covered. (82.35%)

12 existing lines in 6 files now uncovered.

4343 of 5287 relevant lines covered (82.14%)

70.39 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!
NEW
20
            return {
×
NEW
21
                content: [{ type: "text", text: "No organizations found in your MongoDB Atlas account." }],
×
NEW
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,
×
35
                      },
×
36
                  },
×
37
              })
×
38
            : await this.session.apiClient.listProjects();
1✔
39

40
        if (!data?.results?.length) {
1!
NEW
41
            return {
×
NEW
42
                content: [{ type: "text", text: `No projects found in organization ${orgId}.` }],
×
NEW
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