BentoRun Python MCP
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
š± BentoRun Python MCP
A Model Context Protocol (MCP) server that provides a secure isolated environment for executing Python code.
Overview
BentoRun Python MCP allows AI Agents to execute Python code safely inside lightweight sandboxes in Google Cloud Run. It uses a rigorous sandboxing approach to ensure that executed code cannot interfere with the host system or the MCP server itself, while still providing necessary access to the internet and specific libraries.
You can use it for securely executing Python code generated by any AI Agent that supports Model Context Protocol, such as Gemini CLI, Claude Code, or your own agent built with Agent Development Kit (ADK).
Each MCP session is isolated in a separate sandbox.

Related MCP server: Code Executor MCP Server
Sandbox with gVisor
We use gVisor, an application kernel for containers, to create a secure environment for every code execution. It provides an additional layer of isolation between running applications and the host operating system.
gVisor was built by Google to provide strong isolation for multi-tenant workloads. It implements a substantial portion of the Linux system surface, allowing untrusted code to run safely without direct access to the host kernel.
gVisor uses the following features to create a secure isolated execution environment:
1. Application Kernel (The "Sentry")
gVisor intercepts application system calls and handles them in a user-space kernel called the Sentry. The Sentry implements the Linux kernel API, but is written in Go and memory-safe. This means:
Attack Surface Reduction: The application doesn't talk directly to the host kernel.
Defense in Depth: Even if the application compromises the Sentry, it is still isolated from the host.
2. Filesystem Proxy (The "Gofer")
File operations are proxied through a separate process called the Gofer. This ensures that the application only accesses files it is explicitly allowed to see, enforcing strict isolation boundaries.
3. OCI Compatibility
gVisor integrates seamlessly with OCI (Open Container Initiative) runtimes. We use runsc (the gVisor runtime) to spin up lightweight, ephemeral sandboxes for each execution, managing resources via standard container controls.
Sandbox Environment Template
We use a sandbox environment template to ensure that executed code runs in a consistent and secure environment. The template is defined in env_requirements.txt and includes a list of packages that are installed in the sandbox environment.
If you expect your code to often require certain dependencies, customize the sandbox environment by modifying env_requirements.txt file
and by adding additional dependencies to the Dockerfile.
Depending on complexity of the code, you may also need to extend the list of system mounts by modifying KNOWN_SYSTEM_MOUNTS list in src/sandbox.py file.
MCP Server Tools
BentoRun MCP exposes one tool to AI Agents: execute_python
This tool executes Python code in a sandboxed environment. Its parameters are:
code: The Python code to execute.
packages: A list of additional PyPI packages to install in the sandbox environment before executing the code.
env_variables: A dictionary of environment variables to set in the sandbox environment.
For code using Google Cloud libraries, you can pass credentials in 2 ways:
By passing
CLOUDSDK_AUTH_ACCESS_TOKENenvironment variable with the access token fromgcloud auth print-access-tokenCLI command.By passing
GOOGLE_APPLICATION_CREDENTIALSenvironment variable with the content of the service account key json file.
The tool's instructions explicitly state that any output files should be written to output subdirectory.
Such files are processed and returned from execute_python tool as Embedded Resources or Images. See examples/adk/adk_sandbox/agent.py for example of how to use it.
Those files and installed packages are preserved between executions within the same session. Sessions are automatically cleaned up after 10 minutes of inactivity.
Key Isolation Features
Filesystem Isolation:
The sandbox runs with a read-only view of the system's root filesystem.
Only specific directories necessary for python execution are mounted (
/bin,/lib,/usr, etc.).A temporary workspace is bind-mounted as the only writable location.
This prevents the executed code from modifying system files, installing persistent malware, or accessing the MCP server's sensitive files.
Resource Limits (Enforced via OCI/cgroups):
Memory: Limited to 512MB by default via
runscconfiguration to prevent OOM attacks or leaks.CPU Time: Execution time is strictly limited (default 60s) via
RLIMIT_CPUto prevent infinite loops from locking up resources.
Network Access:
The sandbox can share the network namespace with the host container (configurable).
This allows the code to fetch data from the internet (e.g., pip install packages, make API calls) which is often required for useful tasks.
Security Note: Since we are running inside a container (Cloud Run) that already has its own network policies, this is an acceptable trade-off. In Cloud Run, we make sure to use a "permissionless" Service Account, so the code cannot access any Google Cloud resources unless given an explicit authentication token as part of the code execution request.
User Isolation:
Code runs as a dedicated non-privileged user (
sandboxuser, uid:1000) inside the sandbox which makes it even harder to escape the sandbox.
Each MCP session is executed in a separate, ephemeral gVisor sandbox.
Code Execution Flow
Session Initialization: When a client connects, a new session is created.
Package Installation: If packages are requested, they are installed in the sandbox environment.
Code Execution: The code is executed in the sandbox environment.
Output: The output is returned to the client as a JSON object with
stdoutandstderrfields that contain respective outputs from the execution.
Deploying and Running the BentoRun MCP Server
You need a Google Cloud Project with billing enabled to deploy the MCP server.
Make sure you have
gcloudCLI installed and configured.Authenticate with Google Cloud:
gcloud auth loginCopy
env.templateto.env, and setGOOGLE_CLOUD_PROJECTto your Google Cloud Project Id.Deploy the MCP server:
./deploy.shThe script will deploy the MCP server to Cloud Run as mcp-bentorun-python service and provide the URL.
Examples
Our MCP Server in Cloud Run is protected with IAM-based authentication. Both examples below demonstrate how to authenticate to the MCP server in Cloud Run. When the agent's code runs in Google Cloud, it automatically gets credentials using Metadata Service. When running locally, you need to authenticate with
gcloud auth login. In both cases the calling user needs to have Cloud Run Invoker (roles/run.invoker) role assigned.
Simple Client
Edit
examples/mcp_client/simple_client.pyto change theSERVER_URLto your deployed service address.Run the client:
python3 examples/mcp_client/simple_client.pyADK Agent Example
Create
.envinexamples/adk/as a copy of.env.exampleSet environment variables in
.envfile:GOOGLE_GENAI_USE_VERTEXAI- set to "true" to use Vertex AI.GOOGLE_CLOUD_PROJECT- set to your Google Cloud project Id.GOOGLE_CLOUD_LOCATION- Gemini API endpoint location. Keep itglobalif you don't have specific requirements.BENTORUN_MCP_URL- set to your BentoRun MCP URL (e.g.https://mcp-bentorun-python-PROJECT_NUMBER.REGION.run.app/mcp)GEMINI_API_KEY- if you prefer using Gemini API key, setGOOGLE_GENAI_USE_VERTEXAIto "false" andGEMINI_API_KEYto your Gemini API key.
Install ADK requirements:
pip install -r examples/adk/adk_sandbox/requirements.txtRun the agent:
adk web examples/adkOpen http://127.0.0.1:8000 to interact with the agent.

Using BentoRun MCP with Gemini CLI or Claude Code
Our MCP Server in Cloud Run is protected with IAM-based authentication. To be able to use the server, you need:
Have logged in to gcloud CLI with
gcloud auth login.Have Cloud Run Invoker (
roles/run.invoker) role assigned to your user (if you deployed the server yourself, most likely you already have it).Pass your identity token to the MCP server. You can get it by running
gcloud auth print-identity-token -q.
To automate the last step, we use mcp-remote MCP proxy tool with a combination of shell commands.
Add MCP Server to Gemini CLI or Claude Code:
Manually in
settings.jsonfor Gemini CLI or.mcp.jsonfor Claude Code:{ "mcpServers": { "bento-run-mcp": { "env": { "BENTORUN_MCP": "MCP_SERVER_URL" }, "command": "/bin/sh", "args": [ "-c", "ID_TOKEN=$(gcloud auth print-identity-token -q) && npx -y mcp-remote --header \"Authorization: Bearer $ID_TOKEN\" $BENTORUN_MCP" ] } } }or use CLI to add it:
For Gemini CLI:
gemini mcp add \ -e BENTORUN_MCP="MCP_SERVER_URL" \ bento-run-mcp \ /bin/sh -- -c 'ID_TOKEN=$(gcloud auth print-identity-token -q) && npx -y mcp-remote --header "Authorization: Bearer $ID_TOKEN" $BENTORUN_MCP'For Claude Code:
claude mcp add bento-run-mcp \ --scope user \ --env BENTORUN_MCP="MCP_SERVER_URL" \ -- /bin/sh -c 'ID_TOKEN=$(gcloud auth print-identity-token -q) && npx -y mcp-remote --header "Authorization: Bearer $ID_TOKEN" $BENTORUN_MCP'
Replace
MCP_SERVER_URLwith your BentoRun MCP URL (e.g.https://mcp-bentorun-python-PROJECT_NUMBER.REGION.run.app/mcp)
Disclaimer
This is not an officially supported Google product. This project is not eligible for the Google Open Source Software Vulnerability Rewards Program.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelogā¦
This server cannot be deployed
Maintenance
Related MCP Connectors
Build Apps and run code in 30 languages ā sandboxed, with persistent sessions for agent loops.
Run Python code in a secure sandbox without local setup. Declare inline dependencies and execute sā¦
Execution platform for AI agents on Firecracker microVMs in the EU. Interactive Linux sandboxes with root, templates for Python, Node.js, Go, Rust and a headless browser, public HTTPS URLs. Background jobs that outlive the connection, batches of up to 1,000 jobs with dependencies, hard cost caps reserved up front, execution receipts with SHA-256, log digests that fit the context. IPv4, dual-stack or IPv6-only with its own public address, allowlists or no network. WASI runtime for small tasks. Idle sandboxes sleep and keep their files. Also REST API, Python SDK and LangChain.
Beta code sandbox for agents. Run Python or JavaScript with no network and a 30 s timeout.
Related MCP Servers
- AlicenseNot gradedqualityNot gradedmaintenanceProvides AI coding agents with a secure, sandboxed environment for executing coding tasks including file operations, command execution, and testing. Features session management, policy enforcement, and Docker-based sandboxing for safe code execution and development workflows.MIT
- AlicenseNot gradedqualityCmaintenanceProvides sandboxed code execution for AI agents with support for Python, JavaScript, and shell commands. Includes comprehensive safety features like destructive pattern blocking, timeout protection, and restricted file access for secure production use.28 PyPIMIT
- AlicenseNot gradedqualityBmaintenanceEnables LLMs to execute Python code securely in a sandboxed environment. Supports configurable restrictions like no network access and returns results including files.1MIT
- AlicenseNot gradedqualityDmaintenanceEnables AI agents to execute arbitrary Python code securely in a sandboxed environment with resource limits and security constraints via MCP protocol.MIT