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

mongodb-js / mongodb-mcp-server / 17161333946

22 Aug 2025 05:03PM UTC coverage: 81.909% (-0.1%) from 82.022%
17161333946

Pull #471

github

web-flow
Merge 903825dd4 into 49707be70
Pull Request #471: fix: atlas connectCluster defaults to readOnly DB roles - MCP-125

874 of 1092 branches covered (80.04%)

Branch coverage included in aggregate %.

25 of 25 new or added lines in 2 files covered. (100.0%)

49 existing lines in 10 files now uncovered.

4360 of 5298 relevant lines covered (82.3%)

70.64 hits per line

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

95.83
/src/tools/mongodb/read/collectionIndexes.ts
1
import type { CallToolResult } from "@modelcontextprotocol/sdk/types.js";
2
import { DbOperationArgs, MongoDBToolBase } from "../mongodbTool.js";
2✔
3
import type { ToolArgs, OperationType } from "../../tool.js";
4
import { formatUntrustedData } from "../../tool.js";
2✔
5

6
export class CollectionIndexesTool extends MongoDBToolBase {
2✔
7
    public name = "collection-indexes";
80✔
8
    protected description = "Describe the indexes for a collection";
80✔
9
    protected argsShape = DbOperationArgs;
80✔
10
    public operationType: OperationType = "read";
80✔
11

12
    protected async execute({ database, collection }: ToolArgs<typeof DbOperationArgs>): Promise<CallToolResult> {
2✔
13
        const provider = await this.ensureConnected();
10✔
14
        const indexes = await provider.getIndexes(database, collection);
8✔
15

16
        return {
4✔
17
            content: formatUntrustedData(
4✔
18
                `Found ${indexes.length} indexes in the collection "${collection}":`,
4✔
19
                indexes.length > 0
4✔
20
                    ? indexes
4✔
21
                          .map((index) => `Name: "${index.name}", definition: ${JSON.stringify(index.key)}`)
4✔
22
                          .join("\n")
4!
UNCOV
23
                    : undefined
×
24
            ),
10✔
25
        };
10✔
26
    }
10✔
27

28
    protected handleError(
2✔
29
        error: unknown,
6✔
30
        args: ToolArgs<typeof this.argsShape>
6✔
31
    ): Promise<CallToolResult> | CallToolResult {
6✔
32
        if (error instanceof Error && "codeName" in error && error.codeName === "NamespaceNotFound") {
6✔
33
            return {
4✔
34
                content: [
4✔
35
                    {
4✔
36
                        text: `The indexes for "${args.database}.${args.collection}" cannot be determined because the collection does not exist.`,
4✔
37
                        type: "text",
4✔
38
                    },
4✔
39
                ],
4✔
40
            };
4✔
41
        }
4✔
42

43
        return super.handleError(error, args);
2✔
44
    }
6✔
45
}
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