Menu

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.

Secondary helper
Optional execution layer
Snipara Sandbox is not a Snipara connection surface. Add it only when a workflow needs sandbox, docker, or local code execution beyond Hosted MCP context tools and API / SDK integration.

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-snipara

Configures .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:

PackageFeatures
snipara-sandboxSandbox 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 init
snipara-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

ToolDescription
execute_pythonRun Python code in sandbox, docker, or trusted local sessions
get_repl_contextGet current REPL context variables
set_repl_contextSet a variable in REPL context
clear_repl_contextClear all REPL context
list_sessionsList all active sessions with metadata
destroy_sessionDestroy a session and free resources
snipara_agent_runStart an autonomous agent that iteratively solves a task
snipara_agent_statusCheck the status of an autonomous agent run
snipara_agent_cancelCancel a running autonomous agent

Execution Environments

ModeSecurityStartup TimeBest For
sandboxMedium (RestrictedPython)~0msDefault MCP path, verification, lightweight analysis
dockerHigh (container isolation)~100-500msProduction, untrusted code
localLow-Medium (trusted host execution)~0msTrusted 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 asyncio
from snipara_sandbox import SniparaSandbox
async 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 integration
snipara_api_key = "snp-..."
snipara_project_slug = "your-project"
# Docker settings
docker_image = "python:3.11-slim"
docker_memory = "512m"

Or use environment variables:

export SNIPARA_SANDBOX_MODEL=openai/YOUR_MODEL
export SNIPARA_SANDBOX_ENVIRONMENT=docker
export SNIPARA_API_KEY=snp-...
export SNIPARA_PROJECT_SLUG=my-project

CLI Commands

CommandDescription
snipara-sandbox initCreate snipara-sandbox.toml configuration
snipara-sandbox run "prompt"Run a completion
snipara-sandbox run --env dockerRun with Docker isolation
snipara-sandbox agent "task"Run an autonomous agent
snipara-sandbox logsView execution trajectories
snipara-sandbox visualizeLaunch visualization dashboard
snipara-sandbox mcp-serveStart MCP server
snipara-sandbox doctorCheck setup and dependencies

Safety Limits

LimitDefaultMax
Recursion depth45
Agent iterations1050
Cost limit$2.00$10.00
Timeout30s600s
Memory (Docker)512MBConfigurable

Links

Next Steps