From 81b226f171e5ba9c93c3dfc74088a9e304e7969b Mon Sep 17 00:00:00 2001 From: Pavel Bezglasnyy Date: Wed, 14 Jan 2026 16:04:28 +0100 Subject: [PATCH] fix(build): fix build of the project when no features are selected --- crates/rmcp/Cargo.toml | 22 ++++++++++++++++++++++ crates/rmcp/src/error.rs | 1 + crates/rmcp/src/lib.rs | 7 ++++++- crates/rmcp/src/transport.rs | 9 ++++++++- 4 files changed, 37 insertions(+), 2 deletions(-) diff --git a/crates/rmcp/Cargo.toml b/crates/rmcp/Cargo.toml index f7af815a..b9c0baa2 100644 --- a/crates/rmcp/Cargo.toml +++ b/crates/rmcp/Cargo.toml @@ -208,3 +208,25 @@ path = "tests/test_task.rs" name = "test_streamable_http_priming" required-features = ["server", "client", "transport-streamable-http-server", "reqwest"] path = "tests/test_streamable_http_priming.rs" + + +[[test]] +name = "test_custom_request" +required-features = ["server", "client"] +path = "tests/test_custom_request.rs" + +[[test]] +name = "test_prompt_macros" +required-features = ["server", "client"] +path = "tests/test_prompt_macros.rs" + +[[test]] +name = "test_sampling" +required-features = ["server", "client"] +path = "tests/test_sampling.rs" + + +[[test]] +name = "test_close_connection" +required-features = ["server", "client"] +path = "tests/test_close_connection.rs" diff --git a/crates/rmcp/src/error.rs b/crates/rmcp/src/error.rs index f51a7158..51f60acb 100644 --- a/crates/rmcp/src/error.rs +++ b/crates/rmcp/src/error.rs @@ -20,6 +20,7 @@ impl std::error::Error for ErrorData {} /// This is an unified error type for the errors could be returned by the service. #[derive(Debug, thiserror::Error)] +#[allow(clippy::large_enum_variant)] pub enum RmcpError { #[error("Service error: {0}")] Service(#[from] ServiceError), diff --git a/crates/rmcp/src/lib.rs b/crates/rmcp/src/lib.rs index 3ab7c5d9..f1f1e406 100644 --- a/crates/rmcp/src/lib.rs +++ b/crates/rmcp/src/lib.rs @@ -104,9 +104,14 @@ //! //! ```rust //! use anyhow::Result; -//! use rmcp::{model::CallToolRequestParam, service::ServiceExt, transport::{TokioChildProcess, ConfigureCommandExt}}; +//! use rmcp::{model::CallToolRequestParam, service::ServiceExt}; +//! #[cfg(feature = "transport-child-process")] +//! #[cfg_attr(docsrs, doc(cfg(feature = "transport-child-process")))] +//! use rmcp::transport::{TokioChildProcess, ConfigureCommandExt}; //! use tokio::process::Command; //! +//! #[cfg(feature = "transport-child-process")] +//! #[cfg_attr(docsrs, doc(cfg(feature = "transport-child-process")))] //! async fn client() -> Result<()> { //! let service = ().serve(TokioChildProcess::new(Command::new("uvx").configure(|cmd| { //! cmd.arg("mcp-server-git"); diff --git a/crates/rmcp/src/transport.rs b/crates/rmcp/src/transport.rs index d5191738..5b9318d9 100644 --- a/crates/rmcp/src/transport.rs +++ b/crates/rmcp/src/transport.rs @@ -40,10 +40,15 @@ //! //! ```rust //! # use rmcp::{ -//! # ServiceExt, serve_client, serve_server, +//! # ServiceExt, serve_server, //! # }; +//! #[cfg(feature = "client")] +//! #[cfg_attr(docsrs, doc(cfg(feature = "client")))] +//! # use rmcp::serve_client; //! //! // create transport from tcp stream +//! #[cfg(feature = "client")] +//! #[cfg_attr(docsrs, doc(cfg(feature = "client")))] //! async fn client() -> Result<(), Box> { //! let stream = tokio::net::TcpSocket::new_v4()? //! .connect("127.0.0.1:8001".parse()?) @@ -55,6 +60,8 @@ //! } //! //! // create transport from std io +//! #[cfg(feature = "client")] +//! #[cfg_attr(docsrs, doc(cfg(feature = "client")))] //! async fn io() -> Result<(), Box> { //! let client = ().serve((tokio::io::stdin(), tokio::io::stdout())).await?; //! let tools = client.peer().list_tools(Default::default()).await?;