• 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

64.1
/src/tools/atlas/read/listAlerts.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

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

15
    protected async execute({ projectId }: ToolArgs<typeof this.argsShape>): Promise<CallToolResult> {
2✔
16
        const data = await this.session.apiClient.listAlerts({
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
            return { content: [{ type: "text", text: "No alerts found in your MongoDB Atlas project." }] };
1✔
26
        }
1!
27

28
        // Format alerts as a table
29
        const output =
×
30
            `Alert ID | Status | Created | Updated | Type | Comment
×
31
----------|---------|----------|----------|------|--------
32
` +
33
            data.results
×
34
                .map((alert) => {
×
35
                    const created = alert.created ? new Date(alert.created).toLocaleString() : "N/A";
×
36
                    const updated = alert.updated ? new Date(alert.updated).toLocaleString() : "N/A";
×
37
                    const comment = alert.acknowledgementComment ?? "N/A";
×
38
                    return `${alert.id} | ${alert.status} | ${created} | ${updated} | ${alert.eventTypeName} | ${comment}`;
×
39
                })
×
40
                .join("\n");
×
41

42
        return {
×
NEW
43
            content: formatUntrustedData(`Found ${data.results.length} alerts in project ${projectId}`, output),
×
44
        };
×
45
    }
1✔
46
}
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