Skip to main content

MIP-Client-python

PyPI version License: MIT

Python async client for the MIP (MSIP) protocol - handles connections, events, errors, and auto-reconnection.

Server implementation: MIP Server

Part of the MIP Client family:

Installation

pip install mip-client-python

Usage

Basic Connection

import asyncio
from mip_client import MIPClient

async def main():
    client = MIPClient(host="127.0.0.1", port=9000, client_id="my_client_123")

    # Register event callbacks
    client.on_connect(lambda: print("Connected to server"))
    client.on_disconnect(lambda: print("Disconnected"))
    client.on_error(lambda err: print(f"Error: {err.message}"))
    client.on_message(lambda msg: print(f"[{msg.topic}] {msg.message}"))

    # Connect
    await client.connect()

    # Keep running
    await asyncio.sleep(60)
    await client.disconnect()

asyncio.run(main())

Subscribe / Publish

# Subscribe to a topic
client.subscribe("my-topic")

# Listen for messages
def handle_message(msg):
    print(f"Topic: {msg.topic}")
    print(f"Message: {msg.message}")

client.on_message(handle_message)

# Publish a message
client.publish("my-topic", "Hello World!")

Advanced Options

from mip_client import MIPClient, Flags

client = MIPClient(
    host="127.0.0.1",
    port=9000,
    client_id="my_client_123",  # Optional client identifier
    auto_reconnect=True,        # Auto-reconnect (default: True)
    reconnect_delay=3.0,        # Delay between reconnections in seconds (default: 3.0)
    max_reconnect_attempts=10,  # Max attempts (0 = infinite)
    ping_interval=5.0,          # Ping interval in seconds (0 = disabled)
)

# Publish with flags
client.publish("urgent-topic", "Important!", Flags.URGENT | Flags.ACK_REQUIRED)

# Listen for ACKs
client.on_ack(lambda msg_id: print(f"ACK received for: {msg_id}"))

# Manual ping
client.ping()
client.on_pong(lambda: print("Pong received!"))

Auto-Reconnection

client.on_reconnecting(lambda attempt: print(f"Reconnection attempt #{attempt}..."))

def on_connect():
    # Re-subscribe after reconnection
    client.subscribe("my-topic")

client.on_connect(on_connect)

Using create_client helper

from mip_client import create_client

client = create_client("127.0.0.1", 9000, auto_reconnect=True)

API Reference

MIPClient

  • connect() - Connect to the server (async)
  • disconnect() - Disconnect from the server (async)
  • subscribe(topic, require_ack=True) - Subscribe to a topic
  • unsubscribe(topic, require_ack=True) - Unsubscribe from a topic
  • publish(topic, message, flags=Flags.NONE) - Publish a message
  • ping() - Send a ping to the server

Events

  • on_connect(callback) - Called when connected
  • on_disconnect(callback) - Called when disconnected
  • on_reconnecting(callback) - Called when reconnecting (receives attempt number)
  • on_message(callback) - Called when a message is received
  • on_event(callback) - Called when an event is received
  • on_ack(callback) - Called when an ACK is received
  • on_pong(callback) - Called when a pong is received
  • on_error(callback) - Called when an error occurs

Flags

  • Flags.NONE - No flags
  • Flags.ACK_REQUIRED - Request acknowledgment
  • Flags.COMPRESSED - Compressed payload
  • Flags.URGENT - Urgent message

Metadata

Release files for mip-client-python 1.0.2

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

Source distribution (sdist)

Source distribution for mip-client-python 1.0.2
File Size Uploaded
mip_client_python-1.0.2.tar.gz 7.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for mip-client-python 1.0.2
File Interpreter ABI Platform
mip_client_python-1.0.2-py3-none-any.whl Python 3 none any Details

Total release size: 15.2 kB

Release files / mip_client_python-1.0.2.tar.gz

Download URL mip_client_python-1.0.2.tar.gz
Size 7.3 kB
Tags Source
SHA-256 checksum
How to use checksums
15efc1d4717dbcd6a53368a57ea5f13d815c8caf7b4b2f40ab084f82b9f08ef8
BLAKE2b-256 checksum
How to use checksums
bdefeed293bf09358be263941113b30baaeb5baec394b534bcf825e62003fd7a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 10, 2026.

Transparency log

Release files / mip_client_python-1.0.2-py3-none-any.whl

Download URL mip_client_python-1.0.2-py3-none-any.whl
Size 7.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0fb2832e067c509d4ce5fa599ad23ea1b87101fb1c86be500b09676e89692859
BLAKE2b-256 checksum
How to use checksums
7ab2bef45057183ca18fbdf4346c00aacfa55f891966e4df0d139ac14b58d78b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 10, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

1.0.2 This release

2 release files

1.0.0

2 release files

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