From b780120c5244ffa15b567d4ff7d3b4df5353120c Mon Sep 17 00:00:00 2001 From: Geoff Whittington Date: Wed, 14 Jan 2026 15:12:17 -0500 Subject: [PATCH] Add Node.js version check with clear warning for unsupported versions Prevents silent failures when running with Node.js < v22 by checking version at startup in both stdio and HTTP modes, exiting with descriptive error messages. --- src/http.ts | 2 ++ src/stdio.ts | 3 +++ src/utils/version.ts | 18 ++++++++++++++++++ 3 files changed, 23 insertions(+) create mode 100644 src/utils/version.ts diff --git a/src/http.ts b/src/http.ts index e7ea8c88..33a738f6 100644 --- a/src/http.ts +++ b/src/http.ts @@ -4,6 +4,7 @@ import { StreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/ import { isInitializeRequest } from "@modelcontextprotocol/sdk/types.js"; import type { IncomingMessage, ServerResponse } from "node:http"; import { createServer, setupSignalHandlers } from "./mcp"; +import { checkNodeVersion } from "./utils/version"; type SessionEntry = { transport: StreamableHTTPServerTransport; @@ -176,6 +177,7 @@ function readEnvPort(value: string | undefined, fallback: number): number { } export async function main(): Promise { + checkNodeVersion(); assertNoSdeEnvForHttpMode(); const whitelist = readWhitelist(); diff --git a/src/stdio.ts b/src/stdio.ts index e3908336..9f4d5f7e 100644 --- a/src/stdio.ts +++ b/src/stdio.ts @@ -1,7 +1,10 @@ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js"; import { createServer, setupSignalHandlers } from "./mcp"; +import { checkNodeVersion } from "./utils/version"; export async function main(): Promise { + checkNodeVersion(); + const server = createServer(); setupSignalHandlers(async () => server.close()); diff --git a/src/utils/version.ts b/src/utils/version.ts new file mode 100644 index 00000000..334f21eb --- /dev/null +++ b/src/utils/version.ts @@ -0,0 +1,18 @@ +export function checkNodeVersion(): void { + const version = process.version; + const majorVersion = parseInt(version.slice(1).split(".")[0], 10); + const MINIMUM_VERSION = 22; + + if (majorVersion < MINIMUM_VERSION) { + console.error( + `WARNING: Node.js version ${version} is not supported. ` + + `This MCP server requires Node.js v${MINIMUM_VERSION} or higher. ` + + `Please upgrade your Node.js installation.` + ); + console.error(`Current version: ${version}`); + console.error(`Minimum required: v${MINIMUM_VERSION}.0.0`); + process.exit(1); + } + + console.info(`Node.js version ${version} detected (OK)`); +}