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

mongodb-js / mongodb-mcp-server / 17155288437

22 Aug 2025 12:29PM UTC coverage: 82.014% (-0.03%) from 82.04%
17155288437

Pull #468

github

web-flow
Merge 3bb127c20 into ca68195c4
Pull Request #468: chore: update readme with the new tool and resources

855 of 1075 branches covered (79.53%)

Branch coverage included in aggregate %.

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

97 existing lines in 8 files now uncovered.

4357 of 5280 relevant lines covered (82.52%)

70.4 hits per line

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

0.85
/src/index.ts
1
#!/usr/bin/env node
2✔
2

3
function enableFipsIfRequested(): void {
×
4
    let fipsError: Error | undefined;
×
5
    const tlsFIPSMode = process.argv.includes("--tlsFIPSMode");
×
6

7
    if (tlsFIPSMode) {
×
8
        try {
×
9
            // eslint-disable-next-line
10
            require("crypto").setFips(1);
×
11
        } catch (err: unknown) {
×
12
            fipsError ??= err as Error;
×
13
        }
×
14
    }
×
15

16
    if (tlsFIPSMode) {
×
17
        if (!fipsError && !crypto.getFips()) {
×
18
            fipsError = new Error("FIPS mode not enabled despite requested due to unknown error.");
×
19
        }
×
20
    }
×
21

22
    if (fipsError) {
×
23
        if (process.config.variables.node_shared_openssl) {
×
24
            console.error(
×
25
                "Could not enable FIPS mode. Please ensure that your system OpenSSL installation supports FIPS."
×
26
            );
×
27
        } else {
×
28
            console.error("Could not enable FIPS mode. This installation does not appear to support FIPS.");
×
29
        }
×
30
        console.error("Error details:");
×
31
        console.error(fipsError);
×
32
        process.exit(1);
×
33
    }
×
34
}
×
35

36
enableFipsIfRequested();
×
37

38
import { ConsoleLogger, LogId } from "./common/logger.js";
×
39
import { config } from "./common/config.js";
×
40
import crypto from "crypto";
×
41
import { packageInfo } from "./common/packageInfo.js";
×
42
import { StdioRunner } from "./transports/stdio.js";
×
43
import { StreamableHttpRunner } from "./transports/streamableHttp.js";
×
44
import { systemCA } from "@mongodb-js/devtools-proxy-support";
×
45

46
async function main(): Promise<void> {
×
47
    systemCA().catch(() => undefined); // load system CA asynchronously as in mongosh
×
48

49
    assertHelpMode();
×
50
    assertVersionMode();
×
51

52
    const transportRunner = config.transport === "stdio" ? new StdioRunner(config) : new StreamableHttpRunner(config);
×
UNCOV
53
    const shutdown = (): void => {
×
54
        transportRunner.logger.info({
×
55
            id: LogId.serverCloseRequested,
×
56
            context: "server",
×
57
            message: `Server close requested`,
×
58
        });
×
59

UNCOV
60
        transportRunner
×
61
            .close()
×
62
            .then(() => {
×
63
                transportRunner.logger.info({
×
64
                    id: LogId.serverClosed,
×
65
                    context: "server",
×
66
                    message: `Server closed`,
×
67
                });
×
68
                process.exit(0);
×
69
            })
×
70
            .catch((error: unknown) => {
×
71
                transportRunner.logger.error({
×
72
                    id: LogId.serverCloseFailure,
×
73
                    context: "server",
×
74
                    message: `Error closing server: ${error as string}`,
×
75
                });
×
76
                process.exit(1);
×
77
            });
×
78
    };
×
79

UNCOV
80
    process.on("SIGINT", shutdown);
×
81
    process.on("SIGABRT", shutdown);
×
82
    process.on("SIGTERM", shutdown);
×
83
    process.on("SIGQUIT", shutdown);
×
84

UNCOV
85
    try {
×
86
        await transportRunner.start();
×
87
    } catch (error: unknown) {
×
88
        transportRunner.logger.info({
×
89
            id: LogId.serverCloseRequested,
×
90
            context: "server",
×
91
            message: "Closing server",
×
92
        });
×
93
        try {
×
94
            await transportRunner.close();
×
95
            transportRunner.logger.info({
×
96
                id: LogId.serverClosed,
×
97
                context: "server",
×
98
                message: "Server closed",
×
99
            });
×
100
        } catch (error: unknown) {
×
101
            transportRunner.logger.error({
×
102
                id: LogId.serverCloseFailure,
×
103
                context: "server",
×
104
                message: `Error closing server: ${error as string}`,
×
105
            });
×
106
        }
×
107
        throw error;
×
108
    }
×
109
}
×
110

UNCOV
111
main().catch((error: unknown) => {
×
112
    // At this point, we may be in a very broken state, so we can't rely on the logger
113
    // being functional. Instead, create a brand new ConsoleLogger and log the error
114
    // to the console.
UNCOV
115
    const logger = new ConsoleLogger();
×
116
    logger.emergency({
×
117
        id: LogId.serverStartFailure,
×
118
        context: "server",
×
119
        message: `Fatal error running server: ${error as string}`,
×
120
    });
×
121
    process.exit(1);
×
122
});
×
123

UNCOV
124
function assertHelpMode(): void | never {
×
125
    if (config.help) {
×
126
        console.log("For usage information refer to the README.md:");
×
127
        console.log("https://github.com/mongodb-js/mongodb-mcp-server?tab=readme-ov-file#quick-start");
×
128
        process.exit(0);
×
129
    }
×
130
}
×
131

UNCOV
132
function assertVersionMode(): void | never {
×
133
    if (config.version) {
×
134
        console.log(packageInfo.version);
×
135
        process.exit(0);
×
136
    }
×
137
}
×
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