Skip to main content
The Rust SDK (rcp-protocol, imported as rcp) is built entirely on the Rust standard library — no dependencies. Like the C++ SDK vendors json.hpp, this crate vendors a small JSON value type, so you never need serde to speak RCP. It is synchronous and blocking; every call returns Result<_, RcpError>, and it interoperates byte-for-byte with the C++, Python, and Node.js SDKs.

Add it

or in Cargo.toml:
Requires Rust 1.70+.

Server

Handlers are FnMut(&Json) -> Result<Json, RcpError>.

Client

Connect over stdio or HTTP, then make typed, capability-gated calls. A gated call to an unadvertised capability returns Err(CapabilityMissing) before any I/O.
The error carries the wire code and message; Display renders "[RCP <code>] <message>":
Client methods: embed, embed_sparse, embed_multi, rerank, retrieve, search (returns SearchResult { hits, usage, next_cursor }), graph, transform, index_add, index_delete, catalog, info, ping, call, shutdown.

Selecting a backend

The JSON value type

rcp::Json is a small, ordered JSON value with parse, Display / dump, get / get_str / as_* accessors, insert / push, From impls, and the rcp::obj(&[(key, value)]) builder — the reason the SDK stays dependency-free.

Fusion & the vector codec

The reference Reciprocal Rank Fusion (spec §16.3) and the compact f32-base64 embedding codec (§7.3.1) are standalone, unit-tested modules — byte-for-byte identical to the Python, Node, and C++ SDKs:
See Federation and compact encoding.

Test

The suite includes a case where the Rust client drives the C++ example server, proving cross-language interop; cargo clippy is clean.