• 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

81.67
/src/tools/atlas/read/listDBUsers.ts
1
import { z } from "zod";
2✔
2
import { CallToolResult } from "@modelcontextprotocol/sdk/types.js";
3
import { AtlasToolBase } from "../atlasTool.js";
2✔
4
import { ToolArgs, OperationType } from "../../tool.js";
5
import { DatabaseUserRole, UserScope } from "../../../common/atlas/openapi.js";
6

7
export class ListDBUsersTool extends AtlasToolBase {
2✔
8
    public name = "atlas-list-db-users";
34✔
9
    protected description = "List MongoDB Atlas database users";
34✔
10
    public operationType: OperationType = "read";
34✔
11
    protected argsShape = {
34✔
12
        projectId: z.string().describe("Atlas project ID to filter DB users"),
34✔
13
    };
34✔
14

15
    protected async execute({ projectId }: ToolArgs<typeof this.argsShape>): Promise<CallToolResult> {
2✔
16
        const data = await this.session.apiClient.listDatabaseUsers({
1✔
17
            params: {
1✔
18
                path: {
1✔
19
                    groupId: projectId,
1✔
20
                },
1✔
21
            },
1✔
22
        });
1✔
23

24
        if (!data?.results?.length) {
1!
25
            throw new Error("No database users found.");
×
UNCOV
26
        }
×
27

28
        const output =
1✔
29
            `Username | Roles | Scopes
1✔
30
----------------|----------------|----------------
31
` +
32
            data.results
1✔
33
                .map((user) => {
1✔
34
                    return `${user.username} | ${formatRoles(user.roles)} | ${formatScopes(user.scopes)}`;
1✔
35
                })
1✔
36
                .join("\n");
1✔
37
        return {
1✔
38
            content: [{ type: "text", text: output }],
1✔
39
        };
1✔
40
    }
1✔
41
}
2✔
42

43
function formatRoles(roles?: DatabaseUserRole[]) {
1✔
44
    if (!roles?.length) {
1!
45
        return "N/A";
×
UNCOV
46
    }
×
47
    return roles
1✔
48
        .map(
1✔
49
            (role) =>
1✔
50
                `${role.roleName}${role.databaseName ? `@${role.databaseName}${role.collectionName ? `:${role.collectionName}` : ""}` : ""}`
1!
51
        )
1✔
52
        .join(", ");
1✔
53
}
1✔
54

55
function formatScopes(scopes?: UserScope[]) {
1✔
56
    if (!scopes?.length) {
1✔
57
        return "All";
1✔
58
    }
1!
59
    return scopes.map((scope) => `${scope.type}:${scope.name}`).join(", ");
×
UNCOV
60
}
×
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