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

mongodb-js / mongodb-mcp-server / 21407817722

27 Jan 2026 05:43PM UTC coverage: 82.237% (+0.6%) from 81.592%
21407817722

Pull #870

github

web-flow
Merge 55eb849e0 into d13b21123
Pull Request #870: feat: allow session id to be passed externally MCP-369

1637 of 2100 branches covered (77.95%)

Branch coverage included in aggregate %.

94 of 135 new or added lines in 3 files covered. (69.63%)

77 existing lines in 8 files now uncovered.

7474 of 8979 relevant lines covered (83.24%)

112.72 hits per line

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

96.63
/src/resources/common/debug.ts
1
import { ReactiveResource } from "../resource.js";
3✔
2
import type { Telemetry } from "../../telemetry/telemetry.js";
3
import type { Session, UserConfig } from "../../lib.js";
4
import type { AtlasClusterConnectionInfo, ConnectionStateErrored } from "../../common/connectionManager.js";
5
import type { ConnectionStringInfo } from "../../common/connectionInfo.js";
6

7
type ConnectionStateDebuggingInformation = {
8
    readonly tag: "connected" | "connecting" | "disconnected" | "errored";
9
    readonly connectionStringInfo?: ConnectionStringInfo;
10
    readonly errorReason?: string;
11
    readonly connectedAtlasCluster?: AtlasClusterConnectionInfo;
12
};
13

14
export class DebugResource extends ReactiveResource<
3✔
15
    ConnectionStateDebuggingInformation,
16
    readonly ["connect", "disconnect", "close", "connection-error"]
17
> {
3✔
18
    constructor(session: Session, config: UserConfig, telemetry: Telemetry) {
3✔
19
        super({
162✔
20
            resourceConfiguration: {
162✔
21
                name: "debug-mongodb",
162✔
22
                uri: "debug://mongodb",
162✔
23
                config: {
162✔
24
                    description:
162✔
25
                        "Debugging information for MongoDB connectivity issues. Tracks the last connectivity attempt and error information.",
162✔
26
                },
162✔
27
            },
162✔
28
            options: {
162✔
29
                initial: { tag: "disconnected" },
162✔
30
                events: ["connect", "disconnect", "close", "connection-error"],
162✔
31
            },
162✔
32
            session,
162✔
33
            config,
162✔
34
            telemetry,
162✔
35
        });
162✔
36
    }
162✔
37
    reduce(
3✔
38
        eventName: "connect" | "disconnect" | "close" | "connection-error",
1,021✔
39
        event: ConnectionStateErrored | undefined
1,021✔
40
    ): ConnectionStateDebuggingInformation {
1,021✔
41
        switch (eventName) {
1,021✔
42
            case "connect":
1,021✔
43
                return { tag: "connected" };
403✔
44
            case "connection-error": {
1,021✔
45
                return {
50✔
46
                    tag: "errored",
50✔
47
                    connectionStringInfo: event?.connectionStringInfo,
50✔
48
                    connectedAtlasCluster: event?.connectedAtlasCluster,
50✔
49
                    errorReason:
50✔
50
                        event?.errorReason ??
50!
UNCOV
51
                        "Could not find a reason. This might be a bug in the MCP Server. Please open an issue in https://github.com/mongodb-js/mongodb-mcp-server.",
×
52
                };
50✔
53
            }
50✔
54
            case "disconnect":
1,021✔
55
            case "close":
1,021✔
56
                return { tag: "disconnected" };
568✔
57
        }
1,021✔
58
    }
1,021✔
59

60
    async toOutput(): Promise<string> {
3✔
61
        let result = "";
7✔
62

63
        switch (this.current.tag) {
7✔
64
            case "connected": {
7✔
65
                const searchIndexesSupported = await this.session.isSearchSupported();
2✔
66
                result += `The user is connected to the MongoDB cluster${searchIndexesSupported ? " with support for search indexes" : " without any support for search indexes"}.`;
2✔
67
                break;
2✔
68
            }
2✔
69
            case "errored":
7✔
70
                result += `The user is not connected to a MongoDB cluster because of an error.\n`;
3✔
71
                if (this.current.connectedAtlasCluster) {
3✔
72
                    result += `Attempted connecting to Atlas Cluster "${this.current.connectedAtlasCluster.clusterName}" in project with id "${this.current.connectedAtlasCluster.projectId}".\n`;
1✔
73
                }
1✔
74

75
                if (this.current.connectionStringInfo?.authType !== undefined) {
3✔
76
                    result += `The inferred authentication mechanism is "${this.current.connectionStringInfo.authType}".\n`;
2✔
77
                }
2✔
78
                result += `<error>${this.current.errorReason}</error>`;
3✔
79
                break;
3✔
80
            case "connecting":
7!
81
            case "disconnected":
7✔
82
                result += "The user is not connected to a MongoDB cluster.";
2✔
83
                break;
2✔
84
        }
7✔
85

86
        return result;
7✔
87
    }
7✔
88
}
3✔
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

© 2026 Coveralls, Inc