| Crates.io | turbomcp-wire |
| lib.rs | turbomcp-wire |
| version | 3.0.0-beta.3 |
| created_at | 2026-01-12 17:50:14.769438+00 |
| updated_at | 2026-01-22 15:59:47.180583+00 |
| description | Wire format codec abstraction for TurboMCP - JSON-RPC encoding/decoding |
| homepage | |
| repository | https://github.com/Epistates/turbomcp |
| max_upload_size | |
| id | 2038372 |
| size | 43,039 |
Wire format codec abstraction for TurboMCP - JSON-RPC encoding/decoding with pluggable serialization.
This crate provides the wire format layer for MCP protocol communication. It abstracts over different serialization formats while maintaining MCP protocol compliance.
no_std Compatible - Works in embedded and WASM environmentsuse turbomcp_wire::{Codec, JsonCodec};
use serde::{Serialize, Deserialize};
#[derive(Serialize, Deserialize)]
struct Request {
jsonrpc: String,
id: u32,
method: String,
}
let codec = JsonCodec::new();
// Encode
let request = Request {
jsonrpc: "2.0".into(),
id: 1,
method: "initialize".into(),
};
let bytes = codec.encode(&request).unwrap();
// Decode
let decoded: Request = codec.decode(&bytes).unwrap();
For HTTP/SSE transports with newline-delimited JSON:
use turbomcp_wire::StreamingJsonDecoder;
let mut decoder = StreamingJsonDecoder::new();
// Feed data as it arrives
decoder.feed(data_chunk);
// Try to decode complete messages
while let Some(msg) = decoder.try_decode::<MyMessage>()? {
handle_message(msg);
}
| Feature | Description |
|---|---|
std |
Standard library support (default) |
json |
JSON codec (default) |
simd |
SIMD-accelerated JSON (sonic-rs) |
msgpack |
MessagePack binary format |
full |
All features |
Create codecs dynamically by name using AnyCodec:
use turbomcp_wire::AnyCodec;
let codec = AnyCodec::from_name("json").unwrap();
let bytes = codec.encode(&my_data).unwrap();
println!("Available codecs: {:?}", AnyCodec::available_names());
With simd feature enabled, JSON parsing can be 2-4x faster on supported platforms:
cargo bench --features simd
MIT