mcpField
L
layercheck

layercheck

Local
github.com/CloudCorpRecordsDeveloper Tools0Updated 1w ago

About layercheck

layercheck is a CLI and stdio MCP server that analyzes Dockerfiles without a Docker daemon or build. It helps developers inspect layer counts and sizes and identify specific patterns that can waste image space or build cache.

Key features

  1. 01Parse Dockerfile instructions and continuations
  2. 02Count layer-producing instructions
  3. 03Rank supplied layer sizes from largest
  4. 04Flag consecutive RUN instructions
  5. 05Detect early broad COPY, APT leftovers, and local ADD

Use cases

  1. 01Find large layers from supplied docker history sizes
  2. 02Spot Dockerfile patterns that may waste image space
  3. 03Review cache-impacting COPY placement
  4. 04Check layer-size input against instruction counts

MCP support

Exposes the `analyze_dockerfile_layers` tool, which accepts Dockerfile text and optional layer sizes and returns analysis including layer counts, ranked sizes, and waste flags.

Configuration

Local server config is the same for every client. Copy it into your client’s MCP config file.

mcp.json · Universal config
{
"mcpServers": {
"cloudcorprecords-layercheck": {
"command": "npx",
"args": [
"-y",
"@reneturcios/layercheck"
]
}
}
}
Run commandnpx -y @reneturcios/layercheck

Local servers need a runtime on your machine (e.g. Node.js 18+). Config file locations differ by client; see your client’s docs.

Packages
npm@reneturcios/layercheck0.1.0
ocighcr.io/cloudcorprecords/layercheck:0.1.0

Tools

1

Saved tool list · updated 1w ago

ParameterTypeRequiredDescription
dockerfilestringYesThe Dockerfile text
layer_sizesarrayNoSize in bytes of each layer-producing instruction (RUN, COPY, ADD), in Dockerfile order, as docker history would report them; length must equal the number of layer-producing instructions

Details

From the project README

layercheck

Every RUN, COPY, and ADD in a Dockerfile leaves a layer in the image, and layers are where image size and build-cache pain live. layercheck reads a Dockerfile as plain text — no docker daemon, no build — and reports what it finds:

  • every instruction, parsed with \ continuations joined and blank lines and # comments skipped, each marked with whether it produces a layer
  • the layer count, and — when you supply per-layer sizes (as docker history reports them) — the total size and the layers ranked biggest first, so the fattest layer is the first thing you see
  • deterministic waste flags, each with the line it fires on:
    • CONSECUTIVE_RUN — a RUN immediately after another RUN; the two could be one layer
    • BROAD_COPY_EARLY — a COPY . . (or ./) placed before the dependency install step, busting its cache on every source change
    • APT_LEFTOVER — apt-get install without removing /var/lib/apt/lists in the same RUN
    • ADD_LOCAL — ADD used for an ordinary local file, where COPY is the clearer instruction (remote URLs and archives are fine)

If the supplied sizes do not line up with the number of layer-producing instructions, layercheck says so and names both counts instead of silently misaligning them.

CLI

npx @reneturcios/layercheck analyze --dockerfile Dockerfile
npx @reneturcios/layercheck analyze --dockerfile Dockerfile --sizes sizes.json
npx @reneturcios/layercheck --version

sizes.json is a JSON array of numbers: the size in bytes of each layer-producing instruction, in Dockerfile order. The analysis is printed as one JSON object: {layer_count, total_size_bytes, instructions, biggest_layers, waste_flags}.

Exit codes: 0 on success, 1 on a runtime error (including an unreadable file or a sizes length mismatch), 2 on a usage error.

MCP server

npx -y @reneturcios/layercheck mcp

MCP client config:

{
  "mcpServers": {
    "layercheck": {
      "command": "npx",
      "args": ["-y", "@reneturcios/layercheck", "mcp"]
    }
  }
}
Tools
  • analyze_dockerfile_layers — Analyze a Dockerfile's layers and flag wasted ones.
    • dockerfile (string, required) — the Dockerfile text
    • layer_sizes (array of numbers, optional) — size in bytes of each layer-producing instruction, in Dockerfile order; its length must equal the number of layer-producing instructions

Docker

docker run -i ghcr.io/cloudcorprecords/layercheck
docker run --rm -v "$PWD:/w" ghcr.io/cloudcorprecords/layercheck analyze --dockerfile /w/Dockerfile

Development

npm install
npm run build   # tsc -> dist/
npm test        # tsx --test test/*.test.ts (pure local, no network)
npm run dev     # run the CLI from source

License

MIT — Copyright (c) 2026 Rene Turcios

Comments

Markdown supported

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.