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

mongodb-js / mongodb-mcp-server / 14618487127

23 Apr 2025 12:45PM UTC coverage: 78.42% (+1.7%) from 76.675%
14618487127

Pull #91

github

nirinchev
PR comments
Pull Request #91: chore: add tests for metadata actions

90 of 161 branches covered (55.9%)

Branch coverage included in aggregate %.

22 of 23 new or added lines in 4 files covered. (95.65%)

30 existing lines in 12 files now uncovered.

575 of 687 relevant lines covered (83.7%)

30.41 hits per line

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

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

7
export class ListProjectsTool extends AtlasToolBase {
18✔
8
    protected name = "atlas-list-projects";
18✔
9
    protected description = "List MongoDB Atlas projects";
18✔
10
    protected operationType: OperationType = "read";
18✔
11
    protected argsShape = {
18✔
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
        this.session.ensureAuthenticated();
1!
17

18
        const data = orgId
19
            ? await this.session.apiClient.listOrganizationProjects({
20
                  params: {
21
                      path: {
22
                          orgId,
23
                      },
24
                  },
25
              })
26
            : await this.session.apiClient.listProjects();
1!
UNCOV
27

×
28
        if (!data?.results?.length) {
29
            throw new Error("No projects found in your MongoDB Atlas account.");
30
        }
31

1✔
32
        // Format projects as a table
33
        const rows = data.results
8!
34
            .map((project) => {
8✔
35
                const createdAt = project.created ? new Date(project.created).toLocaleString() : "N/A";
36
                return `${project.name} | ${project.id} | ${createdAt}`;
37
            })
1✔
38
            .join("\n");
39
        const formattedProjects = `Project Name | Project ID | Created At
40
----------------| ----------------| ----------------
1✔
41
${rows}`;
42
        return {
43
            content: [{ type: "text", text: formattedProjects }],
44
        };
45
    }
46
}
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