Python Dev Kit Inside Code Interpreter for AI Agents - Jupyter-based code execution with multimodal support
Project description
๐ค py4agent - Python Dev Kit Inside Code Interpreter for AI Agents
A Jupyter-based code execution server with multimodal support designed for AI agents to execute Python code safely and efficiently.
Features
- ๐ Fast and reliable code execution via Jupyter kernels
- ๐จ Multimodal output support (text, plots, tables, images)
- ๐ MCP (Model Context Protocol) server support
- ๐ง Dev Kit Inside Code Interpreter
๐ Quick Start
๐ฆ Installation
pip install py4agent --upgrade
For detailed installation instructions, see INSTALL.md.
โถ๏ธ Running the Code Interpreter Server with Third-Party Jupyter Server
Set up your Jupyter connection parameters:
jupyterlab --no-browser --port=8888 --NotebookApp.token='your-token-here'
Dynamically connect to your Jupyter server and start executing code!
export JUPYTER_HOST="localhost"
export JUPYTER_PORT="8888"
export JUPYTER_TOKEN="your-token-here"
py4agent --host 0.0.0.0 --port 8889 --debug --workers 4
๐ Running the MCP Server with Self-Contains Jupyter Kernel Manager
Just start it directly without needing an external Jupyter server:
py4agent-mcp --host 0.0.0.0 --port 8889 --debug --workers 4
๐ Project Structure
py4agent/
โโโ __init__.py # Package initialization
โโโ __main__.py # Main entry point
โโโ server.py # FastAPI server implementation
โโโ mcp_server.py # MCP server implementation
โโโ injection/ # Code injection utilities
โโโ __main__.py # Injection entry point
โโโ jupyter_parse.py # Jupyter message parsing
โโโ display_mime.py # MIME type display handling
โโโ multimodal.py # Multimodal output handling
โโโ types.py # Type definitions
โโโ blocks/ # Display block implementations
โโโ plotly_json.py # Plotly visualization
โโโ table_json.py # Table display
โโโ search_result.py # Search results
โโโ visual_json.py # Visual display
๐ก API Usage
See the full test examples in test.py.
โก Execute Code
curl -X POST http://localhost:8889/execute \
-H "Content-Type: application/json" \
-d '{
"code": "print(1+1)",
"kernel_id": "your-kernel-id",
"jupyter_host": "localhost",
"jupyter_port": "8888",
"jupyter_token": "your-token",
"session_id": "test",
"timeout": 10
}'
๐ง Create Kernel
curl -X POST http://localhost:8889/jupyter/create \
-H "Content-Type: application/json" \
-d '{
"jupyter_host": "localhost",
"jupyter_port": "8888",
"jupyter_token": "your-token"
}'
๐ ๏ธ Development
๐ Dependencies Management
The dependencies are organized into:
- Core: Web framework and HTTP clients (FastAPI, uvicorn, httpx)
- Scientific Computing: NumPy, Pandas, SciPy, scikit-learn, etc.
- Visualization: Plotly, Matplotlib, Seaborn, etc.
- Database: SQLAlchemy, Redis, MongoDB, etc.
- Web Scraping: BeautifulSoup, Selenium, Playwright
- Dev: Testing and linting tools (pytest, black, ruff, mypy)
๐งช Testing
# Install dev dependencies
pip install -e ".[dev]"
# Run tests
pytest
# With coverage
pytest --cov=py4agent
โจ Code Quality
# Format code
black py4agent/
# Lint code
ruff check py4agent/
# Type checking
mypy py4agent/
๐ License
This project is licensed under the MIT License - see the LICENSE file for details.
๐ Acknowledgments
๐ค Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
๐ง Contact
- GitHub: @LinXueyuanStdio
- Issues: GitHub Issues
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file py4agent-0.0.3.tar.gz.
File metadata
- Download URL: py4agent-0.0.3.tar.gz
- Upload date:
- Size: 41.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.2.1 CPython/3.11.5 Darwin/25.2.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c684684ba7aa0175dfc5758c192c41017043c5eadb8eab283abd06cbfec3c859
|
|
| MD5 |
790e609ef16c7de77acf5e7845f8a324
|
|
| BLAKE2b-256 |
de73fab9fda81989f09270242bc79b2dc6104cd5666275cb66ee17fcc718020b
|
File details
Details for the file py4agent-0.0.3-py3-none-any.whl.
File metadata
- Download URL: py4agent-0.0.3-py3-none-any.whl
- Upload date:
- Size: 46.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.2.1 CPython/3.11.5 Darwin/25.2.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
92b77c9ba34fb9b926c4aebccab968bfb7197b07b7a4d5eafe0502d76ec2839d
|
|
| MD5 |
59411582d27f170ea2079a32a08d31d4
|
|
| BLAKE2b-256 |
61478210ccf734a77033138ab83af06e5d83dd62796668ec29f466d6ae52b295
|