Terminal Sandbox
Execute code and commands in an isolated sandbox environment. Each chat room has its own independent sandbox, allowing you to safely test code and process data.
Key Features
- Execute Python, JavaScript, and Go code
- Run shell commands
- Create and save files
- Download result files
Basic Information
Authentication
No authentication required.
Support Scope
Terminal Sandbox is only available in AI Hub chat. It is not supported in 3rd-party MCP clients.
Sandbox Features
Working Directory
- The home directory is
/workspace. - Files created in
/workspacepersist during the session. - Files outside
/workspaceare reset after each execution.
Session Management
- An independent sandbox is created for each chat room.
- The sandbox is automatically reset after 10 minutes of inactivity.
- Files and data are preserved while the session is active.
Supported MCP Tools
execute_code
Execute code in an isolated sandbox environment.
Supported Languages:
- Python (3.12)
- JavaScript (Node.js 23.11)
- Go (1.24)
Input Parameters:
code(required): Code to executelanguage(required): Programming language (python,javascript,go)libraries(optional): List of libraries to install (pip for Python, npm for JavaScript)timeout(optional): Execution timeout in seconds (default: 30)
Return Information:
- Execution result (stdout)
- Error messages (stderr)
- Exit code
- Execution time
execute_command
Execute shell commands in an isolated sandbox environment.
Input Parameters:
command(required): Shell command to executetimeout(optional): Execution timeout in seconds (default: 30)
Return Information:
- Execution result (stdout)
- Error messages (stderr)
- Exit code
- Execution time
upload_files
Import files uploaded to AI Hub chat into the sandbox’s /workspace/files directory.
Input Parameters:
file_ids(required): List of file IDs uploaded to AI Hub chat
export_file
Export files or directories created in the sandbox as downloadable URLs.
Input Parameters:
file_path(required): Path to the file or directory to export (e.g.,/workspace/report.csv)
Features:
- Directories are automatically compressed into ZIP files.
- The returned URL is provided in Markdown link format.
- URL is valid for 10 minutes.
Usage Examples
Data Analysis with Python
User Input:
Analyze the following product data with pandas and save it as a CSV file:
- Laptop: price $1200, stock 15 units
- Mouse: price $25, stock 50 units
- Keyboard: price $75, stock 30 units
- Monitor: price $350, stock 20 units
Also calculate the average price and total inventory value.The LLM uses the execute_code tool to generate and execute code similar to the following:
import pandas as pd
# Create data
data = {
'Product': ['Laptop', 'Mouse', 'Keyboard', 'Monitor'],
'Price': [1200, 25, 75, 350],
'Stock': [15, 50, 30, 20]
}
df = pd.DataFrame(data)
# Perform analysis
print(f"Average price: ${df['Price'].mean():.2f}")
print(f"Inventory value: ${(df['Price'] * df['Stock']).sum():,}")
# Save to CSV
df.to_csv('/workspace/products.csv', index=False)
print("\nCSV file created.")Then, the export_file tool provides a download link for the generated CSV file.
JSON Processing with JavaScript
User Input:
Filter users where active is true from the following user data and save as a JSON file:
- Alice (ID: 1, active: true)
- Bob (ID: 2, active: false)
- Charlie (ID: 3, active: true)The LLM uses the execute_code tool to generate and execute code similar to the following:
const fs = require('fs');
// User data
const users = [
{ id: 1, name: 'Alice', active: true },
{ id: 2, name: 'Bob', active: false },
{ id: 3, name: 'Charlie', active: true }
];
// Filter active users only
const activeUsers = users.filter(user => user.active);
// Save to file
fs.writeFileSync(
'/workspace/active_users.json',
JSON.stringify(activeUsers, null, 2)
);
console.log(`${activeUsers.length} active users saved`);Text File Analysis with Shell Commands
User Input:
Create /workspace/server.log file and add the following content:
2025-12-02 10:15:23 INFO Server started
2025-12-02 10:16:45 ERROR Database connection failed
2025-12-02 10:17:12 INFO Request processed
2025-12-02 10:18:33 ERROR Timeout exception
2025-12-02 10:19:01 INFO User logged in
Then extract only the lines containing ERROR and save to errors.txt.The LLM uses the execute_command tool to execute commands similar to the following:
# Create log file
cat > /workspace/server.log << 'EOF'
2025-12-02 10:15:23 INFO Server started
2025-12-02 10:16:45 ERROR Database connection failed
2025-12-02 10:17:12 INFO Request processed
2025-12-02 10:18:33 ERROR Timeout exception
2025-12-02 10:19:01 INFO User logged in
EOF
# Extract lines containing ERROR
grep "ERROR" /workspace/server.log > /workspace/errors.txt
# Check result
cat /workspace/errors.txtUsing Multiple Languages in Combination
User Input:
Calculate project progress rate. 850 out of 1000 tasks are completed.
Save the data as JSON with Python, then calculate completion rate with Go and create a report file.The LLM executes step by step in a manner similar to the following:
Step 1: Save data with Python
import json
data = {'total': 1000, 'completed': 850}
with open('/workspace/data.json', 'w') as f:
json.dump(data, f)
print(f"Data saved: {data}")Step 2: Generate report with Go
package main
import (
"encoding/json"
"fmt"
"os"
)
func main() {
// Read JSON file
data, _ := os.ReadFile("/workspace/data.json")
var result map[string]int
json.Unmarshal(data, &result)
// Calculate completion rate
percentage := float64(result["completed"]) / float64(result["total"]) * 100
report := fmt.Sprintf("Project Progress\nTotal: %d tasks\nCompleted: %d tasks\nCompletion Rate: %.1f%%\n",
result["total"], result["completed"], percentage)
// Save report file
os.WriteFile("/workspace/report.txt", []byte(report), 0644)
fmt.Print(report)
}Precautions
Security
- While the sandbox is isolated, exercise caution when handling sensitive data.
- Do not hardcode API keys or passwords in your code.
Session Management
- The sandbox is reset after 10 minutes of inactivity, deleting all files.
- Download important results using the
export_filetool.
Resource Limitations
- The sandbox uses limited CPU and memory.
- Large-scale data processing or long-running tasks may be restricted.
File Storage Location
- Always save files to the
/workspacedirectory. - Files in other locations may disappear after execution.
Network Restrictions
- External network access is limited to library installation purposes only.
- Python:
pypi.org,files.pythonhosted.org - JavaScript:
registry.npmjs.org,nodejs.org - Go:
proxy.golang.org,sum.golang.org,index.golang.org - API calls, web scraping, and other external service access are not possible.
Library Installation
- Python: Common libraries like pandas, numpy, and requests can be installed
- Some libraries with system dependencies may not be installable (e.g., matplotlib)
- JavaScript: npm packages can be installed, but native modules may be restricted