Skip to main content

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 Server

py4agent --host 0.0.0.0 --port 8889 --debug --workers 4

๐Ÿ”Œ Running the MCP 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.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

๐Ÿ“ง Contact

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

py4agent-0.0.2.tar.gz (39.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

py4agent-0.0.2-py3-none-any.whl (44.4 kB view details)

Uploaded Python 3

File details

Details for the file py4agent-0.0.2.tar.gz.

File metadata

  • Download URL: py4agent-0.0.2.tar.gz
  • Upload date:
  • Size: 39.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.2.1 CPython/3.11.5 Darwin/25.2.0

File hashes

Hashes for py4agent-0.0.2.tar.gz
Algorithm Hash digest
SHA256 9a3edfe1f5fc67cd64a6ed6c14654ba516e24b011053fc51b645665995714e36
MD5 aed84201eee409f8ac2aa9b9949255b4
BLAKE2b-256 a07be9e4a22409c5b572bf92134cffbd2d7628029f7d4a16931938f608404a3e

See more details on using hashes here.

File details

Details for the file py4agent-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: py4agent-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 44.4 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

Hashes for py4agent-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 35a782527341993974f70f25bae91f6854c0e32e475bc8d7ba8fab36eef5d934
MD5 6329b459b8d55802ae3786443ca7f094
BLAKE2b-256 040736914f8254538fe3ff9e3f9fa62474de63942ecc3dc8f0b7776c9d7ab557

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page