Windows fix in source - #1
Conversation
File: drip-mcp-server/src/index.js
Import: pathToFileURL is now imported from 'url' along with fileURLToPath.
Startup check (bottom of file): Replaced the direct import.meta.url === \file://${process.argv[1]}\`` check with a Windows-safe comparison:
// Start the server if run directly (Windows-safe: normalize argv[1] to file URL for comparison)const entryUrl = process.argv[1] ? pathToFileURL(path.resolve(process.argv[1])).href : '';if (entryUrl && import.meta.url === entryUrl) { const server = new DripMCPServer(); server.run().catch(console.error);}
Why this works: On Windows, process.argv[1] can be a path like C:\path\to\index.js, so file://${process.argv[1]} is not a valid file:// URL and never matches import.meta.url. Using pathToFileURL(path.resolve(process.argv[1])).href normalizes the script path to the same file:// form as import.meta.url, so the “run directly” check works on Windows (and still works on macOS/Linux).
3. Quick test
npm install and node src/index.js were run from c:\CLIENTS\castos\drip-mcp-server with dummy env; the process printed “Drip MCP server running on stdio” and stayed running, so the fix is active.
WalkthroughModified the startup guard in src/index.js to use a Windows-safe approach for detecting direct script execution. The change normalizes process.argv[1] to a file URL before comparing with import.meta.url, replacing a direct comparison with platform-agnostic path handling. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes 🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Tip Issue Planner is now in beta. Read the docs and try it out! Share your feedback on Discord. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/index.js (1)
889-891: Core fix is correct;entryUrl &&guard is redundant.
pathToFileURL(path.resolve(process.argv[1])).hrefproduces a properfile:///C:/...URL on Windows, making the URL-to-URL comparison work cross-platform — good fix.The
entryUrl &&short-circuit is technically unnecessary: whenprocess.argv[1]is absent,entryUrlis'', andimport.meta.url === ''is unconditionallyfalseanyway. Feel free to simplify if desired:♻️ Optional simplification
-const entryUrl = process.argv[1] ? pathToFileURL(path.resolve(process.argv[1])).href : ''; -if (entryUrl && import.meta.url === entryUrl) { +const entryUrl = process.argv[1] && pathToFileURL(path.resolve(process.argv[1])).href; +if (import.meta.url === entryUrl) {🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/index.js` around lines 889 - 891, Remove the redundant boolean guard by dropping the "entryUrl &&" check in the startup conditional: always compute entryUrl via pathToFileURL(path.resolve(process.argv[1])).href (when process.argv[1] is falsy it becomes ''), then compare import.meta.url === entryUrl directly; update the conditional that uses entryUrl and import.meta.url (the expression currently using entryUrl && import.meta.url === entryUrl) to just import.meta.url === entryUrl so the logic is simpler and equivalent.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@src/index.js`:
- Around line 889-891: Remove the redundant boolean guard by dropping the
"entryUrl &&" check in the startup conditional: always compute entryUrl via
pathToFileURL(path.resolve(process.argv[1])).href (when process.argv[1] is falsy
it becomes ''), then compare import.meta.url === entryUrl directly; update the
conditional that uses entryUrl and import.meta.url (the expression currently
using entryUrl && import.meta.url === entryUrl) to just import.meta.url ===
entryUrl so the logic is simpler and equivalent.
Problem
When the MCP server is run directly (e.g.
node src/index.jsor vianpx), it only starts if:import.meta.url ===
file://${process.argv[1]}On Windows this condition is always false because:
process.argv[1] is a native path (e.g. C:\path\to\index.js or backslashes).
The string file://${process.argv[1]} is not a valid file:// URL (wrong slashes, no leading slash after file://).
import.meta.url is a proper file URL (e.g. file:///C:/path/to/index.js).
So the server process exits immediately without calling run(), which breaks MCP clients (e.g. Cursor, Claude Desktop) on Windows.
Solution
Normalize the entry script path to a file URL before comparing:
Use
path.resolve(process.argv[1])so the path is absolute and consistent.Use
pathToFileURL(...).hrefso the comparison is URL-to-URL and works on all platforms.The server now starts when run directly on Windows as well as on macOS and Linux.
Testing
node src/index.js with DRIP_API_KEY and DRIP_ACCOUNT_ID set prints "Drip MCP server running on stdio" and stays running on Windows.
No change to behavior when the module is imported (e.g. by tests or a wrapper); the condition still only runs the server when it is the entry script.
Summary by CodeRabbit