How to Keep Sensitive Data Out of an MCP Server’s Model Context
When you build a server with the Model Context Protocol (MCP), your tools let a model pull data from services like databases…
If you develop on an Apple silicon Mac and want Claude Code to run in Linux, Apple’s container command-line tool can run a packaged Linux environment, called an image, inside a lightweight virtual machine. You build the image with Claude Code installed, then start it with your project directory mounted as its workspace. Because a mount is a shared folder, any file Claude edits inside the container also changes on your Mac.
Claude can reach host files only in the directories you share with it. Even so, the container still lets Claude write to your project, read any credentials you pass in, and reach the network. Apple supports this tool on macOS 26 or later; its container project explains the setup and links to the signed installer.
Download and install Apple’s signed package from the project’s releases, then start the container service:
container system start
Apple’s tool builds and runs images that follow the Open Container Initiative (OCI) format, a standard for packaging container images. It reads Dockerfiles, the text files that describe how to assemble an image, though it is separate from Docker Desktop. Check the documentation for the release you install, since commands and flags can change between versions.
Create a Dockerfile in your project directory. This example starts from a Debian-based Node.js image, installs a few basic tools, switches from root to the regular node account so Claude does not run with full system privileges, and installs Claude Code:
FROM node:22-bookworm-slim
RUN apt-get update \
&& apt-get install -y --no-install-recommends ca-certificates curl git \
&& rm -rf /var/lib/apt/lists/*
USER node
ENV PATH="/home/node/.local/bin:${PATH}"
WORKDIR /workspace
RUN curl -fsSL https://claude.ai/install.sh | bash
CMD ["claude"]
In its Claude Code installation guidance, Anthropic documents this installer command for macOS and Linux and notes that the native installer places the executable at ~/.local/bin/claude. This Dockerfile runs that installer while building the image. Check it against Anthropic’s current instructions and the Linux base image you plan to use.
From the directory that holds your Dockerfile, build the image:
container build -t claude-code:local .
Apple’s container build command assembles an image from a Dockerfile and a local build context. The trailing . tells the builder to use your current directory as that context, which determines which local files it can read during the build.
From your project directory, export an API key if you authenticate with Anthropic’s API, then start the container:
export ANTHROPIC_API_KEY="your-api-key"
container run --rm -it \
--volume "$PWD:/workspace" \
--workdir /workspace \
--env ANTHROPIC_API_KEY \
claude-code:local
The --volume flag shares your current directory at /workspace, and --workdir starts Claude Code inside it. Apple covers both mount and environment flags in its volume instructions. When Claude exits, --rm deletes the container, while the image stays on disk for your next run.
Because the mount is writable, any file Claude edits in /workspace changes on your Mac right away. If you want to protect your original checkout, copy the project to a disposable folder or create a separate Git worktree and mount that instead. Do not mount your entire home directory or credential folders when Claude only needs the project.
The --env flag passes your exported API key into the container. Any process inside the container can read that key, so never bake it into the Dockerfile or image. If you sign in to Claude Code with another supported method, authenticate from inside the container and follow Anthropic’s current instructions for that flow.
Apple runs Linux containers inside lightweight virtual machines, which gives Claude a Linux environment with only the host folders you explicitly share. In the command above, your project is the only shared folder, so files outside that mount stay out of the container’s working view.
That boundary still has limits. Claude can modify your project, processes in the container can read the API key, and the command does not limit outbound network traffic to an allow-list of permitted destinations. Apple’s CLI does not read Anthropic’s Dev Container configuration, so it will not apply the firewall rules from Anthropic’s Docker-based reference setup.
For your first run, start with a disposable copy of the project, mount only that directory, and pass only the credentials Claude needs. If your work requires network restrictions, set those up and test them separately, because this basic run command leaves outbound traffic unfiltered.
Give Vroni a GitHub issue, bug report, spec, or rough idea. It reads the repo, plans the change, writes code, runs checks, and works toward a review-ready pull request.
Take a look at vroni.com