A comprehensive Python library for crafting and decoding DMTF MCTP communication packets
PyMCTP is a modular Python library for working with DMTF MCTP (Management Component Transport Protocol) packets. The library is organized as a monorepo with multiple packages:
- Core library - Protocol layer definitions and packet crafting/decoding
- OEM extensions - Vendor-specific protocol implementations
- Exercisers - Hardware and virtual device interfaces
- pymctp - Main library with MCTP/IPMI/PLDM protocol support
pip install pymctp
- pymctp-sample-vendorextension - Sample vendor extension (template/example)
pip install pymctp-sample-vendorextension
-
pymctp-exerciser-aardvark - Total Phase Aardvark I2C adapter
pip install pymctp-exerciser-aardvark
-
pymctp-exerciser-qemu - QEMU I2C/I3C virtual devices
pip install pymctp-exerciser-qemu
-
pymctp-exerciser-serial - TTY/Serial UART devices
pip install pymctp-exerciser-serial
# Minimal installation (core library only)
pip install pymctp
# With all exercisers
pip install pymctp[all-exercisers]
# Or install specific packages
pip install pymctp pymctp-sample-vendorextension pymctp-exerciser-qemufrom pymctp.layers.mctp import SmbusTransport, TransportHdr
from pymctp.layers.mctp.control import SetEndpointID, ControlHdr
# Craft an MCTP packet
pkt = (
TransportHdr(src=10, dst=0, som=1, eom=1, msg_type=0)
/ ControlHdr(rq=True, cmd_code=1, instance_id=0x11)
/ SetEndpointID(op=0, eid=29)
)
# Decode a packet
from pymctp.layers import mctp
data = bytes([0x01, 0x0b, 0x0a, 0xc5, 0x00, 0x00, 0x0a, 0x00, 0xff, 0x01, 0x01, 0x0a, 0x02, 0x00, 0x04, 0x01, 0x00])
decoded = mctp.TransportHdrPacket(data)
print(decoded.summary())- Protocol Support: MCTP Control, PLDM, IPMI, VDM, NVMe-MI
- Extensible Architecture: Plugin system for layers and exercisers
- Hardware Interfaces: Support for physical and virtual devices
- Scapy Integration: Built on Scapy for powerful packet manipulation
- Core Library Documentation - Full API and usage guide
- Extension Development - Creating custom OEM/layer extensions
- CLI Extension Development - Creating custom CLI commands
- Contributing Guide - How to contribute to the project
- Development Guide - Development setup, building, and testing
This is a monorepo containing multiple Python packages. Each package can be developed and published independently.
For detailed development instructions, see DEVELOPMENT.md
pymctp/
├── packages/
│ ├── pymctp/ # Core library
│ ├── pymctp-sample-vendorextension/ # Sample vendor extension (example/template)
│ ├── pymctp-exerciser-aardvark/ # Aardvark exerciser
│ ├── pymctp-exerciser-qemu/ # QEMU exercisers
│ └── pymctp-exerciser-serial/ # Serial exerciser
├── tests/ # Shared tests
├── examples/ # Example scripts
├── EXTENSIONS.md # Extension development guide
└── MIGRATION.md # Migration guide
This project uses uv for fast, reliable dependency management.
# Clone the repository
git clone https://github.com/jls5177/pymctp.git
cd pymctp
# Install uv (if not already installed)
curl -LsSf https://astral.sh/uv/install.sh | sh
# Install all workspace packages and dependencies
uv sync --all-extras# Run all tests
make test
# Run tests with coverage
make test-cov
# Generate XML coverage report (for CI)
make test-xml# Format code
make format-all
# Check formatting and linting
make format-check
# Validate license headers
make license-check# Build all packages
make build-all
# Or build individually
cd packages/pymctp
uv run python -m buildContributions are welcome! Please see CONTRIBUTING.md for guidelines.
- Fork the repository
- Create a feature branch (
git checkout -b feature-name) - Make your changes
- Run tests (
pytest) - Submit a pull request
This project is licensed under the MIT License - see the LICENSE file for details.
- PyPI: https://pypi.org/project/pymctp/
- Documentation: https://github.com/jls5177/pymctp#readme
- Issues: https://github.com/jls5177/pymctp/issues
- Source: https://github.com/jls5177/pymctp