From 6d91b00904f134ea23bcfba529f243833c66ffd8 Mon Sep 17 00:00:00 2001 From: Will-hxw Date: Mon, 27 Apr 2026 19:30:02 +0800 Subject: [PATCH 1/2] fix: respect npm_config_registry for update checks Use the npm_config_registry env var (set by npm when invoked via npx with custom registry config) instead of hardcoding registry.npmjs.org. Falls back to the default public registry when the env var is not set. Fixes #1943 --- src/bin/check-latest-version.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/bin/check-latest-version.ts b/src/bin/check-latest-version.ts index eb45674df..7ecce373a 100644 --- a/src/bin/check-latest-version.ts +++ b/src/bin/check-latest-version.ts @@ -12,8 +12,11 @@ const cachePath = process.argv[2]; if (cachePath) { try { + const registry = + process.env.npm_config_registry?.replace(/\/$/, '') || + 'https://registry.npmjs.org'; const response = await fetch( - 'https://registry.npmjs.org/chrome-devtools-mcp/latest', + `${registry}/chrome-devtools-mcp/latest`, ); const data = response.ok ? await response.json() : null; From 5462a961b6824cd206484875665ec23c26ce5039 Mon Sep 17 00:00:00 2001 From: Will-hxw Date: Wed, 29 Apr 2026 06:18:19 +0800 Subject: [PATCH 2/2] fix: use npm config get registry to support direct CLI invocation Instead of only checking npm_config_registry env var (which is only set when invoked via npx/npm), now uses `npm config get registry` to read .npmrc regardless of how the CLI was started. This addresses the maintainer's feedback that the original solution did not work when DevTools CLI is called directly. --- src/bin/check-latest-version.ts | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/bin/check-latest-version.ts b/src/bin/check-latest-version.ts index 7ecce373a..6e713187a 100644 --- a/src/bin/check-latest-version.ts +++ b/src/bin/check-latest-version.ts @@ -4,6 +4,7 @@ * SPDX-License-Identifier: Apache-2.0 */ +import {execSync} from 'node:child_process'; import fs from 'node:fs/promises'; import path from 'node:path'; import process from 'node:process'; @@ -12,9 +13,15 @@ const cachePath = process.argv[2]; if (cachePath) { try { - const registry = - process.env.npm_config_registry?.replace(/\/$/, '') || - 'https://registry.npmjs.org'; + let registry; + try { + registry = execSync('npm config get registry', { + encoding: 'utf8', + }).trim().replace(/\/$/, ''); + } catch { + // npm not on PATH, fall back to default + } + registry ||= 'https://registry.npmjs.org'; const response = await fetch( `${registry}/chrome-devtools-mcp/latest`, );