• 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

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

8
export const ListDBUsersArgs = {
2✔
9
    projectId: AtlasArgs.projectId().describe("Atlas project ID to filter DB users"),
2✔
10
};
2✔
11

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

20
    protected async execute({ projectId }: ToolArgs<typeof this.argsShape>): Promise<CallToolResult> {
2✔
21
        const data = await this.session.apiClient.listDatabaseUsers({
1✔
22
            params: {
1✔
23
                path: {
1✔
24
                    groupId: projectId,
1✔
25
                },
1✔
26
            },
1✔
27
        });
1✔
28

29
        if (!data?.results?.length) {
1!
30
            return {
×
31
                content: [{ type: "text", text: " No database users found" }],
×
32
            };
×
33
        }
×
34

35
        const output =
1✔
36
            `Username | Roles | Scopes
1✔
37
----------------|----------------|----------------
38
` +
39
            data.results
1✔
40
                .map((user) => {
1✔
41
                    return `${user.username} | ${formatRoles(user.roles)} | ${formatScopes(user.scopes)}`;
1✔
42
                })
1✔
43
                .join("\n");
1✔
44
        return {
1✔
45
            content: formatUntrustedData(`Found ${data.results.length} database users in project ${projectId}`, output),
1✔
46
        };
1✔
47
    }
1✔
48
}
2✔
49

50
function formatRoles(roles?: DatabaseUserRole[]): string {
1✔
51
    if (!roles?.length) {
1!
52
        return "N/A";
×
53
    }
×
54
    return roles
1✔
55
        .map(
1✔
56
            (role) =>
1✔
57
                `${role.roleName}${role.databaseName ? `@${role.databaseName}${role.collectionName ? `:${role.collectionName}` : ""}` : ""}`
1!
58
        )
1✔
59
        .join(", ");
1✔
60
}
1✔
61

62
function formatScopes(scopes?: UserScope[]): string {
1✔
63
    if (!scopes?.length) {
1✔
64
        return "All";
1✔
65
    }
1!
66
    return scopes.map((scope) => `${scope.type}:${scope.name}`).join(", ");
×
67
}
×
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