mcpmesh_node/lib.rs
1//! Embed a full [mcpmesh](https://github.com/counterpunchtech/mcpmesh) node in-process.
2//!
3//! The supported surface is [`NodeBuilder`]/[`Node`] plus the `mcpmesh-local/1` control
4//! protocol [`Node::control`] speaks (see `docs/local-protocol.md`). Every other module in
5//! this crate is `#[doc(hidden)]` internals of the mcpmesh daemon — no stability promise is
6//! made for them; they may change or vanish in any release without a major version bump.
7//!
8//! Only driving a RUNNING daemon (the sidecar model)? Depend on
9//! [`mcpmesh-local-api`](https://docs.rs/mcpmesh-local-api) instead — it links no
10//! networking stack at all. The full embedding guide (root-dir layout, host contract,
11//! sidecar-vs-embedded) is
12//! [`docs/embedding.md`](https://github.com/counterpunchtech/mcpmesh/blob/main/docs/embedding.md).
13//!
14//! # Quickstart
15//!
16//! ```no_run
17//! # async fn quickstart() -> anyhow::Result<()> {
18//! let node = mcpmesh_node::NodeBuilder::new("/var/lib/myapp/mesh").start().await?;
19//! let mut control = node.control().await?;
20//! control.register_service(
21//! "notes",
22//! mcpmesh_local_api::BackendSpec::Run {
23//! cmd: vec!["my-mcp-server".into()],
24//! env: Default::default(),
25//! cwd: None,
26//! },
27//! vec![],
28//! ).await?;
29//! let invite = control.invite(vec!["notes".into()]).await?;
30//! println!("send this to a friend: {}", invite.invite_line);
31//! # Ok(())
32//! # }
33//! ```
34//!
35//! The node is a full peer: everything the mcpmesh daemon can do — pairing, live MCP
36//! sessions (`open_session`), roster/org mode, blobs, audit — works through
37//! [`Node::control`], because it runs the daemon's own handlers.
38
39/// This crate's version — the mcpmesh release-train version the daemon binary ships on.
40pub const VERSION: &str = env!("CARGO_PKG_VERSION");
41
42pub use config::Config;
43/// The pinned iroh, re-exported (#67).
44///
45/// [`Node::accept_protocol`](node::Node::accept_protocol) and
46/// [`Node::connect_protocol`](node::Node::connect_protocol) name iroh types in their signatures,
47/// so an embedder needs them in scope. Use THIS path — never your own `iroh` dependency: a
48/// version mismatch is a different crate to the type system and breaks the build with an
49/// `expected Connection, found Connection`.
50pub use mcpmesh_net::iroh;
51/// The pinned `mcpmesh-trust`, re-exported (#85).
52///
53/// [`NodeBuilder::device_key`](node::NodeBuilder::device_key) takes a
54/// `mcpmesh_trust::ed25519_dalek::SigningKey`, so an embedder needs that type in scope. Use THIS
55/// path rather than adding your own `mcpmesh-trust` or `ed25519-dalek` dependency — the version
56/// hazard is identical to the iroh one above, and the compiler error is just as unhelpful.
57pub use mcpmesh_trust;
58pub use node::{Node, NodeBuilder, StartError};
59pub use paths::NodePaths;
60
61#[doc(hidden)]
62pub mod allowlist;
63#[doc(hidden)]
64pub mod audit;
65#[doc(hidden)]
66pub mod backends;
67#[doc(hidden)]
68pub mod blobs;
69#[doc(hidden)]
70pub mod cancel;
71#[doc(hidden)]
72pub mod config;
73#[doc(hidden)]
74pub mod control;
75#[doc(hidden)]
76pub mod daemon;
77/// Node-level conditions that are observable but have no API to observe them through (#134) —
78/// currently the relay's duplicate-endpoint-id report, which iroh 1.0.3 only `warn!`s.
79pub mod diag;
80#[doc(hidden)]
81pub mod ipc;
82#[doc(hidden)]
83pub mod limits;
84pub mod node;
85#[doc(hidden)]
86pub mod pairing;
87pub mod paths;
88#[doc(hidden)]
89pub mod roster;
90#[doc(hidden)]
91pub mod stream;
92#[doc(hidden)]
93pub mod util;