-
Notifications
You must be signed in to change notification settings - Fork 15
Open
Description
Description
When running mcp-ssh on Windows, the server fails to start with an ESM module loading error.
Error Message
node:internal/modules/esm/load:187
throw new ERR_UNSUPPORTED_ESM_URL_SCHEME(parsed, schemes);
^
Error [ERR_UNSUPPORTED_ESM_URL_SCHEME]: Only URLs with a scheme in: file, data, and node are supported by the default ESM loader. On Windows, absolute paths must be valid file:// URLs. Received protocol 'c:'
at throwIfUnsupportedURLScheme (node:internal/modules/esm/load:187:11)
at defaultLoad (node:internal/modules/esm/load:82:3)
at ModuleLoader.load (node:internal/modules/esm/loader:815:12)
at ModuleLoader.loadAndTranslate (node:internal/modules/esm/loader:594:31)
Environment
- OS: Windows 11 (10.0.22631)
- Node.js: v22.x
- Package version: 1.1.0
Root Cause
In bin/mcp-ssh.js, the dynamic import() is called with a Windows absolute path directly:
const mainModule = path.join(__dirname, '..', 'server-simple.mjs');
import(mainModule);On Windows, this results in a path like C:\Users\...\server-simple.mjs, but Node.js ESM loader requires file:// URLs for absolute paths on Windows.
Suggested Fix
Convert the path to a file:// URL before importing:
import path from 'path';
import { fileURLToPath, pathToFileURL } from 'url';
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const mainModule = path.join(__dirname, '..', 'server-simple.mjs');
import(pathToFileURL(mainModule).href);This change makes the code work correctly on both Windows and Unix-like systems.
Workaround
Users can manually edit the installed bin/mcp-ssh.js file to apply the fix above until an official release is available.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels