Resolve symlinks in entry-point check so server starts under npx on POSIX#43
Closed
basilkot wants to merge 53 commits into
Closed
Resolve symlinks in entry-point check so server starts under npx on POSIX#43basilkot wants to merge 53 commits into
basilkot wants to merge 53 commits into
Conversation
…ironment variables
… 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.
…ax support and updating test prompts
…moving unsupported fields and adding SKU resolution logic
…tomer and product references
`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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
When the package is installed via
npm/npx, thebinentry is exposed as asymlink 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 againstfileURLToPath(import.meta.url). On macOS/Linux these two are differentstrings —
argv[1]is the symlink path,import.meta.urlresolves to thereal path — so
main()was silently never invoked. The process importedmodules, 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
binas a.cmdshim that callsnodewith thealready-resolved path, which is why the bug only triggered on POSIX.
Fix
Resolve symlinks on
process.argv[1]viafs.realpathSyncand comparecanonical
file://URLs. Behaviour is now consistent across macOS, Linux,and Windows.
The check is extracted into a small
isMainModule()helper with a JSDocthat explains the root cause for future readers.