Tool Specification: mshtools-ipython
Overview
Interactive Python execution environment providing Jupyter Notebook-style computation, data analysis, and visualization capabilities. Supports matplotlib charts, Pillow/OpenCV image processing, and persistent variable state across executions.
JSON Schema
{
"type": "object",
"properties": {
"code": {
"type": "string",
"description": "Python code to run in the IPython environment"
},
"restart": {
"type": "boolean",
"default": false,
"description": "Whether to restart the IPython environment (resets all variables and imports)"
}
},
"required": ["code"]
}
Streaming Mechanism
- Transport: WebSocket-like persistent connection to Jupyter kernel
- Execution Model: REPL (Read-Eval-Print Loop) with state persistence
- Output Streams:
- STDOUT/STDERR text output
- Display output (matplotlib figures auto-rendered)
- Error tracebacks with full exception details
- State Persistence: Variables and imports persist across executions within same session
- Kernel Management: Control plane manages kernel lifecycle via FastAPI (port 8888)
Integration Architecture
Container Infrastructure
Layer 1: Control Plane (kernel_server.py:8888) - FastAPI lifecycle management
↓
Layer 2: Compute Engine (jupyter_kernel.py) - IPython kernel via ZeroMQ
↓
Layer 3: Execution Environment - Python 3.x with PyTorch 2.8.0, CUDA 12.8
Execution Flow
- Code Submission: Model sends code block via tool invocation
- Kernel Routing: Control plane routes to active IPython kernel (PID 300-400)
- Execution: ZeroMQ sockets execute code in sandboxed environment
- Result Capture: Output captured from stdio and display hooks
- State Update: Global namespace updated with new variables
- Response Streaming: Results returned with text/image data
External Dependencies
- Pre-installed Packages: PyTorch 2.8.0, NumPy, pandas, matplotlib, Pillow, OpenCV, SQLite
- Network Access: BLOCKED (containerized - no outbound requests)
- File System:
/mnt/kimi/upload (read-only user files)
/mnt/kimi/output (write deliverables)
/dev/shm (shared memory for inter-process)
Resource Constraints
- Memory: 4GB RAM (CPU-only)
- Storage: 0MB free (containerized, volatile)
- Timeout: 30s execution timeout per call
- Step Budget: Counts as 1 tool call against 10-step (Base) or 200-300 step (OK Computer) limit
Special Capabilities
Image Processing
- Matplotlib: Automatic figure display (no plt.show() needed)
- Pillow: Image loading, processing, filtering, format conversion
- OpenCV: Edge detection, color space conversion, morphological operations
Shell Integration
- Bang Commands:
!ls -la, !pip install (though packages don't persist across restarts)
- Bash Chaining: Combine multiple shell commands with
&&, ;, ||
Data Analysis
- pandas: DataFrame processing, CSV/Excel I/O
- PyTorch: Tensor operations, model inference (no training - no GPU persistence)
- SQLite: In-memory and file-based database operations
Usage Patterns
When to Use
- Numerical computation and mathematical operations
- Data processing of user-uploaded files (CSV/Excel/JSON)
- Chart generation (matplotlib)
- Image manipulation
- Complex logic requiring iterative computation
Restrictions
- Network Blocked: urllib, requests, wget will fail
- No Package Persistence: pip install works but resets on kernel restart
- File Size Limits: Text >10000 chars truncated, images auto-compressed
1---2name: tool-specification-mshtools-ipython3description: Interactive Python execution environment providing Jupyter Notebook-style computation, data analysis, and visualization capabilities.4---5# Tool Specification: mshtools-ipython67## Overview8Interactive Python execution environment providing Jupyter Notebook-style computation, data analysis, and visualization capabilities. Supports matplotlib charts, Pillow/OpenCV image processing, and persistent variable state across executions.910## JSON Schema11```json12{13 "type": "object",14 "properties": {15 "code": {16 "type": "string",17 "description": "Python code to run in the IPython environment"18 },19 "restart": {20 "type": "boolean",21 "default": false,22 "description": "Whether to restart the IPython environment (resets all variables and imports)"23 }24 },25 "required": ["code"]26}27```2829## Streaming Mechanism30- **Transport**: WebSocket-like persistent connection to Jupyter kernel31- **Execution Model**: REPL (Read-Eval-Print Loop) with state persistence32- **Output Streams**: 33 - STDOUT/STDERR text output34 - Display output (matplotlib figures auto-rendered)35 - Error tracebacks with full exception details36- **State Persistence**: Variables and imports persist across executions within same session37- **Kernel Management**: Control plane manages kernel lifecycle via FastAPI (port 8888)3839## Integration Architecture4041### Container Infrastructure42```43Layer 1: Control Plane (kernel_server.py:8888) - FastAPI lifecycle management44 ↓45Layer 2: Compute Engine (jupyter_kernel.py) - IPython kernel via ZeroMQ46 ↓47Layer 3: Execution Environment - Python 3.x with PyTorch 2.8.0, CUDA 12.848```4950### Execution Flow511. **Code Submission**: Model sends code block via tool invocation522. **Kernel Routing**: Control plane routes to active IPython kernel (PID 300-400)533. **Execution**: ZeroMQ sockets execute code in sandboxed environment544. **Result Capture**: Output captured from stdio and display hooks555. **State Update**: Global namespace updated with new variables566. **Response Streaming**: Results returned with text/image data5758### External Dependencies59- **Pre-installed Packages**: PyTorch 2.8.0, NumPy, pandas, matplotlib, Pillow, OpenCV, SQLite60- **Network Access**: BLOCKED (containerized - no outbound requests)61- **File System**: 62 - `/mnt/kimi/upload` (read-only user files)63 - `/mnt/kimi/output` (write deliverables)64 - `/dev/shm` (shared memory for inter-process)6566### Resource Constraints67- **Memory**: 4GB RAM (CPU-only)68- **Storage**: 0MB free (containerized, volatile)69- **Timeout**: 30s execution timeout per call70- **Step Budget**: Counts as 1 tool call against 10-step (Base) or 200-300 step (OK Computer) limit7172## Special Capabilities7374### Image Processing75- **Matplotlib**: Automatic figure display (no plt.show() needed)76- **Pillow**: Image loading, processing, filtering, format conversion77- **OpenCV**: Edge detection, color space conversion, morphological operations7879### Shell Integration80- **Bang Commands**: `!ls -la`, `!pip install` (though packages don't persist across restarts)81- **Bash Chaining**: Combine multiple shell commands with `&&`, `;`, `||`8283### Data Analysis84- **pandas**: DataFrame processing, CSV/Excel I/O85- **PyTorch**: Tensor operations, model inference (no training - no GPU persistence)86- **SQLite**: In-memory and file-based database operations8788## Usage Patterns8990### When to Use91- Numerical computation and mathematical operations92- Data processing of user-uploaded files (CSV/Excel/JSON)93- Chart generation (matplotlib)94- Image manipulation95- Complex logic requiring iterative computation9697### Restrictions98- **Network Blocked**: urllib, requests, wget will fail99- **No Package Persistence**: pip install works but resets on kernel restart100- **File Size Limits**: Text >10000 chars truncated, images auto-compressed