Snipara Sandbox Integration
Snipara Sandbox is a Python execution layer that integrates with Snipara for context-aware code generation, explicitly started agents, and multi-step task execution across sandbox, docker, and trusted local backends. Sandbox jobs start only from an explicit user or workflow command; Snipara does not silently launch execution.
When to Use Snipara Sandbox
Use Snipara Sandbox for complex multi-step tasks that require code execution, iteration, or multi-file changes. For simple documentation Q&A, use Snipara MCP tools directly (faster and cheaper).
Installation
Fastest Way: NPX Setup
Scaffold Snipara Sandbox plus Snipara config with one command:
npx create-sniparaConfigures .mcp.json, prompts for execution environment (sandbox/docker/local), and sets up LLM provider API keys. Full guide →
Or install manually:
pip install snipara-sandbox[all]The current PyPI package is snipara-sandbox. Legacy command aliases remain available for existing installations.
Or install specific features:
| Package | Features |
|---|---|
snipara-sandbox | Sandbox core with local REPL |
snipara-sandbox[docker] | Docker isolation (recommended for production) |
snipara-sandbox[mcp] | MCP server for Claude Desktop/Code |
snipara-sandbox[snipara] | Snipara Project Intelligence retrieval |
snipara-sandbox[visualizer] | Trajectory visualization dashboard |
snipara-sandbox[all] | All features |
Quick Start
snipara-sandbox initsnipara-sandbox run "Summarize the authentication flow"snipara-sandbox run --env docker "Parse and analyze logs"snipara-sandbox agent "Analyze all CSV files and generate a report"Claude Code / Claude Desktop Setup
Add Snipara Sandbox as an MCP server to get Python execution in Claude. No API keys required for Snipara Sandbox itself.
Step 1: Install with MCP support
pip install snipara-sandbox[mcp]Step 2: Add to your MCP configuration
Add to ~/.mcp.json (Claude Code) or ~/.claude/claude_desktop_config.json (Claude Desktop):
{ "mcpServers": { "snipara-sandbox": { "command": "snipara-sandbox", "args": ["mcp-serve"] } }}Step 3: Add Snipara for context (optional but recommended)
Combine Snipara Sandbox with Snipara for context-aware code execution:
{ "mcpServers": { "snipara-sandbox": { "command": "snipara-sandbox", "args": ["mcp-serve"] }, "snipara": { "type": "http", "url": "https://api.snipara.com/mcp/YOUR_PROJECT", "headers": { "X-API-Key": "snp-YOUR-API-KEY" } } }}Available MCP Tools
| Tool | Description |
|---|---|
execute_python | Run Python code in sandbox, docker, or trusted local sessions |
get_repl_context | Get current REPL context variables |
set_repl_context | Set a variable in REPL context |
clear_repl_context | Clear all REPL context |
list_sessions | List all active sessions with metadata |
destroy_session | Destroy a session and free resources |
snipara_agent_run | Start an autonomous agent that iteratively solves a task |
snipara_agent_status | Check the status of an autonomous agent run |
snipara_agent_cancel | Cancel a running autonomous agent |
Execution Environments
| Mode | Security | Startup Time | Best For |
|---|---|---|---|
sandbox | Medium (RestrictedPython) | ~0ms | Default MCP path, verification, lightweight analysis |
docker | High (container isolation) | ~100-500ms | Production, untrusted code |
local | Low-Medium (trusted host execution) | ~0ms | Trusted development and local-only tooling |
The standalone Python package can expose other runtime backends such as WebAssembly. The MCP execute_python tool itself selects sandbox, docker, or trusted local execution.
Security Recommendation
Use docker for production and untrusted code. sandbox is the default RestrictedPython path, and local is only for trusted development workflows.
When to Use Snipara Sandbox vs Direct MCP
Use Direct Snipara MCP Tools For:
- Documentation Q&A- "What's the tech stack?"
- Code lookup- "Where is auth handled?"
- Simple retrieval- "List all API endpoints"
Use Snipara Sandbox For:
- Multi-step code tasks- "Implement OAuth integration"
- Complex reasoning- "Refactor auth to use JWT"
- Iterative refinement- "Optimize this function"
- Multi-file changes- "Add validation to all endpoints"
Python API
import asynciofrom snipara_sandbox import SniparaSandboxasync def main(): sandbox = SniparaSandbox( model="openai/YOUR_MODEL", environment="docker", max_depth=4, ) result = await sandbox.completion("Analyze and fix the auth bug") print(result.response)asyncio.run(main())Configuration
Create snipara-sandbox.toml in your project:
[snipara_sandbox]backend = "litellm"model = "openai/YOUR_MODEL"environment = "docker"max_depth = 4# Snipara integrationsnipara_api_key = "snp-..."snipara_project_slug = "your-project"# Docker settingsdocker_image = "python:3.11-slim"docker_memory = "512m"Or use environment variables:
export SNIPARA_SANDBOX_MODEL=openai/YOUR_MODELexport SNIPARA_SANDBOX_ENVIRONMENT=dockerexport SNIPARA_API_KEY=snp-...export SNIPARA_PROJECT_SLUG=my-projectCLI Commands
| Command | Description |
|---|---|
snipara-sandbox init | Create snipara-sandbox.toml configuration |
snipara-sandbox run "prompt" | Run a completion |
snipara-sandbox run --env docker | Run with Docker isolation |
snipara-sandbox agent "task" | Run an autonomous agent |
snipara-sandbox logs | View execution trajectories |
snipara-sandbox visualize | Launch visualization dashboard |
snipara-sandbox mcp-serve | Start MCP server |
snipara-sandbox doctor | Check setup and dependencies |
Safety Limits
| Limit | Default | Max |
|---|---|---|
| Recursion depth | 4 | 5 |
| Agent iterations | 10 | 50 |
| Cost limit | $2.00 | $10.00 |
| Timeout | 30s | 600s |
| Memory (Docker) | 512MB | Configurable |