Appearance
Code Runner
Execute Python and JavaScript code instantly in secure WebAssembly sandboxes with millisecond response times.
Overview
Code Runner is a built-in capability that provides AI agents with instant code execution through WebAssembly isolation. When enabled on your MCP Gateway, agents can run Python and JavaScript code in fresh sandboxes with complete memory isolation, delivering both security and performance.
Key Features
- Instant Execution: Under 10ms instantiation overhead
- Complete Isolation: Fresh WASM instance for every request
- Standard Libraries: Python standard library and modern JavaScript (ES6+) included
- Memory Safety: 128MB isolated memory per execution
- No State Persistence: Clean environment every run
How to Enable
- Navigate to your MCP Gateway settings
- Locate Code Runner in the Built-in Capabilities section
- Toggle the capability ON
- Save your configuration
Once enabled, any AI agent connected to your gateway can execute code through the MCP protocol.
Supported Languages
Python
- Version: Python 3.11
- Libraries: Core standard library modules (json, math, datetime, re, etc.)
- Memory: 128MB heap
- CPU Time: Max 100ms
- Execution Time: 30 second timeout
JavaScript
- Version: Modern ES6+
- Runtime: QuickJS in WASM
- Features: Arrow functions, async/await, destructuring, spread operators, template literals
- Libraries: Core standard library (no DOM/Browser APIs)
- Memory: 128MB heap
- CPU Time: Max 100ms
- Execution Time: 30 second timeout
What AI Agents Can Do
Data Transformations
- Parse and transform JSON data structures
- Convert between different data formats
- Aggregate and summarize information
- Clean and normalize data
Mathematical Calculations
- Perform statistical analysis
- Calculate compound interest and financial metrics
- Run scientific computations
- Generate mathematical models
String Processing
- Analyze text content
- Extract patterns using regular expressions
- Transform and format text
- Generate reports from templates
Algorithm Implementation
- Sort and filter data
- Implement custom business logic
- Create data validation rules
- Generate dynamic content
Capability Behavior
Performance Characteristics
Metric | Value | Notes |
---|---|---|
Instantiation | <10ms | Sandbox creation overhead |
Memory Limit | 128MB | Per execution |
CPU Time | Max 100ms | Maximum CPU time |
Timeout | 30 seconds | Maximum execution time |
Code Size | 10KB | Maximum code length |
Output Limit | 1MB | Maximum output size |
Concurrency | Unlimited | Each in isolated sandbox |
Automatic Features
- Fresh sandbox for every execution
- Automatic memory cleanup
- Resource limit enforcement
- Error isolation and handling
Security Enforcement
- Complete memory isolation between executions
- No access to host system
- No network capabilities
- No file system access
- Resource limits strictly enforced
Limitations
No External Libraries
Code Runner includes only standard libraries. For packages like numpy, pandas, requests, or machine learning frameworks, use Virtual Machine instead.
No File System
- No file read/write operations
- No persistent storage
- Use Files capability for file operations
No Network Access
- No HTTP requests
- No database connections
- Use HTTP Client capability for API calls
No State Persistence
- Each execution starts fresh
- No global variables persist
- No session management
When to Use Code Runner vs Virtual Machine
Use Code Runner for:
- Quick calculations (< 1 second)
- Data transformations
- String processing
- Template rendering
- JSON manipulation
- Standard library operations
Use Virtual Machine for:
- Data science with pandas/numpy
- Machine learning workflows
- Web scraping
- File processing
- Long-running computations
- External package dependencies
Typical Applications
Financial Calculations
AI agents use Code Runner to perform quick financial calculations like compound interest, loan amortization, or currency conversions using standard mathematical operations.
Data Format Conversion
Agents transform data between formats such as CSV to JSON, restructure nested objects, or aggregate data from multiple sources into unified formats.
Text Analysis
Agents analyze text for patterns, extract information using regular expressions, calculate statistics about content, or generate formatted reports.
Business Logic Implementation
Agents implement custom validation rules, calculate business metrics, or apply complex conditional logic to data processing tasks.
Pricing
Code Runner is included with standard MCP Gateway usage:
- No per-execution charges
- No time-based billing
- Counts as single gateway request
Next Steps
Related Capabilities
- Virtual Machine - For complex processing with external packages
- Files - For file operations
- HTTP Client - For API calls and web requests
Platform Features
- All Capabilities - Explore other built-in tools
- MCP Gateway - Configure your gateway
- Usage & Limits - Understand platform constraints