Skip to content

Resolve symlinks in entry-point check so server starts under npx on POSIX#43

Closed
basilkot wants to merge 53 commits into
commerce-operations-foundation:developfrom
VirtoCommerce:fix/entrypoint-symlink
Closed

Resolve symlinks in entry-point check so server starts under npx on POSIX#43
basilkot wants to merge 53 commits into
commerce-operations-foundation:developfrom
VirtoCommerce:fix/entrypoint-symlink

Conversation

@basilkot

Copy link
Copy Markdown
Contributor

Summary

When the package is installed via npm/npx, the bin entry is exposed as a
symlink on POSIX systems (e.g. node_modules/.bin/cof-mcp -> ../@virtocommerce/cof-mcp/dist/index.js).

The previous entry-point check compared process.argv[1] directly against
fileURLToPath(import.meta.url). On macOS/Linux these two are different
strings — argv[1] is the symlink path, import.meta.url resolves to the
real path — so main() was silently never invoked. The process imported
modules, reached EOF and exited with code 0 with no output. Under Claude
Desktop this manifested as "Server started and connected successfully"
immediately followed by "Server transport closed unexpectedly".

On Windows, npm installs bin as a .cmd shim that calls node with the
already-resolved path, which is why the bug only triggered on POSIX.

Fix

Resolve symlinks on process.argv[1] via fs.realpathSync and compare
canonical file:// URLs. Behaviour is now consistent across macOS, Linux,
and Windows.

The check is extracted into a small isMainModule() helper with a JSDoc
that explains the root cause for future readers.

… HTTP transport

- Updated the @modelcontextprotocol/sdk dependency from v0.5.0 to v1.26.0.
- Introduced a new Streamable HTTP transport in the MCPServerSDK.
- Modified the main function to support starting the server with Streamable HTTP.
- Implemented request handling for health checks, POST, GET, and DELETE methods in the Streamable HTTP transport.
- Ensured proper session management for Streamable HTTP connections.
basilkot and others added 23 commits February 17, 2026 06:09
…moving unsupported fields and adding SKU resolution logic
`import(absolutePath)` fails on Windows because Node.js ESM loader
interprets the drive letter (e.g. `E:`) as a URL scheme. Convert the
path to a file:// URL before importing.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@basilkot basilkot closed this May 13, 2026
@basilkot basilkot deleted the fix/entrypoint-symlink branch May 13, 2026 08:46
@basilkot basilkot restored the fix/entrypoint-symlink branch May 13, 2026 08:46
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