---
title: "LM Studio Sandbox | Cosmonic"
description: "Sandbox LM Studio with Cosmonic Desktop: connect it over MCP and install the cosmonic-sandbox skill so the code it writes runs in a local WebAssembly sandbox, isolated from your files, network, and keys."
canonical: "https://cosmonic.com/docs/desktop/agents/lm-studio-sandbox/"
---

# LM Studio Sandbox

Cosmonic Desktop is a local **AI sandbox** for [LM Studio](https://lmstudio.ai/): the code the model writes is compiled to WebAssembly and runs on your own machine with no access to your files, network, or keys until you grant it. LM Studio is a GUI MCP host rather than a terminal coding agent, so the wiring is two settings and one selection inside LM Studio: a config preset from Settings → Agents, Desktop's MCP server from Settings → MCP Server, and the preset picked in a chat.

## Sandbox LM Studio with Cosmonic Desktop

### 1. Settings → Agents: install the Cosmonic Sandbox preset

Open **Settings → Agents**. LM Studio appears in **Detected agents** when `~/.lmstudio` exists, marked as a GUI host: it is not launchable from Build. In the **Skills** card, turn on **LM Studio** to install a **config preset**, not a skill, at `~/.lmstudio/cosmonic-sandbox/`. The preset is a condensed system prompt that teaches the model the sandbox loop; select **Cosmonic Sandbox** as the preset in an LM Studio chat to use it.

### 2. Settings → MCP Server: install Desktop's MCP server into LM Studio

Open **Settings → MCP Server**. Under **Install in your AI client**, turn on **LM Studio**: Desktop's toggle merges the entry into `~/.lmstudio/mcp.json` (LM Studio 0.3.17 or later reads the standard `mcpServers` schema there). This registers `cosmonicd mcp serve` as an MCP server in LM Studio'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.

Or paste this through LM Studio's in-app editor (**Program → Install → Edit mcp.json**):

```json
{
  "mcpServers": {
    "cosmonic": {
      "command": "/Applications/Cosmonic Desktop.app/Contents/Resources/cosmonicd",
      "args": ["mcp", "serve"]
    }
  }
}
```

### 3. Verify the connection

In an LM Studio chat, enable the `cosmonic` MCP server in the tools panel and select the **Cosmonic Sandbox** preset; ask the model to list Cosmonic workloads and the `cosmonic_*` tools should answer while Desktop is running.

### 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](https://github.com/modelcontextprotocol/ext-skills) 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 Build relies on for the agents it launches.

## What LM Studio can do once connected

Its full tool surface (observe, deploy, build) and the guardrails are covered in [Connect Coding Agents](https://cosmonic.com/docs/desktop/coding-agents/#what-the-agent-can-do); the tools work only while Cosmonic Desktop is running.

## Frequently asked questions

### How do I sandbox LM Studio?

Install Cosmonic Desktop, then under Settings → Agents turn on LM Studio to install the cosmonic-sandbox skill, and under Settings → MCP Server register Desktop’s MCP server in LM Studio. From then on the code LM Studio 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 LM Studio itself run inside the sandbox?

No. LM Studio 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 LM Studio 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 LM Studio 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.

### Why does LM Studio get a preset instead of a skill?

LM Studio has no skills directory: it is a GUI model host with an MCP client, not a terminal agent. Desktop therefore ships a config preset, a condensed system prompt you select per chat, and the full skills reach the model over MCP through the Skills extension once the server is connected.

## Next steps

- The server's trust model and tool reference: [Connect Coding Agents](https://cosmonic.com/docs/desktop/coding-agents/).
- Sandbox the tool servers your agent calls: [Sandbox MCP Servers](https://cosmonic.com/docs/desktop/sandbox-mcp-servers/).
- What an AI sandbox is and why it matters: [AI Sandbox](https://cosmonic.com/ai-sandbox/).

Last updated on **Nov 9, 2026** by **Eric Gregory**
