Python SDK Guide
Use this guide when you are developing sdks/python.
What this module owns
sdks/python owns:
- Python protocol models and message helpers
- registry behavior and path matching
- websocket and HTTP loop client transports
- package metadata and Python-side tests
It does not own:
- protocol source of truth under
packages/protocol - server routing logic under
packages/server - browser-specific auth bootstrap behavior from the JavaScript SDK
Local setup
Create one virtualenv inside the SDK directory:
bash
cd sdks/python
python3 -m venv .venv
. .venv/bin/activate
python -m pip install --upgrade pip
python -m pip install -e '.[test]'Build and test
Use the package-scoped commands first:
bash
cd sdks/python
. .venv/bin/activate
python -m compileall src/modeldriveprotocol
pytest -q
python -m buildWhat they prove:
compileallcatches basic syntax regressions quicklypytest -qvalidates registry behavior, register flow, ping/pong, and invocation handlingpython -m buildproves the package metadata and wheel/sdist build still work
Common development workflow
Typical loop:
- update
src/modeldriveprotocol/** - run
pytest -q - if transport or packaging changed, run
python -m build - if behavior mirrors a protocol change, verify the corresponding TypeScript protocol package too
Debugging expectations
Start with the narrowest layer that can prove the bug:
- registry/path bugs: add or adjust tests in
tests/test_registry.py - lifecycle bugs: add or adjust tests in
tests/test_client.py - transport bugs: isolate the transport with a fake server or injected client first
If you need to debug a real runtime session, log the raw JSON message shape before assuming the Python model is wrong. Most first-failure cases here are message-shape drift or path-shape mismatch.
Common failure modes
MDP client is not connectedregister()orsync_catalog()ran beforeconnect()- unknown path for a routed invocation the registered path pattern and the concrete call path do not have the same segment count
- handler error on skill or prompt paths a reserved
skill.mdorprompt.mdleaf was exposed as an endpoint - HTTP loop session closes unexpectedly inspect
/connect,/send, and/pollstatus codes before changing client logic
Release and packaging notes
This SDK is published by the shared v* release workflow.
Local preflight:
bash
cd sdks/python
. .venv/bin/activate
pytest -q
python -m buildRepository-side publishing expectations live in Polyglot SDK Packages.