Skip to content

Commit 6f425d3

Browse files
committed
docs: enhance CLI reference and MCP documentation
- Add detailed examples and parameter descriptions for all CLI commands - Expand MCP documentation with comprehensive tool descriptions - Fix navigation links to MCP guide (/mcp -> /guides/mcp) - Add "Next Steps" sections to guide pages - Update API reference link in documentation index
1 parent 5f6fae0 commit 6f425d3

File tree

7 files changed

+774
-156
lines changed

7 files changed

+774
-156
lines changed

docs/guides/getting-started.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ msb server start --dev
4040
!!!info MCP Server
4141
The microsandbox server is also an [MCP server](https://modelcontextprotocol.io), which means it works directly with Cursor, Claude, and other MCP-enabled AI tools out of the box!
4242

43-
[!ref See how to use microsandbox as an MCP server](/mcp)
43+
[!ref See how to use microsandbox as an MCP server](/guides/mcp)
4444
!!!
4545

4646
---

docs/guides/mcp.md

Lines changed: 249 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,41 +16,271 @@ The [Model Context Protocol (MCP)](https://modelcontextprotocol.io) is an open s
1616

1717
---
1818

19-
### MCP Capabilities
20-
21-
microsandbox exposes the following MCP capabilities:
22-
23-
#### Tools Available
24-
- **`sandbox_start`** - Create and start new sandboxes
25-
- **`sandbox_stop`** - Stop running sandboxes
26-
- **`sandbox_run_code`** - Execute code in sandboxes (Python, Node.js)
27-
- **`sandbox_run_command`** - Run shell commands in sandboxes
28-
- **`sandbox_get_metrics`** - Monitor sandbox resource usage
29-
30-
#### Connection Details
19+
### Connection Details
3120

3221
- **Endpoint:** `http://127.0.0.1:5555/mcp`
3322
- **Protocol:** Streamable HTTP
3423
- **Authentication:** Bearer token (if not in dev mode)
3524

3625
!!!info Transport Support
37-
microsandbox server only supports the **Streamable HTTP** transport protocol. The deprecated HTTP+SSE transport is not supported. Prefer **Streamable HTTP** when connecting with MCP clients.
26+
microsandbox server only supports the **Streamable HTTP** transport protocol.
3827
!!!
3928

4029
---
4130

31+
### Tools
32+
33+
microsandbox exposes tools through the MCP interface for complete sandbox lifecycle management.
34+
35+
---
36+
37+
### Sandbox Management Tools
38+
39+
==- `sandbox_start`
40+
Start a new sandbox with specified configuration. This creates an isolated environment for code execution.
41+
42+
| Parameter | Type | Required | Description |
43+
| ----------- | -------- | -------- | ----------------------------- |
44+
| `sandbox` | `string` || Name of the sandbox to start |
45+
| `namespace` | `string` || Namespace for the sandbox |
46+
| `config` | `object` | | Sandbox configuration options |
47+
48+
#### Configuration Options
49+
50+
| Property | Type | Description |
51+
| --------- | --------------- | ---------------------------------------------------------------------- |
52+
| `image` | `string` | Docker image to use (e.g., `microsandbox/python`, `microsandbox/node`) |
53+
| `memory` | `integer` | Memory limit in MiB |
54+
| `cpus` | `integer` | Number of CPUs |
55+
| `volumes` | `array[string]` | Volume mounts |
56+
| `ports` | `array[string]` | Port mappings |
57+
| `envs` | `array[string]` | Environment variables |
58+
59+
+++ Basic Python Sandbox
60+
61+
```json
62+
{
63+
"sandbox": "my-python-env",
64+
"namespace": "default"
65+
}
66+
```
67+
68+
+++ Custom Configuration
69+
70+
```json
71+
{
72+
"sandbox": "data-analysis",
73+
"namespace": "research",
74+
"config": {
75+
"image": "microsandbox/python",
76+
"memory": 1024,
77+
"cpus": 2,
78+
"envs": ["PYTHONPATH=/workspace"]
79+
}
80+
}
81+
```
82+
83+
+++ Node.js Environment
84+
85+
```json
86+
{
87+
"sandbox": "node-env",
88+
"namespace": "development",
89+
"config": {
90+
"image": "microsandbox/node",
91+
"memory": 512
92+
}
93+
}
94+
```
95+
96+
+++
97+
98+
!!!warning Important
99+
Always stop the sandbox when done to prevent it from running indefinitely and consuming resources.
100+
!!!
101+
===
102+
103+
==- `sandbox_stop`
104+
Stop a running sandbox and clean up its resources.
105+
106+
| Parameter | Type | Required | Description |
107+
| ----------- | -------- | -------- | --------------------------- |
108+
| `sandbox` | `string` || Name of the sandbox to stop |
109+
| `namespace` | `string` || Namespace of the sandbox |
110+
111+
```json
112+
{
113+
"sandbox": "my-python-env",
114+
"namespace": "default"
115+
}
116+
```
117+
118+
!!!warning Critical
119+
Always call this when you're finished with a sandbox to prevent resource leaks and indefinite running. Failing to stop sandboxes will cause them to consume system resources unnecessarily.
120+
!!!
121+
===
122+
123+
---
124+
125+
### Code Execution Tools
126+
127+
==- `sandbox_run_code`
128+
Execute code in a running sandbox environment.
129+
130+
| Parameter | Type | Required | Description |
131+
| ----------- | -------- | -------- | --------------------------------------------- |
132+
| `sandbox` | `string` || Name of the sandbox (must be already started) |
133+
| `namespace` | `string` || Namespace of the sandbox |
134+
| `code` | `string` || Code to execute |
135+
| `language` | `string` || Programming language (`python`, `nodejs`) |
136+
137+
+++ Python Execution
138+
139+
```json
140+
{
141+
"sandbox": "my-python-env",
142+
"namespace": "default",
143+
"code": "import math\nresult = math.sqrt(16)\nprint(f'Square root: {result}')",
144+
"language": "python"
145+
}
146+
```
147+
148+
+++ JavaScript Execution
149+
150+
```json
151+
{
152+
"sandbox": "node-env",
153+
"namespace": "development",
154+
"code": "const fs = require('fs');\nconst data = { message: 'Hello from Node.js!' };\nconsole.log(JSON.stringify(data, null, 2));",
155+
"language": "nodejs"
156+
}
157+
```
158+
159+
+++
160+
161+
!!! Prerequisites
162+
The target sandbox must be started first using `sandbox_start` - this will fail if the sandbox is not running. Code execution is synchronous and may take time depending on complexity.
163+
!!!
164+
===
165+
166+
==- `sandbox_run_command`
167+
Execute shell commands in a running sandbox.
168+
169+
| Parameter | Type | Required | Description |
170+
| ----------- | --------------- | -------- | --------------------------------------------- |
171+
| `sandbox` | `string` || Name of the sandbox (must be already started) |
172+
| `namespace` | `string` || Namespace of the sandbox |
173+
| `command` | `string` || Command to execute |
174+
| `args` | `array[string]` | | Command arguments |
175+
176+
+++ Simple Command
177+
178+
```json
179+
{
180+
"sandbox": "my-python-env",
181+
"namespace": "default",
182+
"command": "ls"
183+
}
184+
```
185+
186+
+++ Command with Arguments
187+
188+
```json
189+
{
190+
"sandbox": "my-python-env",
191+
"namespace": "default",
192+
"command": "ls",
193+
"args": ["-la", "/workspace"]
194+
}
195+
```
196+
197+
+++ Package Installation
198+
199+
```json
200+
{
201+
"sandbox": "data-analysis",
202+
"namespace": "research",
203+
"command": "pip",
204+
"args": ["install", "pandas", "numpy", "matplotlib"]
205+
}
206+
```
207+
208+
+++
209+
210+
!!!info Prerequisites
211+
The target sandbox must be started first using `sandbox_start` - this will fail if the sandbox is not running. Command execution is synchronous and may take time depending on complexity.
212+
!!!
213+
===
214+
215+
---
216+
217+
### Monitoring Tools
218+
219+
==- `sandbox_get_metrics`
220+
Get metrics and status for sandboxes including CPU usage, memory consumption, and running state.
221+
222+
| Parameter | Type | Required | Description |
223+
| ----------- | -------- | -------- | ------------------------------------------------- |
224+
| `namespace` | `string` || Namespace to query (use `*` for all namespaces) |
225+
| `sandbox` | `string` | | Optional specific sandbox name to get metrics for |
226+
227+
+++ Single Sandbox
228+
229+
```json
230+
{
231+
"sandbox": "my-python-env",
232+
"namespace": "default"
233+
}
234+
```
235+
236+
+++ All Sandboxes in Namespace
237+
238+
```json
239+
{
240+
"namespace": "development"
241+
}
242+
```
243+
244+
+++ All Sandboxes
245+
246+
```json
247+
{
248+
"namespace": "*"
249+
}
250+
```
251+
252+
+++
253+
254+
**Returns:** JSON object with metrics including:
255+
256+
- `name` - Sandbox name
257+
- `namespace` - Sandbox namespace
258+
- `running` - Boolean running status
259+
- `cpu_usage` - CPU usage percentage
260+
- `memory_usage` - Memory usage in MiB
261+
- `disk_usage` - Disk usage in bytes
262+
263+
!!! Usage
264+
This tool can check the status of any sandbox regardless of whether it's running or not, making it useful for monitoring and cleanup operations.
265+
!!!
266+
===
267+
268+
---
269+
42270
### Setting Up microsandbox with an Agent
43271

44272
Let's use [Agno](https://docs.agno.com) to build an AI agent that can execute code in microsandbox.
45273

46274
#### Prerequisites
47275

48276
1. **Install Agno and dependencies**:
277+
49278
```bash
50279
pip install agno openai
51280
```
52281

53282
2. **Start microsandbox server**:
283+
54284
```bash
55285
msb server start --dev
56286
```
@@ -99,13 +329,15 @@ microsandbox works with any MCP-compatible application:
99329
#### Complete Workflow
100330

101331
1. **Start the server:**
332+
102333
```bash
103334
msb server start --dev
104335
```
105336

106337
2. **Configure Claude Desktop** with the MCP server
107338

108339
3. **Test the integration:**
340+
109341
```
110342
Ask Claude: "Can you start a Python sandbox and run a simple calculation?"
111343
```
@@ -118,16 +350,19 @@ Ask Claude: "Can you start a Python sandbox and run a simple calculation?"
118350
#### Advanced Usage
119351

120352
**Data Analysis Workflow:**
353+
121354
```
122355
"Create a Python sandbox, install pandas, and analyze this CSV data: [paste data]"
123356
```
124357

125358
**Web Development:**
359+
126360
```
127-
"Start a Node.js sandbox, create a simple Express server, and show me the code"
361+
"Start a Node.js sandbox and create a simple HTML generator script"
128362
```
129363

130364
**Multi-step Processing:**
365+
131366
```
132367
"Create a sandbox, download some data, process it, and create a visualization"
133368
```
@@ -136,6 +371,4 @@ Ask Claude: "Can you start a Python sandbox and run a simple calculation?"
136371

137372
### Next Steps
138373

139-
Now that you understand MCP integration:
140-
141374
[!ref API Reference](/references/api)

docs/guides/projects.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,3 +79,9 @@ This executes the default _start_ script of your sandbox. For more control, you
7979
```bash
8080
msr myapp~start
8181
```
82+
83+
---
84+
85+
### Next Steps
86+
87+
[!ref CLI Reference](/references/cli#project-management)

docs/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ asyncio.run(main())
6666
!!!info AI Integration Ready
6767
microsandbox server speaks [MCP](https://modelcontextprotocol.io) natively - connect it to **Cursor**, **Claude**, or any MCP-compatible AI tool in seconds!
6868

69-
[!ref See how to use microsandbox as a MCP server](/mcp)
69+
[!ref See how to use microsandbox as a MCP server](/guides/mcp)
7070
!!!
7171

7272
---

0 commit comments

Comments
 (0)