Skip to content

CLI version is hardcoded in src/cli.ts and has drifted from package.json #5

Description

@royalpinto007

What is wanted

Stop hardcoding the CLI version string, and read it from package.json instead.

The problem

src/cli.ts line 15:

const VERSION = "0.1.0";

package.json line 3 says:

"version": "0.1.1",

They have already drifted. mcp-audit --version and the header line of usage() (line 46, mcp-audit v${VERSION}) both report a version that is not the one published to npm as @royalpinto007/mcp-audit.

Why it matters

The version is the first thing anyone pastes into a bug report. If it is wrong, every reproduction attempt starts from the wrong tree. It will also drift again on the next release, because nothing links the two numbers.

Steps

  1. In src/cli.ts, read the version from package.json at runtime rather than duplicating it. The package is ESM ("type": "module" in package.json), so createRequire(import.meta.url) from node:module is the straightforward approach, wrapped in a try/catch that falls back to a placeholder. There is a working example of exactly this pattern in a sibling project if you want a reference shape, but the three-line version is fine.
  2. Mind the path. The binary ships as dist/cli.js (see the bin field in package.json), so the resolved path from the built file is ../package.json, not ../../package.json. Verify with npm run build && node dist/cli.js --version.
  3. Confirm "files": ["dist", "README.md", "LICENSE"] still results in a working install; package.json itself is always included by npm, so this is safe.
  4. Note that mcp-audit --version on its own is separately broken and is tracked in another issue. Test with node dist/cli.js rules --version or fix on top of that one.

Under an hour, no new dependencies. Comment below to claim it and I will usually reply within a day.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions