pub struct RpcError {
pub code: i64,
pub data: Option<Value>,
pub message: String,
}Expand description
Latest MCP Protocol 2026_07_28 RpcError
JSON schema
{
"type": "object",
"required": [
"code",
"message"
],
"properties": {
"code": {
"description": "The error type that occurred.",
"type": "integer"
},
"data": {
"description": "Additional information about the error. The value of this member is defined by the sender (e.g. detailed error information, nested errors etc.)."
},
"message": {
"description": "A short description of the error. The message SHOULD be limited to a concise single sentence.",
"type": "string"
}
}
}Fields§
§code: i64The error type that occurred.
data: Option<Value>Additional information about the error. The value of this member is defined by the sender (e.g. detailed error information, nested errors etc.).
message: StringA short description of the error. The message SHOULD be limited to a concise single sentence.
Implementations§
Source§impl RpcError
impl RpcError
pub fn new( error_code: RpcErrorCodes, message: String, data: Option<Value>, ) -> Self
pub fn method_not_found() -> Self
pub fn invalid_params() -> Self
pub fn invalid_request() -> Self
pub fn internal_error() -> Self
pub fn parse_error() -> Self
pub fn with_message<T: Into<String>>(self, message: T) -> Self
pub fn with_data(self, data: Option<Value>) -> Self
Trait Implementations§
Source§impl<'de> Deserialize<'de> for RpcError
impl<'de> Deserialize<'de> for RpcError
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Error for RpcError
impl Error for RpcError
Source§fn description(&self) -> &str
fn description(&self) -> &str
👎Deprecated since 1.42.0:
use the Display impl or to_string()
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
Returns the lower-level source of this error, if any. Read more
Source§impl From<CallToolError> for RpcError
Converts a CallToolError into a RpcError.
impl From<CallToolError> for RpcError
Converts a CallToolError into a RpcError.
The conversion creates an internal error variant of RpcError
and attaches the string representation of the original CallToolError as a message.
Source§fn from(value: CallToolError) -> Self
fn from(value: CallToolError) -> Self
Converts to this type from the input type.
Source§impl From<MissingRequiredClientCapabilityError> for RpcError
impl From<MissingRequiredClientCapabilityError> for RpcError
Source§fn from(value: MissingRequiredClientCapabilityError) -> Self
fn from(value: MissingRequiredClientCapabilityError) -> Self
Converts to this type from the input type.
Source§impl From<RpcError> for MessageFromServer
impl From<RpcError> for MessageFromServer
Source§impl From<RpcError> for MessageFromClient
impl From<RpcError> for MessageFromClient
Source§impl From<UnsupportedProtocolVersionError> for RpcError
impl From<UnsupportedProtocolVersionError> for RpcError
Source§fn from(value: UnsupportedProtocolVersionError) -> Self
fn from(value: UnsupportedProtocolVersionError) -> Self
Converts to this type from the input type.
Auto Trait Implementations§
impl Freeze for RpcError
impl RefUnwindSafe for RpcError
impl Send for RpcError
impl Sync for RpcError
impl Unpin for RpcError
impl UnsafeUnpin for RpcError
impl UnwindSafe for RpcError
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more