MCP in a Can 🥫 - Sandboxed, Reproducible MCP Servers Without Docker
What happens when you add a new MCP server to your AI agent using npx or uvx? In a conventional, unsandboxed environment, you're downloading third-party code and executing it with your own privileges. Your SSH keys. Yo
What happens when you add a new MCP server to your AI agent using npx or uvx?
In a conventional, unsandboxed environment, you're downloading third-party code and executing it with your own privileges.
Your SSH keys. Your cloud credentials. Your source code. Your network.
Does an MCP memory server really need access to all of that?
I've been building Cantainer, an open-source project written in Rust that explores a different approach to distributing and executing software.
Introducing MCP in a can
A can is a distributable OCI artifact containing:
- An executable and its runtime.
- Cryptographically pinned dependencies and system libraries.
- A Software Bill of Materials (SBOM).
- A machine-readable, kernel-enforced permission manifest.
Think of it as software packaged together with its security contract.
Cantainer uses Linux Landlock and seccomp to enforce permissions, with approximately a millisecond of additional startup overhead in initial benchmarks.
No Docker engine. No root privileges. No background daemon.
What does it look like?
Instead of launching an MCP memory server using:
npx -y @modelcontextprotocol/server-memory
The OCI registry workflow looks like this:
cant pull ghcr.io/cantainer/server-memory:2.2.1
cant inspect ghcr.io/cantainer/server-memory:2.2.1
cant run ghcr.io/cantainer/server-memory:2.2.1
And the corresponding Claude Code configuration:
{
"mcpServers": {
"memory": {
"command": "cant",
"args": [
"run",
"ghcr.io/cantainer/server-memory:2.2.1"
]
}
}
}
Same MCP server. Same protocol. A fundamentally different security model.
The server can access its dedicated data directory, but its policy denies access to unrelated personal files and the network.
These restrictions are enforced by the Linux kernel, rather than an AI prompt or the server's own implementation.
Building an MCP server from a Canfile
A Canfile is a declarative recipe that describes where the software comes from, how it is packaged and what it is allowed to do.
Here is the essential part of the memory server's recipe:
canfile_version = 0
name = "server-memory"
version = "2.2.1"
[build]
runtime = "[email protected]"
npm = "@modelcontextprotocol/[email protected]"
run = "dist/index.js"
[capabilities]
network = false
fs.ensure_dirs = ["~/.local/share/mcp-memory"]
[env]
set = { MEMORY_FILE_PATH = "~/.local/share/mcp-memory/memory.jsonl" }
[test]
mcp = true
The generated lock section pins the runtime, dependencies, system libraries and build tools by cryptographic hash.
Unlike a traditional Dockerfile, there is no arbitrary sequence of build commands. Runtime-specific presets construct the artifact from pinned inputs.
The goal is reproducibility across Linux distributions. The same memory server recipe has already produced byte-identical files when built on Ubuntu and Fedora.
A growing ecosystem of MCP servers
The cantainer/cans repository already contains recipes for 16 MCP servers and integrations:
- Core tools: Memory, Filesystem, Sequential Thinking, Fetch and Time.
- Developer tools: GitHub and Context7.
- Infrastructure: Kubernetes, Terraform and Grafana.
- Data and productivity: Supabase and Notion.
- Search and web: Brave Search, Exa and Firecrawl.
- Remote integration: MCP Remote.
The catalog supports Node.js, Python and native binaries, with automated multi-architecture builds and MCP functional tests.
Each server declares its own permissions.
A sequential-thinking server doesn't need the network or access to user files. A filesystem server needs only the directories explicitly granted to it. A GitHub server needs network access and an API token, not access to your home directory.
The permission model should reflect those differences.
Try it yourself
Cantainer runs on Linux with kernel 6.2 or newer, including suitable WSL and Linux VM environments.
You can install it using Cargo:
cargo install cantainer
Check whether your kernel supports the required isolation features:
cant check
Then build an MCP memory server locally:
git clone https://github.com/cantainer/cans
cd cans
cant build recipes/server-memory/Canfile
cant inspect ./server-memory.can
Register it with Claude Code:
claude mcp add memory -- cant run "$PWD/server-memory.can"
The official OCI registry packages are currently private pending artifact signing and licensing compliance. Local builds from the published recipes are already supported.
What's still missing?
Cantainer is experimental and has not been independently security-audited.
Some particularly interesting engineering challenges remain:
- Sigstore-based artifact signing and verification.
- Automated permission approval and permission-aware updates.
- Granular network destination restrictions. Currently, network-enabled cans do not have host-level allowlist enforcement.
- Stronger content-addressed store integrity.
- Expanding the catalog of MCP servers.
- Independent security research and adversarial testing.
I want to explore whether AI agents could eventually discover, evaluate and install tools autonomously, provided their requested capabilities remain within an approved security policy.
Installing software should not automatically mean granting it authority.
Looking for collaborators
I'd love to collaborate with developers interested in MCP, Rust, Linux internals, security engineering and reproducible software distribution.
Contributing doesn't necessarily require Rust knowledge. Adding an MCP server can be as simple as creating a Canfile, generating its dependency lock and testing the resulting artifact.
Both repositories are open source under MIT or Apache 2.0.
Runtime and architecture:
https://github.com/cantainer/cantainer
MCP server recipes:
https://github.com/cantainer/cans
The broader architectural vision:
We Gave AI Agents a Shell. Now What?
Which MCP servers would you like to see packaged next? What security guarantees would you need before trusting an ecosystem like this?
Feedback, architectural discussions and pull requests are welcome.
By default, you can't.
Originally published by Dev.to Security. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.