An open API service indexing awesome lists of open source software.

https://github.com/gradion-ai/ipybox

A lightweight and secure Python code execution sandbox based on IPython and Docker
https://github.com/gradion-ai/ipybox

code-execution code-interpreter code-sandbox mcp mcp-client mcp-server python

Last synced: about 1 month ago
JSON representation

A lightweight and secure Python code execution sandbox based on IPython and Docker

Awesome Lists containing this project

README

          

# ipybox

mcp-name: io.github.gradion-ai/ipybox


Website
PyPI - Version
GitHub Release
GitHub Actions Workflow Status
GitHub License
PyPI - Python Version

`ipybox` is a lightweight and secure Python code execution sandbox based on [IPython](https://ipython.org/) and [Docker](https://www.docker.com/). You can run it locally on your computer or remotely in an environment of your choice. `ipybox` is designed for AI agents that need to execute code safely e.g. for data analytics use cases or executing code actions like in [`freeact`](https://github.com/gradion-ai/freeact/) agents.


ipybox MCP server


logo

## Features

- Secure code execution inside Docker containers
- [Restrict network access](https://gradion-ai.github.io/ipybox/examples/#restrict-network-access) with a configurable firewall
- Stateful code execution with IPython kernels
- Stream code execution output as it is generated
- Install Python packages at build time or runtime
- Return plots generated with visualization libraries
- Exposes an [MCP server](https://gradion-ai.github.io/ipybox/mcp-server/) interface for AI agent integration
- [Invocation of MCP servers](https://gradion-ai.github.io/ipybox/mcp-client/) via generated client code
- Flexible deployment options, local or remote
- `asyncio` API for managing the execution environment

## Documentation

- [User Guide](https://gradion-ai.github.io/ipybox/)
- [API Docs](https://gradion-ai.github.io/ipybox/api/execution_container/)

## MCP server

`ipybox` can be installed as [MCP server](https://gradion-ai.github.io/ipybox/mcp-server/).

```json
{
"mcpServers": {
"ipybox": {
"command": "uvx",
"args": ["ipybox", "mcp"]
}
}
}
```

## Python example

Install `ipybox` Python package:

```bash
pip install ipybox
```

Execute code in an `ipybox` container:

```python
import asyncio
from ipybox import ExecutionClient, ExecutionContainer

async def main():
async with ExecutionContainer(tag="ghcr.io/gradion-ai/ipybox") as container:
async with ExecutionClient(port=container.executor_port) as client:
result = await client.execute("print('Hello, world!')")
print(f"Output: {result.text}")

if __name__ == "__main__":
asyncio.run(main())
```