OpenCode Sandbox
Cosmonic Desktop is a local AI sandbox for OpenCode: the code OpenCode writes is compiled to WebAssembly and runs on your own machine with no access to your files, network, or keys until you grant it. Two settings wire it up, one for launching OpenCode from Builder with the sandbox playbook and one for installing Desktop's MCP server into OpenCode; use either or both.
Sandbox OpenCode with Cosmonic Desktop
1. Settings → Agents: launch OpenCode from Builder
Open Settings → Agents. The Detected agents card lists every coding agent Desktop found by its home directory (~/.config/opencode or ~/.opencode) or on your login shell's PATH, and says whether each one is launchable from Builder. In the Skills card, turn on OpenCode to install the cosmonic-sandbox skill at ~/.config/opencode/skills/cosmonic-sandbox/. This is the same install the one-time Set up your coding agents dialog offers on first run; nothing is installed silently.
The skill is the sandbox playbook: it teaches OpenCode to compile what it generates to a WebAssembly component and deploy it into the local sandbox instead of running it raw on your host. Once it is installed, Builder can launch OpenCode directly: open Builder, pick OpenCode as the agent, describe what you want, and its output lands in a sandboxed workload you can inspect before it runs.
Alongside the skill, Desktop installs a Cosmonic agent profile at ~/.config/opencode/agents/cosmonic.md. That profile is OpenCode's guarded mode: it keeps the sandbox in the loop without per-action prompts, and it is what Builder selects with --agent cosmonic.
2. Settings → MCP Server: install Desktop's MCP server into OpenCode
Open Settings → MCP Server. Under Install in your AI client, turn on OpenCode: OpenCode's server map is its own shape (a top-level mcp map, not mcpServers) and opencode mcp add cannot register a local stdio server without prompting, so Desktop's toggle edits ~/.config/opencode/opencode.json (or .jsonc) directly. This registers cosmonicd mcp serve as an MCP server in OpenCode's own configuration, and the cosmonic_* tools (observe, deploy, build) are available the next time you start it. Expand Instructions on the same card to copy the manual snippet instead.
To do it by hand, add this to ~/.config/opencode/opencode.json:
{
"mcp": {
"cosmonic": {
"type": "local",
"command": [
"/Applications/Cosmonic Desktop.app/Contents/Resources/cosmonicd",
"mcp",
"serve"
],
"enabled": true
}
}
}3. Verify the connection
opencode mcp list # the cosmonic server should be listed and enabledRun opencode mcp list; cosmonic should be listed and enabled. Builder starts OpenCode with --agent cosmonic by default, the guarded profile Desktop installs, because OpenCode ships only a full-bypass flag and no middle mode of its own.
Skills over MCP
Desktop's MCP server also publishes its skill family—cosmonic-sandbox, cosmonic-go, cosmonic-nats, cosmonic-nats-tuning, and cosmonic-kafka—through the MCP Skills extension (io.modelcontextprotocol/skills). A client that supports Skills over MCP gets the playbooks the moment it connects, with nothing written to its skills directory, so the MCP registration above is enough on its own for those clients. The on-disk skill from Settings → Agents covers clients that read a skills directory but do not yet speak the extension, and it is what Builder relies on to launch OpenCode.
What OpenCode can do once connected
Its full tool surface (observe, deploy, build) and the guardrails are covered in Connect Coding Agents; the tools work only while Cosmonic Desktop is running.
Frequently asked questions
How do I sandbox OpenCode?
Install Cosmonic Desktop, then under Settings → Agents turn on OpenCode to install the cosmonic-sandbox skill, and under Settings → MCP Server register Desktop’s MCP server in OpenCode. From then on the code OpenCode writes is compiled to WebAssembly and runs in a local sandbox with no access to your files, network, or keys until you grant it.
Does OpenCode itself run inside the sandbox?
No. OpenCode keeps running in your terminal or IDE exactly as before. What changes is where its output executes: the programs and MCP servers it builds run as sandboxed WebAssembly workloads on your machine instead of directly on your host.
Do I need both the skill and the MCP server?
They do different jobs. The MCP server gives OpenCode the tools to build, deploy, and observe sandboxed workloads; the skill gives it the know-how to use them by default. Desktop also publishes its skills over the MCP Skills extension, so a client that supports Skills over MCP gets the playbook from the connection alone.
What can the code OpenCode writes reach inside the sandbox?
Nothing by default. Each workload starts with no filesystem, network, or credential access; you grant exactly the capabilities it needs in its manifest, and everything else stays denied. The same manifest deploys unchanged to Cosmonic Control on Kubernetes.
What is the cosmonic agent profile OpenCode gets?
OpenCode has no guarded middle mode as a launch flag (it ships only the full-bypass flag), so Desktop installs an agent profile at ~/.config/opencode/agents/cosmonic.md that plays that role. Builder launches OpenCode with --agent cosmonic so generated code goes to the sandbox by default.
Next steps
- The server's trust model and tool reference: Connect Coding Agents.
- Sandbox the tool servers your agent calls: Sandbox MCP Servers.
- What an AI sandbox is and why it matters: AI Sandbox.