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

mongodb-js / mongodb-mcp-server / 17657973871

11 Sep 2025 09:37PM UTC coverage: 81.59% (+0.4%) from 81.188%
17657973871

Pull #524

github

web-flow
Merge 7617674d0 into d6b84c7bd
Pull Request #524: chore: update smithery dockerfile to be closer to the official one

962 of 1279 branches covered (75.22%)

Branch coverage included in aggregate %.

4866 of 5864 relevant lines covered (82.98%)

46.3 hits per line

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

67.19
/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 type { ToolArgs } from "../../tool.js";
6
import { AtlasArgs } from "../../args.js";
2✔
7

8
export const ListProjectsArgs = {
2✔
9
    orgId: AtlasArgs.organizationId().describe("Atlas organization ID to filter projects").optional(),
2✔
10
};
2✔
11

12
export class ListProjectsTool extends AtlasToolBase {
2✔
13
    public name = "atlas-list-projects";
61✔
14
    protected description = "List MongoDB Atlas projects";
61✔
15
    public operationType: OperationType = "read";
61✔
16
    protected argsShape = {
61✔
17
        ...ListProjectsArgs,
61✔
18
    };
61✔
19

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

23
        if (!orgData?.results?.length) {
1!
24
            return {
×
25
                content: [{ type: "text", text: "No organizations found in your MongoDB Atlas account." }],
×
26
            };
×
27
        }
×
28

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

34
        const data = orgId
1!
35
            ? await this.session.apiClient.listOrganizationProjects({
×
36
                  params: {
×
37
                      path: {
×
38
                          orgId,
×
39
                      },
×
40
                  },
×
41
              })
×
42
            : await this.session.apiClient.listProjects();
1✔
43

44
        if (!data?.results?.length) {
1!
45
            return {
×
46
                content: [{ type: "text", text: `No projects found in organization ${orgId}.` }],
×
47
            };
×
48
        }
×
49

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