# Capsule

> Run untrusted Python and JavaScript code in isolated WebAssembly sandboxes

Source: https://talira.ai/catalog/capsule-qaf2w9hz
Every listing: https://talira.ai/catalog.md

- Kind: Open source
- Types: Library, Command-line tool, MCP server
- Categories: [ai / agents / sandboxing](https://talira.ai/categories/ai/agents/sandboxing), [ai / mcp / servers](https://talira.ai/categories/ai/mcp/servers), [security / sandboxing](https://talira.ai/categories/security/sandboxing)
- Platforms: macos, windows, linux, cli[^3]
- Licence: Apache-2.0[^1]
- Pricing: Free and open source[^1]
- Free tier: yes[^1]
- Self-hostable: yes[^1]
- MCP server: yes[^2]
- Supports: [MCP](https://talira.ai/standards/mcp.md)[^2]

Capsule is an open source runtime, written in Rust, that runs untrusted code such as AI agents' tasks inside WebAssembly sandboxes. You mark Python functions with a @task decorator or wrap TypeScript and JavaScript functions with task(), and each task runs in its own sandbox with CPU limits through Wasm fuel metering, a memory cap, a timeout and automatic retries, returning a JSON envelope with the result and execution metrics. Tasks have no network or file access unless you allow hosts and directories (read-only or read-write). Run tasks with the capsule CLI or from your own code with run(), or give an agent the Capsule MCP server, whose execute_python and execute_javascript tools run code in a fresh sandbox each time. It's Apache-2.0 licensed and ships on PyPI as capsule-run and on npm as @capsule-run/cli, @capsule-run/sdk and @capsule-run/mcp-server.

## Links

- GitHub: https://github.com/capsulerun/runtime

## Problems it solves

- run code an AI agent wrote without risking my machine
- sandbox untrusted Python code with CPU, memory and time limits
- let my agent execute Python or JavaScript safely through MCP
- a lightweight code sandbox without Docker or VMs
- isolate each agent task so a failure doesn't take down the rest
- block network and file access for untrusted code except an allowlist
- run user-submitted JavaScript in a WebAssembly sandbox
- a code interpreter tool for an LLM agent that runs locally

## Features

- @task decorator for Python and task() wrapper for TypeScript/JavaScript
- a WebAssembly sandbox per task
- CPU limits through Wasm fuel (LOW, MEDIUM, HIGH or custom)
- memory limits, timeouts and automatic retries
- JSON result envelope with duration, retries, fuel and RAM used
- outbound HTTP only to allowed hosts
- file access only to allowed directories, read-only or read-write
- capsule run CLI
- run() to execute sandboxed tasks from host code
- MCP server with execute_python and execute_javascript tools
- Python and TypeScript adapters

## Limitations

- Python packages with C extensions need a wasm32-wasi wheel, so numpy and pandas don't work inside the sandbox[^1]
- Each MCP execution starts from a clean sandbox with no state shared between calls[^2]
- Standard Python networking libraries don't work inside the MCP server's sandbox[^2]

## Capabilities

- Has a command line tool: plan not known
- Has an MCP server: plan not known
- Has official SDKs: plan not known

## Trust

Overall: 0.26 out of 1.
Signals: backing 0.00, extensibility 0.40.

- has an MCP server for agents

Warnings:

- GitHub activity not fetched yet

## Alternatives

- [Vercel Sandbox](https://talira.ai/catalog/vercel-sandbox-20g2mqv2.md): Run agent workloads in isolated sandboxes
- [E2B](https://talira.ai/catalog/e2b-zxrwgrzj.md): The AI agent cloud: an isolated sandbox machine for every agent session
- [Modal](https://talira.ai/catalog/modal-ye3xg914.md): Pay per second for GPUs and CPUs
- [Wasmer](https://talira.ai/catalog/wasmer-n2vrj7qv.md): Fast and lightweight sandboxes for your apps and AI agents
- [Sandscale](https://talira.ai/catalog/sandscale-pzzkmqdt.md): Isolated cloud sandboxes, workspaces and build machines for AI agents
- [CodeSandbox](https://talira.ai/catalog/codesandbox-zz8t1whn.md): Instant cloud development environments and sandboxes built for scale

## Sources

[^1]: https://github.com/capsulerun/runtime (checked 22 Nov 2026)
[^2]: https://github.com/capsulerun/runtime/tree/main/integrations/mcp-server (checked 22 Nov 2026)
[^3]: https://pypi.org/project/capsule-run/#files (checked 22 Nov 2026)
