Skip to main content
Glama
mcpguards

mcp-lock

by mcpguards

mcp-lock

npm ci für Ihre MCP-Server.

Jedes Mal, wenn Ihr KI-Coding-Tool startet, lädt npx -y @scope/mcp-server stillschweigend die neueste Version jedes MCP-Servers herunter. Keine Versionsfixierung. Keine Hash-Prüfung. Keine Aufzeichnung dessen, was gestern lief.

mcp-lock behebt dies. Es zeichnet beim ersten Ausführen die exakte Version und den Tarball-Integritäts-Hash jedes MCP-Servers auf und überprüft bei jedem nachfolgenden Ausführen, ob sich etwas geändert hat.


Das Problem

// Your .mcp.json — right now
{
  "mcpServers": {
    "filesystem": {
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-filesystem"]
      //        ^^^
      //        Downloads whatever is latest. Every. Single. Time.
    }
  }
}

Der Supply-Chain-Angriff auf axios im März 2026 kompromittierte ein Minor-Versions-Update (1.14.1). Jeder, der ^1.14.0 verwendete, führte stillschweigend ein automatisches Upgrade durch. Die Malware lief, bevor es jemand bemerkte.

MCP-Server sind demselben Risiko ausgesetzt. Sie sind npm-Pakete. Sie laufen mit Ihren Anmeldedaten. Sie greifen auf Ihr Dateisystem und Ihre APIs zu. Und kein existierender Scanner verfolgt, ob das Paket, das Sie heute ausführen, dasselbe ist, das Sie letzte Woche überprüft haben.


Related MCP server: mcp-shield

Installation & Schnellstart

# 1. Lock all your MCP servers (one time)
npx @mcpguards/mcp-lock init

# 2. Commit the lockfile
git add .mcp.lock && git commit -m "chore: add mcp-lock lockfile"

# 3. Verify on every CI run (exits 1 if anything changed)
npx @mcpguards/mcp-lock verify

Das ist alles. Wenn sich ein Paket zwischen den Ausführungen ändert, wissen Sie es, bevor Ihr KI-Agent es ausführt.


Befehle

mcp-lock init

Erkennt alle MCP-Konfigurationen auf Ihrem Computer, löst jeden Server zu seinem npm-Paket auf und zeichnet die exakte Version + Tarball-Integritäts-Hash auf.

$ mcp-lock init

Found 4 server(s) across 2 config(s)

  ✔ filesystem      2026.1.1            sha512-xK3z…  ✔ attestation
  ✔ github          2026.1.1            sha512-9mRq…  ✔ attestation
  ✔ memory          2025.11.18          sha512-pL2t…  ○ no attestation
  ~ python-server   pypi registry — not lockable

─────────────────────────────────────────────────────────────────
  3 locked  1 skipped

✔ Lockfile written to .mcp.lock
Tip: Run with --pin to add version pins to your MCP configs.

Optionen:

--config <path>   Scan a specific config file
--pin             Rewrite configs to add @version pins
--force           Overwrite existing lockfile
--global          Write to ~/.mcp.lock

mcp-lock verify

Vergleicht Ihre installierten Pakete mit der Lockfile. Beendet den Prozess mit 1, falls sich etwas geändert hat.

$ mcp-lock verify

mcp-lock  .mcp.lock
────────────────────────────────────────────────────────────────
  ✔ filesystem
  ✔ github
  ⚠ memory  INTEGRITY-CHANGED
      integrity    sha512-pL2t…  →  sha512-XXXX…
      version      2025.11.18   →  2025.11.19
      ACTION REQUIRED: Run `mcp-lock update memory` after manual review.

────────────────────────────────────────────────────────────────
  2 clean  1 changed  0 skipped

✖ 1 server(s) changed since last lock.
  Run 'mcp-lock update <server>' to review and accept changes.

Optionen:

--sarif <path>    Write SARIF 2.1.0 report for GitHub Security tab
--json            Output as JSON
--global          Check against ~/.mcp.lock

Exit-Codes:

Code

Bedeutung

0

Sauber – alle Server stimmen mit der Lockfile überein

1

Geändert – ein oder mehrere Server wurden geändert oder die Lockfile wurde manipuliert

2

Lockfile fehlt – führen Sie mcp-lock init aus

3

Netzwerk- / Registry-Fehler

4

Ungültige Argumente


mcp-lock update <server>

Zeigt genau an, was sich geändert hat, bittet um Bestätigung und aktualisiert die Lockfile.

$ mcp-lock update memory

  memory
  version      2025.11.18 → 2025.11.19
  integrity    sha512-pL2t… →
               sha512-XXXX…

Accept update for memory? [y/N] y
✔ Updated 1 server(s) in .mcp.lock

Optionen:

--all             Update all servers
--to <version>    Update to a specific version
--yes             Skip confirmation prompt (for CI)
--pin             Also update version pin in the MCP config

mcp-lock list

Zeigt alle gesperrten (locked) Server an.

$ mcp-lock list

mcp-lock list  scope: project
────────────────────────────────────────────────────────────────
  ✔ filesystem      @modelcontextprotocol/server-filesystem    2026.1.1
  ✔ github          @modelcontextprotocol/server-github        2026.1.1
  ○ memory          @modelcontextprotocol/server-memory        2025.11.18
────────────────────────────────────────────────────────────────
  3 servers  generated 4/16/2026

GitHub Action

Fügen Sie dies zu jedem Repository hinzu, das eine .mcp.json-Konfiguration hat. Lässt den PR fehlschlagen, wenn ein Server ohne ein explizites mcp-lock update geändert wurde:

# .github/workflows/mcp-lock.yml
name: MCP Lock
on: [push, pull_request]

jobs:
  verify:
    runs-on: ubuntu-latest
    permissions:
      contents: read
      security-events: write   # for SARIF upload
    steps:
      - uses: actions/checkout@v4

      - uses: mcpguards/mcp-lock@v0.1.1
        with:
          sarif-output: mcp-lock.sarif

      - uses: github/codeql-action/upload-sarif@v3
        if: always()
        with:
          sarif_file: mcp-lock.sarif

Ergebnisse erscheinen im Tab Security → Code Scanning:

mcp-lock: server 'memory' integrity changed
  The tarball integrity hash changed since last lock.
  Run: mcp-lock update memory

Action-Inputs:

Input

Standard

Beschreibung

config-path

(automatische Erkennung)

Pfad zur MCP-Konfiguration

fail-on-missing-lock

true

Fehler, wenn keine Lockfile existiert

sarif-output

(keiner)

Pfad zum Schreiben des SARIF-Berichts


Die Lockfile

.mcp.lock ist eine JSON-Datei, die Sie in Ihr Repository einchecken. Sie zeichnet auf:

{
  "lockfileVersion": 1,
  "generatedBy": "mcp-lock@0.1.0",
  "generatedAt": "2026-04-16T12:00:00.000Z",
  "scope": "project",
  "servers": {
    "filesystem": {
      "source": {
        "command": "npx",
        "args": ["-y", "@modelcontextprotocol/server-filesystem"],
        "configPath": "/abs/path/.mcp.json"
      },
      "resolved": {
        "registry": "npm",
        "name": "@modelcontextprotocol/server-filesystem",
        "version": "2026.4.10",
        "tarball": "https://registry.npmjs.org/...tgz",
        "integrity": "sha512-AbC...==",
        "shasum": "a1b2c3...",
        "publishedAt": "2026-04-10T09:12:33.000Z"
      },
      "attestation": {
        "present": true,
        "predicateTypes": ["https://slsa.dev/provenance/v1"]
      },
      "lockedAt": "2026-04-16T12:00:00.000Z"
    }
  },
  "checksum": "sha256-9f86d081..."
}

Das Feld checksum ist ein SHA-256-Hash des gesamten Lockfile-Inhalts (kanonisches JSON, sortierte Schlüssel). Wenn die Datei manuell bearbeitet wird, ohne mcp-lock update auszuführen, wird verify dies erkennen.


Unterstützte MCP-Clients

Automatisch auf Ihrem Computer erkannt:

Client

Konfigurationspfad

Claude Desktop (macOS)

~/Library/Application Support/Claude/claude_desktop_config.json

Claude Code

~/.claude/settings.json

Cursor

~/.cursor/mcp.json

VS Code

~/Library/Application Support/Code/User/settings.json

Windsurf

~/.codeium/windsurf/mcp_config.json

Amazon Q

~/.aws/amazonq/mcp.json

Projektebene

.mcp.json im aktuellen Verzeichnis


Wie es sich von anderen Tools unterscheidet

Tool

Prüft npm-Pakete

Integritäts-Hash

Erkennt Versionsänderungen

SBOM

Lockfile

Snyk Agent Scan

❌

❌

❌

❌

❌

Cisco mcp-scanner

❌

❌

❌

❌

❌

MCPWatch

❌

❌

❌

❌

❌

mcp-lock

✅

✅

✅

✅

✅

Die anderen scannen Tool-Beschreibungen und Konfigurationen auf Prompt-Injection. mcp-lock behandelt MCP-Server als Artefakte der Software-Lieferkette und wendet eine Paket-Integritätsprüfung an – denselben Ansatz, den npm ci verwendet.


Anforderungen

  • Node.js >= 18.3.0

  • Funktioniert mit Claude Code, Cursor, VS Code Copilot, Windsurf, Amazon Q und jedem Tool, das die MCP-Spezifikation verwendet


Lizenz

MIT © Vamshidhar Reddy Parupally

Related MCP Connectors

Related MCP Servers

  • A
    license
    Not graded
    quality
    A
    maintenance
    Scans MCP servers for prompt injection, supply chain attacks, excessive permissions, and code execution risks. Includes an offline blacklist that catches known-compromised packages like LiteLLM 1.82.7/1.82.8 and Trivy with zero latency.
    19
    MIT
  • A
    license
    A
    quality
    D
    maintenance
    The MCP ecosystem is growing fast. Not every server on npm is safe. mcp-shield lets Claude audit any MCP server — local or from npm — before you trust it with your files, keys, and context.
    4
    60 npm
    2
    MIT
  • A
    license
    Not graded
    quality
    C
    maintenance
    MCP server that vets package installations and shell commands to block dangerous actions by AI coding agents.
    7 npm
    1
    MIT
  • A
    license
    Not graded
    quality
    D
    maintenance
    An account-free MCP server that checks AI-written changes before they are committed, detecting nonexistent packages, dependency risk shapes, and hardcoded secrets.
    MIT