• 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

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

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

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

25
        if (!data?.results?.length) {
1!
NEW
26
            return {
×
NEW
27
                content: [{ type: "text", text: " No database users found" }],
×
NEW
28
            };
×
UNCOV
29
        }
×
30

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

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

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