Skip to main content

klieo_tools_mcp/
lib.rs

1#![deny(missing_docs)]
2#![deny(rust_2018_idioms)]
3#![deny(rustdoc::broken_intra_doc_links)]
4
5//! MCP adapter — exposes remote MCP servers' tools as
6//! [`klieo_core::Tool`] implementations.
7//!
8//! Connect to an MCP server via stdio (subprocess), pull its tool
9//! catalogue, and register the wrapped tools with a
10//! `klieo_tools::ChainedInvoker` alongside native `#[tool]`-derived
11//! tools.
12//!
13//! Each remote tool surfaces as `mcp:<server_id>.<original_name>`.
14//!
15//! # Transports
16//!
17//! - **stdio (subprocess)** — spawn an MCP server as a child process,
18//!   pump JSON-RPC over its stdin/stdout. Production default. Backed by
19//!   the official `rmcp` SDK's `TokioChildProcess` transport.
20//! - **streamable HTTP** (`http` feature) — connect to a REMOTE MCP
21//!   server over the network. `https`-only (loopback `http` permitted for
22//!   local dev), with env-var-sourced auth headers and bounded timeouts.
23//!   Backed by `rmcp`'s reqwest streamable-HTTP client transport. See
24//!   [`McpToolset::connect_http`].
25//! - SSE transport is out of scope; a follow-up plan adds it.
26//!
27//! # Limitations
28//!
29//! - **No tool-list refresh.** Tools are queried once at connect time;
30//!   if the server adds new tools later, reconnect to pick them up.
31//! - **Stdio subprocess hardening.** Stdin/stdout pipes only; stderr is
32//!   inherited so server diagnostics surface in the parent. Working
33//!   directory and env are caller-supplied.
34
35mod version;
36pub use version::MCP_PROTOCOL_VERSION;
37
38pub(crate) mod client;
39#[cfg(feature = "http")]
40pub(crate) mod http;
41pub(crate) mod tool;
42pub mod toolset;
43pub use toolset::{McpServerId, McpToolset, StdioConnectOptions};
44
45#[cfg(feature = "http")]
46pub use http::HttpConnectOptions;