Run an MCP server in a sandbox
Keep an MCP server away from your files by running it in a Linux sandbox.
Requires OSMates Pro.
Make the sandbox
An MCP server your client starts on your Mac runs as you. It can read your SSH keys and tokens. Claude Code runs these servers outside its sandbox, with your full access.
- Make a Linux machine for the server and open a shell in it:
osmates vm create mcp-base --image debian-13
osmates vm start mcp-base --wait agent
osmates ssh mcp-base
- Install the server as its instructions say, then run
exit. - Stop the machine, then clone and start a sandbox:
osmates vm stop mcp-base
osmates vm clone mcp-base mcp --preset agent-sandbox
osmates vm start mcp --wait agent
Start mcp before your client. When it stops, it's deleted with everything the server wrote. Clone it again for your next session.
Allow another host
The sandbox reaches package registries, GitHub, and model APIs. If the server needs another host:
osmates vm egress mcp --allow api.example.com
To keep a rule for every sandbox, set it on mcp-base before you clone. A source with its own rules passes on only those, so add the presets too:
osmates vm egress mcp-base --mode allowlist --allow preset:packages --allow preset:github --allow preset:models --allow api.example.com
Register the server with your client
Your client starts the server with ssh mcp.osmates -- <command>, which needs ssh by name. Replace <command> with the command that starts the server, and <server> with a name for it.
Claude Code
claude mcp add --transport stdio --scope user <server> -- ssh mcp.osmates -- <command>
The first -- ends Claude Code's options, and the second ends ssh's. With --scope user, every project of yours gets the server.
To share the server with everyone on a project, add it to .mcp.json at the project's root instead:
{
"mcpServers": {
"<server>": {
"type": "stdio",
"command": "ssh",
"args": ["mcp.osmates", "--", "<command>"]
}
}
}
Claude Code's MCP documentation lists the other scopes and settings.
Codex
codex mcp add <server> -- ssh mcp.osmates -- <command>
Or add the server to ~/.codex/config.toml:
[mcp_servers.<server>]
command = "ssh"
args = ["mcp.osmates", "--", "<command>"]
Codex's MCP documentation lists the other settings.