feat: make the package publishable to npm - #4
Merged
Conversation
The published tarball was broken in a way the test suite could not see. The MCP host spawned all four tool servers via the local `tsx` binary against `src/**/*.ts`, but `tsx` is a devDependency and `src/` isn't needed at runtime, so every server failed with ENOENT on a real install. Because startup failures are deliberately non-fatal, this didn't error — it produced reviews with no context tools at all, silently. - Spawn compiled servers with `process.execPath` on `dist/tools/*/server.js` when running compiled, keeping the `tsx` + `src/` runner for the no-build dev loop. Server paths now resolve relative to the host module rather than a guessed project root, so one code path serves both layouts. - Add a `files` allowlist: 197 files / 757 kB -> 129 files / 319 kB, no longer shipping src/, tests/, bun.lock or the internal docs. - Add the MIT LICENSE file the manifest already claimed, plus repository, homepage and bugs metadata. - Single-source the version from package.json via src/version.ts, replacing the five hardcoded '0.1.0' literals in the CLI and MCP serverInfo blocks. - Add `npm run test:pack` (scripts/smoke-pack.sh): packs, installs the tarball into a clean project, asserts every server answers an MCP initialize under plain node, and runs the CLI end-to-end. Wired into CI, since the unit tests import servers from src/ and cannot catch a packaging break. - Document install/publish in the README and the packaging contract in CLAUDE.md; ignore *.tgz. Co-Authored-By: Claude <noreply@anthropic.com>
npm rewrites './bin/mcp-review' to 'bin/mcp-review' at publish time and warns about the auto-correction on every run. Store the normalized form (npm pkg fix).
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.
Makes
mcp-git-reviewerpublishable to npm. (PyPI was assessed and rejected — this is a TypeScript/Node project end to end; a PyPI presence would mean a rewrite or a Python shim wrapping a Node runtime the user installs separately, which is strictly worse thannpx.)The blocker: the published package didn't work
The MCP host spawned all four tool servers via the local
tsxbinary againstsrc/**/*.ts.tsxis adevDependency, so consumers never get it. Installing the tarball into a clean project and running the CLI gave:The severity is in the failure mode, not the message.
initialize()treats server startup failures as non-fatal warnings ("graceful degradation"), so with a valid API key this does not error — it produces a review with zero context tools. No file reads, no convention scanning, no related-files. The entire premise of the tool, silently absent, while the CLI looks like it worked.The existing suite can't see this: it imports tool servers directly from
src/, so all 303 tests pass against a package that cannot spawn a single server.Fix:
resolveRunnernow spawnsprocess.execPathondist/tools/<name>/server.jswhen running compiled, and keeps thetsx+src/runner when running from source, so the no-build dev loop (bun run dev, vitest) is untouched. Server paths resolve relative to the host module rather than a guessed project root, so one code path serves both layouts.process.execPathrather than a barenoderespects nvm/volta/asdf shims.Both paths verified end to end: compiled via the installed tarball, source via
npx tsx src/cli.ts(all four servers start, run proceeds to the expected 401 on a dummy key).Regression guard
New
npm run test:pack(scripts/smoke-pack.sh) — packs the tarball, installs it into a throwaway project, asserts every server answers an MCPinitializeunder plainnode, runs the CLI end-to-end against a scratch git repo, and checks--versionmatchespackage.json:Wired into CI. Reverting the runner fix turns this red while the unit suite stays green.
Packaging hygiene
src/,tests/,bun.lock,CLAUDE.md,AGENT_TEAM.md,.github/filesallowlistLICENSErepository/homepage/bugs0.1.0in 5 placespackage.jsonviasrc/version.ts## Install(npx + global) and## Publishing.gitignore*.tgznpm packlitters the root otherwiseNaming
Kept the npm package name as
mcp-git-reviewer(per your instruction) with the binary stayingmcp-review, and documented the split explicitly in the README so it isn't a surprise. Both names are still free on npm. Say the word if you'd rather the package bemcp-reviewtoo — it's a one-line change plus doc updates.Verification
bash scripts/verify.sh— lint/format, typecheck, build, 303 tests, all greennpm run test:pack— greentsx)Not done
dist/. TheirdeclarationMap/sourceMapreferences point atsrc/, which is no longer in the tarball, so they're partially dangling — harmless (file/line still resolve in stack traces) but droppable if you want a leaner package.0.1.0;npm version+npm publishis a deliberate manual step, documented in the README rather than automated here.Generated by Claude Code