Expand description
Talk to a running mcpmesh daemon from Rust.
This crate is the mcpmesh-local/1 control seam: the typed wire vocabulary of the daemon’s
local control endpoint (requests, results, and the live-stream frames), the platform rule for
finding that endpoint (paths), and — behind the client feature — an async client that
speaks it. It links no networking stack: embedders (UIs, plugins, scripts) drive the
daemon without pulling the mesh transport.
The full protocol (framing, method-by-method semantics, the identity contract) is documented in
docs/local-protocol.md.
§Quickstart (feature client)
let mut daemon = mcpmesh_local_api::connect_control_default().await?;
let status = daemon.status().await?;
for peer in &status.peers {
println!("{} shares: {}", peer.name, peer.services.join(", "));
}connect_control_default dials the platform default endpoint (a unix socket, or a named
pipe on Windows — the one rule in paths::default_endpoint); ControlClient then offers
a typed helper per control method (status, invite, pair, subscribe, …), with
ControlClient::request as the raw escape hatch for forward compatibility.
§Features
| Feature | Adds | Dependencies |
|---|---|---|
| (none) | The wire vocabulary (protocol) + endpoint resolution (paths) | serde only |
client | ControlClient: connect, typed request helpers, the typed client::StreamSubscription live stream | + tokio |
service | The plugin seam (service): local endpoint bind + same-user gate, [services.*] self-registration | + rustix, tracing |
Re-exports§
pub use principals::principal_set;pub use protocol::API_NAME;pub use protocol::API_VERSION;pub use protocol::ActiveSession;pub use protocol::AuditKind;pub use protocol::AuditRecord;pub use protocol::AuditSummaryResult;pub use protocol::BackendKind;pub use protocol::BackendSpec;pub use protocol::BlobFetchParams;pub use protocol::BlobFetchResult;pub use protocol::BlobGrantParams;pub use protocol::BlobPublishParams;pub use protocol::BlobPublishResult;pub use protocol::BlobScopeList;pub use protocol::Hello;pub use protocol::InviteParams;pub use protocol::InviteResult;pub use protocol::OpenSessionParams;pub use protocol::OrgJoinParams;pub use protocol::OrgJoinResult;pub use protocol::PairParams;pub use protocol::PairResult;pub use protocol::PeerAddParams;pub use protocol::PeerInfo;pub use protocol::PeerReachability;pub use protocol::PeerRemoveParams;pub use protocol::PeerRenameParams;pub use protocol::PresencePeer;pub use protocol::RecentPairing;pub use protocol::RegisterServiceParams;pub use protocol::Request;pub use protocol::RosterInstallParams;pub use protocol::RosterInstallResult;pub use protocol::RosterStatus;pub use protocol::ScopeInfo;pub use protocol::ServiceInfo;pub use protocol::SetRosterUrlParams;pub use protocol::StatusResult;pub use protocol::StreamFrame;pub use protocol::method_of;pub use client::ControlClient;pub use client::StreamSubscription;pub use client::connect_control;pub use client::connect_control_default;
Modules§
- client
- A no-iroh mcpmesh-local/1 client: connect the UDS, read the server’s
Hellofirst frame, assert the api name, then issue typed request/response frames. Distinct from the CLI crate (cli/)’s ControlClient (which uses mcpmesh_net::framing) — this one links no iroh, so kb and the host shell can use it. kb calls this to self-register its[services.kb]socket backend with the running mcpmesh daemon. - codec
- The family’s one wire codec: compact JSON, UTF-8, one frame per
\n, 16 MiB cap. Re-exported frommcpmesh-codec— ONE implementation, provably shared with the daemon side (mcpmesh_net::framingre-exports the same crate), so the two ends cannot drift.mcpmesh-codeclinks no iroh, so this stays a no-iroh client crate. - paths
- Platform paths + endpoint resolution — featureless/std-only, so any consumer
resolves the daemon endpoint from the ONE rule.
Shared paths rule: resolved per-platform in ONE place (XDG on unix;
APPDATA/LOCALAPPDATA + named-pipe names on windows). Featureless and std-only —
it lives on the vocabulary crate precisely so EVERY consumer (the daemon, the CLI,
and plugins, which are barred from
mcpmesh-trust) resolves the same endpoint from the same rule instead of a per-crate replica.mcpmesh_trust::pathsre-exports it. - principals
- THE principal-set expansion: the ONE definition of a resolved caller’s flat
authorization identity —
groups ∪ {petname} ∪ {user_id}, empty components skipped, default-deny (no identity ⇒ empty set ⇒ nothing matches). - protocol
- mcpmesh-local/1 protocol types. Shared vocabulary between the daemon and its clients (porcelain, connect proxy, later the host shell). Wire framing is the family NDJSON codec — carried by the caller, not defined here.
- service
- The shared plugin-platform seam (kb, loc, …): local endpoint faces, THE audience-authz
expansion,
[services.*]self-registration, and the*-local/1JSON-RPC conventions. The shared plugin-platform seam (servicefeature): everything a plugin daemon (kb, loc, …) needs to face the platform, extracted from the kb/loc byte-duplicates so each rule has ONE home: - transport
- The platform local-endpoint seam: connect/bind/accept/authorize.
The platform local-endpoint seam: ONE narrow API —
connect_local,bind_local,LocalListener::accept,authorize_local_peer,split_local— with per-platform impls. Unix: the family’s hardened UDS rule (0700 symlink-refused dir, 0600 socket, same-euid peer gate). Windows: an owner-only-DACL named pipe (the kernel enforces same-user at connect; seewindows.rs). Everything above this seam is platform-identical: the endpoint value is aPathon both (a socket path / a\\.\pipe\…name), and both stream types areAsyncRead + AsyncWrite.