safe-audit-fix

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.

Category
访问服务器

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:

  1. Plan first — every fix is risk-labeled (low / moderate / high-breaking) before anything changes.
  2. One fix at a time — never a big-bang change.
  3. Test after every fix — your own test command runs after each step.
  4. Auto-revert — if install or tests fail, that fix is instantly undone (package.json + lockfile restored, node_modules re-synced).
  5. Breaking upgrades are opt-in — major-version jumps are skipped unless you pass --include-major, and even then they are test-protected.
  6. Full undosafe-audit-fix revert restores 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 --json format)
  • A package-lock.json in the target project (run npm install once 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 overrides suggestions for transitive vulnerabilities with no parent fix
  • Support for pnpm / yarn

License

MIT

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选