About lockdrift
lockdrift is a static auditor for npm projects that compares dependency ranges in package.json with resolved versions in package-lock.json. It also checks workspace packages and reports missing, out-of-range, extraneous, and unsupported dependencies.
Key features
- 01Compares declared ranges with locked versions
- 02Reports missing and out-of-range dependencies
- 03Flags extraneous top-level packages
- 04Checks supported workspace packages
- 05Emits deterministic JSON reports
Use cases
- 01Audit dependency consistency in an npm repository
- 02Review lockfile drift across supported workspaces
- 03Inspect findings through a machine-readable report
MCP support
Exposes the check_lockfile tool, which takes a path and returns the check results as a JSON report.
Configuration
Local server config is the same for every client. Copy it into your client’s MCP config file.
Tools
1Saved tool list · updated 1d ago
| Parameter | Type | Required | Description |
|---|---|---|---|
| path | string | Yes | Target path to check |
Details
From the project READMElockdrift
Lockfile drift auditor for npm projects. lockdrift compares the dependency
ranges declared in package.json against the versions actually resolved in
package-lock.json, and reports where the two have drifted apart:
- a declared dependency with no entry in the lockfile (
LOCK-MISSING, high) - a locked version that does not satisfy its declared range
(
RANGE-VIOLATED, high, with evidence such asdeclared ^1.2.0, locked 2.0.0) - a locked top-level package that nothing declares and nothing depends on
(
EXTRANEOUS, low) - a declared range in a form lockdrift does not evaluate
(
RANGE-UNSUPPORTED, info): counted as unchecked, never as violated
The report verdict is IN-SYNC when there are no high findings and DRIFT
otherwise. Extraneous (low) and unsupported (info) findings alone do not
change the verdict. Every report carries counts: declared, locked, missing,
violated, extraneous, and unchecked. Output is deterministic, with no
timestamps.
Monorepos: when the root package.json declares workspaces, or a
packages/ directory holds package.json files, each workspace package.json
is also checked against the root lockfile. Workspace globs such as
packages/* are expanded one level. Patterns in other shapes are reported
with a WORKSPACES-NOTED info finding and are not silently treated as
checked.
Install
npx @reneturcios/lockdrift check .
Or install it as a dependency or a global tool:
npm install @reneturcios/lockdrift
CLI
lockdrift check [path] [--json]
lockdrift mcp
lockdrift --version
checkaudits the target directory (default: the current directory). Add--jsonfor the machine-readable report. Exit code 0 when the verdict isIN-SYNC, 1 forDRIFT, 2 for a usage or input error (for example a missingpackage.jsonorpackage-lock.json, which is a clear thrown error, not a report).mcpruns the MCP server over stdio.--versionprints the version.
MCP
The MCP server exposes one tool:
check_lockfile, with apathargument: runs the same check as the CLI and returns the full JSON report (tool name, version, target, verdict, counts, findings, and summary).
Supported range forms
A locked version satisfies a declared range when one of these forms says so:
- exact:
1.2.3 - caret:
^1.2.3(same major; the 0.x rules apply, so^0.2.3means>=0.2.3 <0.3.0and^0.0.3means exactly0.0.3) - tilde:
~1.2.3(means>=1.2.3 <1.3.0) - simple comparators:
>=1.2.3,>1.2.3,<1.2.3,<=1.2.3 - space-separated AND pairs of comparators, such as
>=1.0.0 <2.0.0 *,latest, and an empty range: always satisfied
Versions with a prerelease or build suffix (such as 1.2.3-beta.1) are
compared on their numeric core only; the suffix is ignored.
Everything else is unsupported and returns "unchecked" rather than a
guess: URLs, git references, file: and other protocol ranges,
workspace: ranges, npm: aliases, || unions, hyphen ranges, and
partial versions such as ^1 or ^1.2.
How extraneous is decided
An entry is only evaluated for the extraneous rule at the top level of
node_modules/. A top-level locked package is extraneous when it is not
declared in any checked package.json, is not a local workspace package,
and no lock entry lists it in its dependencies, peerDependencies, or
optionalDependencies. That reference set is the v0.1 approximation of
transitivity: it does not walk the graph package by package. Nested
copies under another package's node_modules/ are not evaluated, only
the top-level entry for each name.
Limits
- npm lockfiles only. lockdrift reads the lockfile v3
packagesmap frompackage-lock.json. There is no yarn or pnpm lockfile support in v0.1. - Unsupported ranges are reported as unchecked, never guessed and never flagged as violated.
- Static analysis only. Nothing in a checked repo is installed or executed.
- The root lock entry (the empty-string key in the
packagesmap) mirrorspackage.jsonand is not itself treated as a locked package.
Development
npm install
npm run build
npm test
Comments
New to MCP?
From what the protocol is to installing your first server, these answers cover most first questions.
An open protocol that defines how AI applications connect to external tools and data in a uniform way. Clients talk to the model; MCP servers provide tools, resources and prompt templates. They exchange standard messages, so one server can be reused by many clients.