Skip to main content

🤖 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:

jupyter-lab --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-server --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
└── 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

Metadata

Release files for py4agent 1.0.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for py4agent 1.0.6
File Size Uploaded Provenance Actions
py4agent-1.0.6.tar.gz 32.1 kB Without provenance Details for py4agent-1.0.6.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for py4agent 1.0.6
File Interpreter ABI Platform Actions
py4agent-1.0.6-py3-none-any.whl Python 3 none any Details for py4agent-1.0.6-py3-none-any.whl

Total release size: 67.1 kB

Release files / py4agent-1.0.6.tar.gz

Download URL py4agent-1.0.6.tar.gz
Size 32.1 kB
Tags Source
SHA-256 checksum
How to use checksums
1b08e65a4540c7bcecc4bb380753ebec18200804f2ab3522089d043ab2d7fe3f
BLAKE2b-256 checksum
How to use checksums
1b7a0a7b8ac994ca05f3a4e48ebc2df54b10a099647ade0e5a5541efa52a5958
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.2.1 CPython/3.11.5 Darwin/25.3.0

Release files / py4agent-1.0.6-py3-none-any.whl

Download URL py4agent-1.0.6-py3-none-any.whl
Size 35.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e38c56633f3f651cc9f57a11ae8b776608593471f593b7b81aff9a4a1913e2a9
BLAKE2b-256 checksum
How to use checksums
991789f46c0884d144f63b66422449b0c4f40950ad04ccd1a3c4a53ab3de289a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.2.1 CPython/3.11.5 Darwin/25.3.0

Security for py4agent 1.0.6

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page