MCP is a protocol that allows AI assistants to interact with external tools and services. The Hopx MCP server provides a standardized way for AI assistants to execute code safely in isolated environments.
Quick Start
The easiest way to get started:-
Install the MCP server:
uvx hopx-mcp - Get your API key from hopx.ai
- Configure your IDE with the MCP server
- Your AI assistant can now execute code safely
Installation
Install the Hopx MCP server usinguvx:
Get Your API Key
Sign up at hopx.ai to get your free API key. You’ll need this to configure the MCP server.Configuration
After installing withuvx hopx-mcp, configure your IDE by adding the MCP server configuration:
- Cursor
- VS Code
- Claude Desktop
- Windsurf
- Other IDEs
Add to
.cursor/mcp.json in your project or workspace:your-api-key-here with your actual API key from hopx.ai.
Usage Examples
Once configured, your AI assistant can execute code directly. Here’s what it looks like:Python Data Analysis
You: “Analyze this sales data: [100, 150, 200, 180, 220]” Claude: Usesexecute_code_isolated() to run:
JavaScript Computation
You: “Calculate fibonacci numbers up to 100” Claude: Executes:Primary Tool: execute_code_isolated()
The recommended way to execute code. Creates a sandbox, runs your code, returns output, and auto-destroys.
Parameters:
code(required): Code to executelanguage(optional):'python','javascript','bash', or'go'(default:'python')timeout(optional): Max execution time in seconds (default: 30, max: 300)env(optional): Environment variables as a dictionarytemplate_name(optional): Template to use (default:'code-interpreter')region(optional): Deployment region (e.g.,'us-east','eu-west')
Advanced: Persistent Sandboxes
For multi-step workflows where you need to maintain state:-
Create a long-lived sandbox:
-
Extract connection details:
-
Run multiple commands:
-
File operations:
-
Clean up when done:
Available Tools
The MCP server exposes 30+ tools for complete control:Sandbox Management
create_sandbox()- Create a new sandboxlist_sandboxes()- List all your sandboxesget_sandbox()- Get sandbox detailsdelete_sandbox()- Terminate a sandboxupdate_sandbox_timeout()- Extend runtimeresume_sandbox()- Resume a paused sandbox
Code Execution
execute_code_isolated()- ⭐ Primary method (one-shot)execute_code()- Execute in existing sandboxexecute_code_rich()- Capture matplotlib plots, DataFramesexecute_code_background()- Long-running tasks (5-30 min)execute_code_async()- Very long tasks with webhooks (30+ min)
File Operations
file_read(),file_write(),file_list()file_exists(),file_remove(),file_mkdir()
Process Management
list_processes()- All system processesexecute_list_processes()- Background executionsexecute_kill_process()- Terminate process
Environment & System
env_set(),env_get(),env_clear()- Manage env varsget_system_metrics()- CPU, memory, disk usagerun_command()- Execute shell commands
Templates
list_templates()- Browse available templatesget_template()- Get template details
Best Practices
Use execute_code_isolated() for One-Shot Tasks
Use execute_code_isolated() for One-Shot Tasks
For quick code execution, use This is perfect for:
execute_code_isolated(). It handles sandbox creation, execution, and cleanup automatically:- Quick data analysis
- Code testing
- Package installation checks
- One-off computations
Use Persistent Sandboxes for Multi-Step Workflows
Use Persistent Sandboxes for Multi-Step Workflows
For workflows requiring multiple operations, create a persistent sandbox:This maintains state between executions and is more efficient for complex workflows.
Handle Errors Gracefully
Handle Errors Gracefully
Always check execution results:
Set Appropriate Timeouts
Set Appropriate Timeouts
Use timeouts to prevent infinite loops or long-running code:
Use Environment Variables for Secrets
Use Environment Variables for Secrets
Pass sensitive data via environment variables:Never hardcode secrets in code strings.
Production Example
Complete MCP server integration example:Troubleshooting
”401 Unauthorized” Error
Cause: API key not set or invalid. Solution:“Template not found” Error
Cause: Invalid template name. Solution: Use the defaultcode-interpreter template or list available templates:
Slow First Execution
Cause: Cold start - container is being created. Why it happens: The first execution needs to:- Create the container (~0.1ms)
- Wait for VM auth init (~3 seconds)
- Execute your code

