execute_ipython_cell
Run Python code in a stateful IPython kernel within a Docker container. Maintain variables, imports, and definitions across executions for iterative workflows. Supports async code with 'await' and sequential executions with shared kernel state.
Instructions
Execute Python code in a stateful IPython kernel within a Docker container.
The kernel maintains state across executions - variables, imports, and definitions
persist between calls. Each execution builds on the previous one, allowing you to
build complex workflows step by step. Use '!pip install package_name' to install
packages as needed.
The kernel has an active asyncio event loop, so use 'await' directly for async
code. DO NOT use asyncio.run() or create new event loops.
Executions are sequential (not concurrent) as they share kernel state. Use the
reset() tool to clear the kernel state and start fresh.
Returns:
str: Output text from execution, or empty string if no output.
Input Schema
Name | Required | Description | Default |
---|---|---|---|
code | Yes | Python code to execute in the IPython kernel | |
timeout | No | Maximum execution time in seconds before the kernel is interrupted |
Input Schema (JSON Schema)
{
"properties": {
"code": {
"description": "Python code to execute in the IPython kernel",
"title": "Code",
"type": "string"
},
"timeout": {
"default": 120,
"description": "Maximum execution time in seconds before the kernel is interrupted",
"title": "Timeout",
"type": "number"
}
},
"required": [
"code"
],
"title": "execute_ipython_cellArguments",
"type": "object"
}