Repository navigation
fix: server not starting via npx bin symlink (v1.1.1) - #10
Merged
Merged
Conversation
The v1.1.0 entrypoint guard compared path.resolve(process.argv[1]) with the real module path, but npm installs bin entries as symlinks (node_modules/.bin and the npx cache), so `npx @kazuph/mcp-taskmanager` silently exited without starting the server. Resolve argv[1] with realpathSync before comparing. Adds a regression test that launches the built entrypoint through an actual symlink (npx-style) and asserts the server starts and serves all 10 tools; verified red on the v1.1.0 guard and green on this fix. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Fixes a regression introduced in v1.1.0 where the server wouldn’t start when invoked via npx/node_modules/.bin because the “am I the main module?” guard compared against a symlinked argv[1] path instead of the real file path.
Changes:
- Update the entrypoint guard to
realpathSync(process.argv[1])before comparing to the module path. - Add an integration-style Vitest that spawns the built entrypoint via an actual symlink (npx-style) and validates startup + tool listing.
- Bump package version from 1.1.0 to 1.1.1 (and lockfile).
Reviewed changes
Copilot reviewed 3 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
index.ts |
Makes the “execute directly vs imported” guard symlink-aware using realpathSync. |
tests/bin-entrypoint.test.ts |
Adds regression coverage for launching the compiled bin through a symlink and via direct path. |
package.json |
Version bump to 1.1.1. |
package-lock.json |
Lockfile version bump to 1.1.1. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+68
to
+72
| beforeAll(async () => { | ||
| tmpDir = await fs.mkdtemp(path.join(os.tmpdir(), "mcp-tm-bin-")); | ||
| symlinkPath = path.join(tmpDir, "mcp-taskmanager"); | ||
| await fs.symlink(distEntry, symlinkPath); | ||
| }); |
Comment on lines
+60
to
+63
| setTimeout(() => { | ||
| p.kill(); | ||
| resolve({ stdoutLines: out.trim().split("\n").filter(Boolean), stderr: err }); | ||
| }, 900); |
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.
Why
v1.1.0 introduced an entrypoint guard (so tests can import the module without starting the stdio server). It compared
path.resolve(process.argv[1])against the real module path — but npm installsbinentries as symlinks (node_modules/.bin, npx cache), sonpx @kazuph/mcp-taskmanagersilently exited without ever starting the server. Caught by smoke-testing the published package vianpxexactly like an end user.How
Resolve
argv[1]withrealpathSyncbefore comparing (with a safe try/catch fallback to not starting).What
index.ts:isMainnow usesrealpathSync(process.argv[1])tests/bin-entrypoint.test.ts: launches the built entrypoint through an actual symlink (npx-style) and asserts the startup log + all 10 tools respond; also covers the direct-path launchVerification
npm audit: 0 vulnerabilities🤖 Generated with Claude Code