---
sidebar:
  hidden: true
title: roboto.formats.mcap.msgpack_decoder_factory
---
MCAP decoder factory for msgpack-encoded messages.

Exposes an `mcap.decoder.DecoderFactory` that decodes `msgpack` messages (typically described by a `jsonschema` schema), for use by [`McapReader`](/docs/reference/python-sdk/roboto/formats/mcap/reader#roboto.formats.mcap.reader.McapReader). Decoding is delegated to the shared Rust decoder (the `mcap_codec` extension built from `roboto-mcap-codec`), which returns nested `dict` / `list` / scalar values.

Known limitation: msgpack-numpy ndarray fields — nested maps with *binary* keys (`nd`/`type`/`shape`/`data`), used by compressed-video packet payloads — are silently dropped by the codec: the field decodes to an empty `{}` and the payload bytes are unrecoverable downstream. Every other field of such a message decodes normally. Tracked in [https://github.com/roboto-ai/roboto-mcap-codec/issues/5](https://github.com/roboto-ai/roboto-mcap-codec/issues/5); until that lands, consumers must treat non-`bytes` payload fields as undecodable rather than assume frame data is present.

## Module Contents

### MsgpackDecodeError

```python
exception roboto.formats.mcap.msgpack_decoder_factory.MsgpackDecodeError
```

`from roboto.formats.mcap.msgpack_decoder_factory import MsgpackDecodeError`

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/formats/mcap/msgpack_decoder_factory.py#L43-L44)

Bases: `mcap.exceptions.McapError`

Raised when a `msgpack` message cannot be decoded.

### MsgpackDecoderFactory

```python
class roboto.formats.mcap.msgpack_decoder_factory.MsgpackDecoderFactory
```

`from roboto.formats.mcap.msgpack_decoder_factory import MsgpackDecoderFactory`

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/formats/mcap/msgpack_decoder_factory.py#L47-L113)

Bases: `mcap.decoder.DecoderFactory`

Decode msgpack-encoded MCAP messages via the shared Rust `mcap_codec` decoder.

Supply an instance to `mcap.reader.make_reader()`. The schema is parsed once per schema id; the returned callable then decodes each message into nested `dict` / `list` / scalar values.

#### MsgpackDecoderFactory.decoder_for()

```python
def decoder_for(
    message_encoding: str,
    schema: Optional[mcap.records.Schema],
) -> Optional[Callable[[bytes], Any]]
```

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/formats/mcap/msgpack_decoder_factory.py#L58-L67)

If the message encoding and schema arguments can be decoded by this decoder factory, returns a callable to decode message bytes.

**Parameters**

- **message_encoding** (`str`)
- **schema** (`Optional[mcap.records.Schema]`)

**Returns**

- `Optional[Callable[[bytes], Any]]`

### make_msgpack_decoder_factory()

```python
def roboto.formats.mcap.msgpack_decoder_factory.make_msgpack_decoder_factory() -> MsgpackDecoderFactory
```

`from roboto.formats.mcap.msgpack_decoder_factory import make_msgpack_decoder_factory`

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/formats/mcap/msgpack_decoder_factory.py#L116-L119)

Build a decoder factory for msgpack-encoded messages, backed by the shared Rust `mcap_codec` decoder.

**Returns**

- `MsgpackDecoderFactory`
