Skip to content

Commit 631e249

Browse files
author
DeepWiki Dev
committed
fix(mcp): enforce Node 24 native runtime
1 parent a738b11 commit 631e249

6 files changed

Lines changed: 39 additions & 2 deletions

File tree

.node-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
24.18.0

packages/mcp/package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@
3434
],
3535
"author": "abdush",
3636
"license": "MIT",
37+
"engines": {
38+
"node": "24.x"
39+
},
3740
"type": "module",
3841
"bin": {
3942
"context7-mcp": "dist/index.js"

packages/mcp/src/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import { randomUUID } from "node:crypto";
2121
import { createSessionStore } from "./lib/sessionStore.js";
2222
import { SERVER_VERSION } from "./lib/constants.js";
2323
import { localContext7Service } from "./local/service.js";
24+
import { assertSupportedNodeRuntime } from "./runtime.js";
2425

2526
/** Default HTTP server port */
2627
const DEFAULT_PORT = 3000;
@@ -538,6 +539,7 @@ function installTransportArgAliasing(transport: Transport): void {
538539
}
539540

540541
async function main() {
542+
assertSupportedNodeRuntime();
541543
const transportType = TRANSPORT_TYPE;
542544

543545
if (transportType === "http") {

packages/mcp/src/local/service.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { initDatabase } from "@neuledge/context";
21
import { readFile, stat } from "node:fs/promises";
32
import { join } from "node:path";
43
import type {
@@ -31,6 +30,11 @@ import type {
3130

3231
const MAX_INDEX_CANDIDATES = 5;
3332

33+
async function initializeNativeDatabase(): Promise<void> {
34+
const { initDatabase } = await import("@neuledge/context");
35+
await initDatabase();
36+
}
37+
3438
function resultFromManifest(manifest: LibraryManifest): SearchResult {
3539
const safe = (value: string, limit: number) =>
3640
value
@@ -82,7 +86,9 @@ export class LocalContext7Service {
8286
this.store = new LocalLibraryStore(config);
8387
this.discovery = new LibraryDiscovery(config);
8488
this.builder = new LocalLibraryBuilder(config, this.store);
85-
this.ready = Promise.all([this.store.initialize(), initDatabase()]).then(() => undefined);
89+
this.ready = Promise.all([this.store.initialize(), initializeNativeDatabase()]).then(
90+
() => undefined
91+
);
8692
}
8793

8894
private async buildOnce(

packages/mcp/src/runtime.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
export const SUPPORTED_NODE_MAJOR = 24;
2+
3+
export function assertSupportedNodeRuntime(nodeVersion: string = process.versions.node): void {
4+
const major = Number.parseInt(nodeVersion.split(".", 1)[0] ?? "", 10);
5+
if (major === SUPPORTED_NODE_MAJOR) return;
6+
7+
throw new Error(
8+
`Context7 Local requires Node.js ${SUPPORTED_NODE_MAJOR}.x because its local SQLite index uses native modules. ` +
9+
`Detected Node.js ${nodeVersion}. Run the MCP server with Node.js ${SUPPORTED_NODE_MAJOR}.x or reinstall dependencies with the selected Node.js runtime.`
10+
);
11+
}

packages/mcp/test/runtime.test.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { describe, expect, test } from "vitest";
2+
import { SUPPORTED_NODE_MAJOR, assertSupportedNodeRuntime } from "../src/runtime.js";
3+
4+
describe("MCP native runtime compatibility", () => {
5+
test("accepts the Node.js runtime used to install native SQLite dependencies", () => {
6+
expect(() => assertSupportedNodeRuntime("24.18.0")).not.toThrow();
7+
});
8+
9+
test("rejects an incompatible runtime before native modules are loaded", () => {
10+
expect(() => assertSupportedNodeRuntime("26.5.0")).toThrow(
11+
`Context7 Local requires Node.js ${SUPPORTED_NODE_MAJOR}.x`
12+
);
13+
});
14+
});

0 commit comments

Comments
 (0)