Skip to content

fix: resolve symlink handling for entry point detection on POSIX systems - #44

Open
basilkot wants to merge 1 commit into
commerce-operations-foundation:mainfrom
VirtoCommerce:fix/entry-point-symlink-posix
Open

basilkot wants to merge 1 commit into
commerce-operations-foundation:mainfrom
VirtoCommerce:fix/entry-point-symlink-posix

Conversation

@basilkot

Copy link
Copy Markdown
Contributor

Problem

When the package is installed via npm/npx, the bin entry is exposed as a
symlink (for example node_modules/.bin/cof-mcp -> ../@virtocommerce/cof-mcp/dist/index.js).
The direct string comparison between process.argv[1] and
fileURLToPath(import.meta.url) therefore fails on POSIX systems, main()
is silently skipped, and the process exits with code 0 producing no output —
which manifests as the server "starting and immediately disconnecting"
under Claude Desktop on macOS/Linux.

Fix

Canonicalize process.argv[1] with fs.realpathSync and compare canonical
file:// URLs via pathToFileURL. Works on macOS, Linux, and Windows.

Test plan

  • Run on macOS via `npx` — server stays up and responds to MCP requests.
  • Run on Linux via globally installed `cof-mcp` — same.
  • Run on Windows (no symlinks) — no regression.

@OlegoO

OlegoO commented Jun 25, 2026

Copy link
Copy Markdown

@AJITHMELVIN @timdauer Any updates or thoughts?

@joshfischer-cin7

Copy link
Copy Markdown

Ajith saw this, has some feedback. Will follow up

@OlegoO

OlegoO commented Jul 8, 2026

Copy link
Copy Markdown

Ajith saw this, has some feedback. Will follow up

Ok, waiting for the feedback

@OlegoO

OlegoO commented Sep 3, 2026

Copy link
Copy Markdown

@joshfischer-cin7 any updates?

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.

3 participants