Skip to content

Windows fix in source - #1

Open
mathetos wants to merge 1 commit into
GravityKit:mainfrom
mathetos:main
Open

Windows fix in source#1
mathetos wants to merge 1 commit into
GravityKit:mainfrom
mathetos:main

Conversation

@mathetos

@mathetos mathetos commented Feb 18, 2026

Copy link
Copy Markdown

Problem

When the MCP server is run directly (e.g. node src/index.js or via npx), 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(...).href so 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

  • Bug Fixes
    • Improved cross-platform startup detection to ensure reliable application initialization on Windows and other operating systems.

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.
@coderabbitai

coderabbitai Bot commented Feb 18, 2026

Copy link
Copy Markdown

Walkthrough

Modified 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

Cohort / File(s) Summary
Startup Guard Enhancement
src/index.js
Imported pathToFileURL from 'url' module and refactored startup detection logic to normalize process.argv[1] to a file URL using pathToFileURL(path.resolve(process.argv[1])).href before comparison with import.meta.url. Added guard check for non-empty entryUrl to ensure cross-platform reliability on Windows and Unix-like systems.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Windows fix in source' is directly related to the main change: a cross-platform fix for the Windows startup issue in src/index.js where process.argv[1] comparison failed due to path format differences.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
src/index.js (1)

889-891: Core fix is correct; entryUrl && guard is redundant.

pathToFileURL(path.resolve(process.argv[1])).href produces a proper file:///C:/... URL on Windows, making the URL-to-URL comparison work cross-platform — good fix.

The entryUrl && short-circuit is technically unnecessary: when process.argv[1] is absent, entryUrl is '', and import.meta.url === '' is unconditionally false anyway. 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant