Skip to content

jls5177/pymctp

Repository files navigation

PyMCTP - DMTF MCTP Protocol Library

A comprehensive Python library for crafting and decoding DMTF MCTP communication packets

build codecov PyPI version

Overview

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

Packages

Core Package

  • pymctp - Main library with MCTP/IPMI/PLDM protocol support
    pip install pymctp

Vendor Extensions

Exercisers

Quick Start

Installation

# 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-qemu

Usage Example

from 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())

Features

  • 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

Documentation

Development

This is a monorepo containing multiple Python packages. Each package can be developed and published independently.

For detailed development instructions, see DEVELOPMENT.md

Repository Structure

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

Development Setup

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

Running Tests

# Run all tests
make test

# Run tests with coverage
make test-cov

# Generate XML coverage report (for CI)
make test-xml

Code Quality

# Format code
make format-all

# Check formatting and linting
make format-check

# Validate license headers
make license-check

Building Packages

# Build all packages
make build-all

# Or build individually
cd packages/pymctp
uv run python -m build

Contributing

Contributions are welcome! Please see CONTRIBUTING.md for guidelines.

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature-name)
  3. Make your changes
  4. Run tests (pytest)
  5. Submit a pull request

License

This project is licensed under the MIT License - see the LICENSE file for details.

Links

About

PyMCTP is a tool to craft/decode DMTF MCTP communication packets

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages