A real CI scan found that hardening an internal MCP server removed unused npm tooling, reducing image attack surface while changing build and debugging workflows.

Internal services that connect AI agents to company systems deserve the same container scrutiny as public APIs. These services may hold credentials and broad permissions, yet they can receive less security attention because they aren't directly exposed to customers. A real CI comparison of a custom Model Context Protocol (MCP) server shows why hardened base images matter: they can remove tools the application never needs, including parts of Node.js’s bundled npm toolchain.
The distinction between an internal service and a public one can be misleading. An MCP server may sit behind other controls, but its permissions can still make it a valuable target if an attacker reaches it through a compromised workload or stolen credentials. Container contents won't prevent every breach, but they affect the tools and code available inside the boundary after one occurs.
What the image comparison revealed
The test rebuilt a small internal MCP server on a hardened base and scanned both versions in CI. The notable change went beyond the vulnerability count. A substantial share of the removed components belonged to npm’s dependency and publishing tools, which ship in a standard Node.js image even when a running server never calls npm.
That detail matters because a container image is often treated as a passive package for the application, when it also carries the tooling used to build and manage it. If the runtime process doesn't need npm, retaining its utilities adds code without adding application capability. A scanner can report known vulnerabilities, but the comparison also points to a more basic question: why ship the component at all?
That leaves code and utilities in the container without a runtime purpose. Removing them narrows the available attack surface, and a hardened base can catch this excess where a manual cleanup of operating system packages might not. This is more significant than it looks: reducing what ships can limit both exposure to known flaws and the options available to someone who gains access to the container.
Three approaches to smaller runtime images
Google’s Distroless offers an established, free option with tightly stripped runtime images. Standard variants omit shells and package managers, which reduces the set of tools present after deployment. Kubernetes, Knative and Tekton use Distroless, though the timing of fixes depends on upstream package updates and image rebuilds, which can leave a delay after a vulnerability is disclosed.
That update path is part of the operational trade-off. A minimal image can reduce unnecessary components, but teams still need to track the base image and rebuild their own application image when relevant updates arrive. Distroless can suit teams comfortable managing that process and accepting the cadence set by upstream releases.
Chainguard Images are built from source using Wolfi and Chainguard OS, with daily rebuilds. The free tier is limited to latest and latest-dev tags; version-specific tags and remediation backed by a service-level agreement require a paid subscription.
The tag limits matter for teams that need to pin a particular version as part of a controlled release process. Daily rebuilds describe the image provider’s cadence, while the service terms define what support a customer can expect. Those are related but separate considerations, and teams should weigh both against their own release and incident-response routines.
Docker’s Hardened Images use Debian or Alpine foundations, which can make adoption simpler for teams already using those distributions. The core images became free and Apache 2.0 licensed at the end of 2025.
Familiar foundations can reduce the changes needed in existing build pipelines, though teams still need to validate compatibility with their application and deployment process. The license and pricing terms also shape whether an option can be adopted broadly without adding a new subscription decision.
The choice comes down to the migration a team can absorb, the patch commitments it needs and the supply-chain provenance its compliance requirements call for. Teams already using Kubernetes ecosystem tools may find Distroless a practical no-cost default. Chainguard suits organizations that need stronger provenance and can pay for its service terms. Docker’s option may fit teams seeking a smaller runtime while keeping their existing distribution base.
There isn't a universal winner here. If you're working in this space, the useful comparison is how each image fits your build pipeline, update ownership and deployment constraints—not simply how small the final image looks.
Smaller images change build and debug routines
These minimal runtime images generally have no shell or package manager. That removes tools an intruder might use after a compromise, but it also ends the familiar practice of entering a live container to inspect it with standard utilities.
That can expose a gap in teams’ troubleshooting habits. A shell in a production container is convenient because it puts familiar commands beside the failing process, but it also means those commands remain available in the deployed environment. Removing them asks engineers to make diagnosis a deliberate part of the deployment design.
Multi-stage builds become especially useful: install dependencies and build the application in a stage with a full toolchain, then copy only the needed files into the runtime image. This separates the environment needed to produce the service from the one needed to run it. It can also make the image contents easier to review, since the runtime stage should contain a narrower set of files.
Debugging also shifts. Instead of keeping diagnostic tools in every production container, teams can use debug images, development variants or tools that provide access when needed. That approach requires preparation: an emergency workflow is only useful if engineers know how to use it before an incident. A smaller image without a workable diagnostic path can turn routine investigation into avoidable friction.
Internal agent services belong in the security review
Container hardening has often focused on customer-facing applications. MCP servers and other internal bridges that give AI systems access to company services are expanding the set of containers with sensitive credentials and API permissions. Their internal location doesn't make those permissions less consequential; it changes where teams need to look for exposure.
The practical lesson is to scan and minimize these images with the same care given to public services. Removing unused runtime components can limit what’s available if an internal service is compromised. It won't replace careful permission design or patching, but it addresses a part of the security boundary that teams can inspect directly.
For organizations adopting agent connected services, the image comparison offers a useful review prompt: identify what the deployed process actually needs, then check whether the base image includes more. That question applies beyond MCP. Any internal service that carries credentials or can call company systems deserves an account of its runtime contents and a plan for keeping those contents current.
And the overlooked part? Minimal images affect daily operations as much as security posture. Teams that plan the build, update and debug workflow together are more likely to keep the reduced image useful after the initial hardening work is done.

Discussion
Sign in to join the discussion.