Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions crates/rmcp/src/error.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
use std::{borrow::Cow, fmt::Display};

pub use crate::model::ErrorData;
#[deprecated(
note = "Use `rmcp::ErrorData` instead, `rmcp::ErrorData` could become `RmcpError` in the future."
)]
pub type Error = ErrorData;
impl Display for ErrorData {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{}: {}", self.code.0, self.message)?;
Expand Down
69 changes: 39 additions & 30 deletions crates/rmcp/src/handler/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,42 +129,51 @@ macro_rules! client_handler_methods {
/// Real clients should override this to provide user interaction.
///
/// # Example
/// ```rust,ignore
/// use rmcp::model::ElicitRequestParams;
/// ```rust,no_run
/// use rmcp::{
/// model::ErrorData as McpError,
/// model::*,
/// service::{NotificationContext, RequestContext, RoleClient, Service, ServiceRole},
/// ClientHandler,
/// model::{
/// ElicitRequestParams, ElicitResult, ElicitationAction, ElicitationSchema,
/// ErrorData as McpError,
/// },
/// service::{RequestContext, RoleClient},
/// };
/// use rmcp::ClientHandler;
///
/// # struct MyClient;
/// #
/// # async fn get_user_input(
/// # _message: String,
/// # _schema: ElicitationSchema,
/// # ) -> Result<serde_json::Value, McpError> {
/// # std::future::pending().await
/// # }
/// #
/// # async fn open_url_in_browser(_url: String) -> Result<(), McpError> {
/// # Ok(())
/// # }
/// #
/// impl ClientHandler for MyClient {
/// async fn create_elicitation(
/// &self,
/// request: ElicitRequestParams,
/// context: RequestContext<RoleClient>,
/// ) -> Result<ElicitResult, McpError> {
/// match request {
/// ElicitRequestParams::FormElicitationParam {meta, message, requested_schema,} => {
/// // Display message to user and collect input according to requested_schema
/// let user_input = get_user_input(message, requested_schema).await?;
/// Ok(ElicitResult {
/// action: ElicitationAction::Accept,
/// content: Some(user_input),
/// meta: None,
/// })
/// }
/// ElicitRequestParams::UrlElicitationParam {meta, message, url, elicitation_id,} => {
/// // Open URL in browser for user to complete elicitation
/// open_url_in_browser(url).await?;
/// Ok(ElicitResult {
/// action: ElicitationAction::Accept,
/// content: None,
/// meta: None,
/// })
/// async fn create_elicitation(
/// &self,
/// request: ElicitRequestParams,
/// _context: RequestContext<RoleClient>,
/// ) -> Result<ElicitResult, McpError> {
/// match request {
/// ElicitRequestParams::FormElicitationParams {
/// message,
/// requested_schema,
/// ..
/// } => {
/// let input = get_user_input(message, requested_schema).await?;
/// Ok(ElicitResult::new(ElicitationAction::Accept).with_content(input))
/// }
/// ElicitRequestParams::UrlElicitationParams { url, .. } => {
/// open_url_in_browser(url).await?;
/// Ok(ElicitResult::new(ElicitationAction::Accept))
/// }
/// _ => Ok(ElicitResult::new(ElicitationAction::Decline)),
/// }
/// }
/// }
/// }
/// ```
fn create_elicitation(
Expand Down
3 changes: 1 addition & 2 deletions crates/rmcp/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
#![doc = include_str!("../README.md")]

mod error;
#[allow(deprecated)]
pub use error::{Error, ErrorData, RmcpError};
pub use error::{ErrorData, RmcpError};

/// Basic data types in MCP specification
pub mod model;
Expand Down
Loading