diff --git a/crates/rmcp/Cargo.toml b/crates/rmcp/Cargo.toml index 4703c667..45f7faa1 100644 --- a/crates/rmcp/Cargo.toml +++ b/crates/rmcp/Cargo.toml @@ -77,7 +77,7 @@ chrono = { version = "0.4.38", default-features = false, features = [ [features] default = ["base64", "macros", "server"] client = ["dep:tokio-stream"] -server = ["transport-async-rw", "dep:schemars"] +server = ["transport-async-rw", "dep:schemars", "dep:pastey"] macros = ["dep:rmcp-macros", "dep:pastey"] elicitation = [] diff --git a/crates/rmcp/src/error.rs b/crates/rmcp/src/error.rs index e0da2b3d..2d19660f 100644 --- a/crates/rmcp/src/error.rs +++ b/crates/rmcp/src/error.rs @@ -1,6 +1,5 @@ use std::{borrow::Cow, fmt::Display}; -use crate::ServiceError; pub use crate::model::ErrorData; #[deprecated( note = "Use `rmcp::ErrorData` instead, `rmcp::ErrorData` could become `RmcpError` in the future." @@ -21,8 +20,9 @@ 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)] pub enum RmcpError { + #[cfg(any(feature = "client", feature = "server"))] #[error("Service error: {0}")] - Service(#[from] ServiceError), + Service(#[from] crate::ServiceError), #[cfg(feature = "client")] #[error("Client initialization error: {0}")] ClientInitialize(#[from] crate::service::ClientInitializeError), diff --git a/crates/rmcp/src/lib.rs b/crates/rmcp/src/lib.rs index 9f81eabe..e5c0e32d 100644 --- a/crates/rmcp/src/lib.rs +++ b/crates/rmcp/src/lib.rs @@ -171,8 +171,8 @@ pub use pastey::paste; #[cfg(all(feature = "macros", feature = "server"))] #[cfg_attr(docsrs, doc(cfg(all(feature = "macros", feature = "server"))))] pub use rmcp_macros::*; -#[cfg(all(feature = "macros", feature = "server"))] -#[cfg_attr(docsrs, doc(cfg(all(feature = "macros", feature = "server"))))] +#[cfg(any(feature = "macros", feature = "server"))] +#[cfg_attr(docsrs, doc(cfg(any(feature = "macros", feature = "server"))))] pub use schemars; #[cfg(feature = "macros")] #[cfg_attr(docsrs, doc(cfg(feature = "macros")))] diff --git a/crates/rmcp/src/model/prompt.rs b/crates/rmcp/src/model/prompt.rs index bb63938f..f90aff19 100644 --- a/crates/rmcp/src/model/prompt.rs +++ b/crates/rmcp/src/model/prompt.rs @@ -1,8 +1,7 @@ -use base64::engine::{Engine, general_purpose::STANDARD as BASE64_STANDARD}; use serde::{Deserialize, Serialize}; use super::{ - AnnotateAble, Annotations, Icon, Meta, RawEmbeddedResource, RawImageContent, + AnnotateAble, Annotations, Icon, Meta, RawEmbeddedResource, content::{EmbeddedResource, ImageContent}, resource::ResourceContents, }; @@ -138,11 +137,13 @@ impl PromptMessage { meta: Option, annotations: Option, ) -> Self { + use base64::{Engine, prelude::BASE64_STANDARD}; + let base64 = BASE64_STANDARD.encode(data); Self { role, content: PromptMessageContent::Image { - image: RawImageContent { + image: crate::model::RawImageContent { data: base64, mime_type: mime_type.into(), meta, @@ -215,7 +216,7 @@ mod tests { #[test] fn test_prompt_message_image_serialization() { - let image_content = RawImageContent { + let image_content = crate::model::RawImageContent { data: "base64data".to_string(), mime_type: "image/png".to_string(), meta: None,