Rust SDK Guide
Use this guide when you are developing sdks/rust.
What this module owns
sdks/rust owns:
- Rust protocol model mirror types
- path matching and registry behavior
- async client lifecycle and routed invocation handling
- websocket and HTTP loop transports
- crate metadata and Rust-side tests
It does not own:
- protocol source of truth under
packages/protocol - MDP server behavior under
packages/server - JVM or Python runtime packaging concerns
Build and test
Use the crate-scoped commands first:
bash
cargo test --manifest-path sdks/rust/Cargo.toml
cargo package --manifest-path sdks/rust/Cargo.tomlWhat they prove:
cargo testvalidates registry behavior, client lifecycle, ping/pong, and invocation handlingcargo packageproves the published crate can be assembled with the current manifest
Common development workflow
Typical loop:
- update
sdks/rust/src/** - run
cargo test --manifest-path sdks/rust/Cargo.toml - if manifest, README, or public exports changed, run
cargo package --manifest-path sdks/rust/Cargo.toml - if behavior follows a protocol change, compare the Rust model with
packages/protocol/src/**
Debugging expectations
Start by identifying whether the bug is in:
src/path_utils.rspath pattern validation or specificitysrc/registry.rshandler resolution and invocation shapingsrc/client.rsconnection lifecycle or register/sync/disconnect flowsrc/transport.rswire transport and session behavior
When a real transport bug appears, log the raw text frame or HTTP payload before changing typed structs. In practice the first mismatch is often JSON field naming, not async control flow.
Common failure modes
NotConnectedregister()orsync_catalog()ran beforeconnect()UnknownPaththe registered pattern and the incoming path do not match by segment count or reserved leaf shape- handler error in
CallClientResultthe registered closure returned an error or expected a different request body shape - websocket connect failure inspect URL scheme, TLS assumptions, and request headers before changing message logic
Release and packaging notes
This SDK is published by the shared v* release workflow.
Local preflight:
bash
cargo test --manifest-path sdks/rust/Cargo.toml
cargo package --manifest-path sdks/rust/Cargo.tomlRepository-side publishing expectations live in Polyglot SDK Packages.