safe-audit-fix
MCP server that safely fixes npm audit vulnerabilities by planning, applying fixes one at a time, running tests after each, and auto-reverting failures to prevent breaking changes.
README
safe-audit-fix
Fix npm vulnerabilities without breaking your app.
npm audit fix --force can silently jump major versions, downgrade packages, and break your build. safe-audit-fix takes the opposite approach — like a careful surgeon instead of a sledgehammer:
- Plan first — every fix is risk-labeled (
low/moderate/high-breaking) before anything changes. - One fix at a time — never a big-bang change.
- Test after every fix — your own test command runs after each step.
- Auto-revert — if install or tests fail, that fix is instantly undone (package.json + lockfile restored, node_modules re-synced).
- Breaking upgrades are opt-in — major-version jumps are skipped unless you pass
--include-major, and even then they are test-protected. - Full undo —
safe-audit-fix revertrestores everything from before the run.
It works two ways from one shared engine:
┌────────────────────┐
you ──────────► CLI │
├────────────────────┤──► core engine: scan → plan → fix one → test → keep/revert
AI assistant ─► MCP server │
(Claude Code, └────────────────────┘
Cursor, ...)
Requirements
- Node.js ≥ 18, npm ≥ 7 (needs the modern
npm audit --jsonformat) - A
package-lock.jsonin the target project (runnpm installonce if missing)
Install
Try it instantly — no install (run inside your project folder):
npx safe-audit-fix scan
npx safe-audit-fix fix
Or install globally:
npm install -g safe-audit-fix
safe-audit-fix scan
Or from source:
git clone https://github.com/pasindudilshan1/safe-audit-fix.git
cd safe-audit-fix
npm install
npm link # makes the `safe-audit-fix` command available globally
CLI usage
safe-audit-fix scan # show vulnerabilities + whether each fix is safe or breaking
safe-audit-fix plan # show the ordered fix plan (changes nothing)
safe-audit-fix fix # apply fixes one at a time, testing after each
safe-audit-fix fix --include-major # also attempt breaking upgrades (test-protected)
safe-audit-fix fix --dry-run # preview only
safe-audit-fix fix --test "npm run test:unit" # custom verify command
safe-audit-fix fix --no-test # skip test verification (install failures still revert)
safe-audit-fix revert # undo the entire last fix run
All commands accept --dir <path> to target another project, and scan/plan accept --json.
Before any fix is applied, your tests are run once as a baseline — if they already fail, the tool refuses to start (otherwise every fix would be wrongly blamed and reverted).
MCP server (use it from Claude Code, Cursor, etc.)
Register the server, then just ask your AI assistant: "safely fix the vulnerabilities in my project".
Claude Code:
claude mcp add safe-audit-fix -- npx -y --package=safe-audit-fix safe-audit-fix-mcp
Or via .mcp.json / MCP config file:
{
"mcpServers": {
"safe-audit-fix": {
"command": "npx",
"args": ["-y", "--package=safe-audit-fix", "safe-audit-fix-mcp"]
}
}
}
(If you installed globally, you can use safe-audit-fix-mcp directly as the command instead of npx.)
Exposed tools:
| Tool | What it does | Changes files? |
|---|---|---|
scan_vulnerabilities |
Structured audit report | No |
plan_fixes |
Ordered, risk-labeled fix plan | No |
apply_fixes_safely |
The fix-test-revert loop (dryRun, includeMajor, testCommand options) |
Yes |
revert_last_session |
Undo the last fix run | Yes |
How it compares
npm audit fix |
npm audit fix --force |
Asking an AI in chat | safe-audit-fix | |
|---|---|---|---|---|
| Fixes in-range vulns | ✅ | ✅ | manual | ✅ |
| Fixes breaking (major) vulns | ❌ | ✅ silently | manual | ✅ opt-in |
| Runs your tests after each change | ❌ | ❌ | ❌ | ✅ |
| Auto-reverts a bad fix | ❌ | ❌ | ❌ | ✅ |
| Shows a risk-labeled plan first | ❌ | ❌ | ⚠️ | ✅ |
| One-command full undo | ❌ | ❌ | ❌ | ✅ |
| Usable by AI assistants (MCP) | ❌ | ❌ | — | ✅ |
Library usage
The engine is importable directly:
import { scan, planFix, fixAll, revertSession } from 'safe-audit-fix';
const result = fixAll('/path/to/project', { includeMajor: false });
console.log(result.applied, result.failed, result.blocked);
Roadmap
--explain: use an LLM to summarize the changelog/breaking changes of a planned major upgrade- Reachability analysis: skip vulnerabilities whose vulnerable code path is never called from your code
- Automatic
overridessuggestions for transitive vulnerabilities with no parent fix - Support for pnpm / yarn
License
MIT
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
Neon Database
MCP server for interacting with Neon Management API and databases
E2B
Using MCP to run code via e2b.
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.