Skip to content

fix: server not starting via npx bin symlink (v1.1.1) - #10

Merged
kazuph merged 1 commit into
mainfrom
fix/bin-symlink-entrypoint
Jun 12, 2026
Merged

kazuph merged 1 commit into
mainfrom
fix/bin-symlink-entrypoint

Conversation

@kazuph

@kazuph kazuph commented Jun 12, 2026

Copy link
Copy Markdown
Owner

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 installs bin entries as symlinks (node_modules/.bin, npx cache), so npx @kazuph/mcp-taskmanager silently exited without ever starting the server. Caught by smoke-testing the published package via npx exactly like an end user.

How

Resolve argv[1] with realpathSync before comparing (with a safe try/catch fallback to not starting).

What

  • index.ts: isMain now uses realpathSync(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 launch
  • version 1.1.0 → 1.1.1

Verification

  • Regression test proven red on the v1.1.0 guard, green on this fix
  • Full suite: 5/5 passing; npm audit: 0 vulnerabilities

🤖 Generated with Claude Code

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>
Copilot AI review requested due to automatic review settings June 12, 2026 08:35
@kazuph
kazuph merged commit e9f09ab into main Jun 12, 2026
2 checks passed

Copilot AI 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.

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);
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.

2 participants