Skip to content

Commit 18954db

Browse files
authored
refactor: deprecated auto-generated struct name JsonrpcErrorError (#65)
* chore: improve JsonrpcError * refactor: deprecated JsonRpcErrorError
1 parent c72d252 commit 18954db

File tree

7 files changed

+774
-916
lines changed

7 files changed

+774
-916
lines changed

examples/mcp_client_handle_message.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use rust_mcp_schema::schema_utils::*;
22
use rust_mcp_schema::*;
33
use std::str::FromStr;
44

5-
type AppError = JsonrpcErrorError;
5+
type AppError = RpcError;
66

77
const SAMPLE_PAYLOAD: &str = r#"
88
{

examples/mcp_server_handle_message.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use rust_mcp_schema::schema_utils::*;
22
use rust_mcp_schema::*;
33
use std::str::FromStr;
44

5-
type AppError = JsonrpcErrorError;
5+
type AppError = RpcError;
66

77
const SAMPLE_PAYLOAD: &str = r#"
88
{

src/generated_schema/2024_11_05/mcp_schema.rs

Lines changed: 42 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
///
77
/// Generated from : <https://github.com/modelcontextprotocol/specification.git>
88
/// Hash : 72516795d9a7aacdcf9b87624feb05229e10c950
9-
/// Generated at : 2025-04-03 19:11:35
9+
/// Generated at : 2025-04-04 20:01:25
1010
/// ----------------------------------------------------------------------------
1111
///
1212
/// MCP Protocol Version
@@ -2006,12 +2006,12 @@ pub struct InitializedNotificationParams {
20062006
/// </details>
20072007
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
20082008
pub struct JsonrpcError {
2009-
pub error: JsonrpcErrorError,
2009+
pub error: RpcError,
20102010
pub id: RequestId,
20112011
jsonrpc: ::std::string::String,
20122012
}
20132013
impl JsonrpcError {
2014-
pub fn new(error: JsonrpcErrorError, id: RequestId) -> Self {
2014+
pub fn new(error: RpcError, id: RequestId) -> Self {
20152015
Self {
20162016
error,
20172017
id,
@@ -2022,43 +2022,6 @@ impl JsonrpcError {
20222022
&self.jsonrpc
20232023
}
20242024
}
2025-
///JsonrpcErrorError
2026-
///
2027-
/// <details><summary>JSON schema</summary>
2028-
///
2029-
/// ```json
2030-
///{
2031-
/// "type": "object",
2032-
/// "required": [
2033-
/// "code",
2034-
/// "message"
2035-
/// ],
2036-
/// "properties": {
2037-
/// "code": {
2038-
/// "description": "The error type that occurred.",
2039-
/// "type": "integer"
2040-
/// },
2041-
/// "data": {
2042-
/// "description": "Additional information about the error. The value of this member is defined by the sender (e.g. detailed error information, nested errors etc.)."
2043-
/// },
2044-
/// "message": {
2045-
/// "description": "A short description of the error. The message SHOULD be limited to a concise single sentence.",
2046-
/// "type": "string"
2047-
/// }
2048-
/// }
2049-
///}
2050-
/// ```
2051-
/// </details>
2052-
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
2053-
pub struct JsonrpcErrorError {
2054-
///The error type that occurred.
2055-
pub code: i64,
2056-
///Additional information about the error. The value of this member is defined by the sender (e.g. detailed error information, nested errors etc.).
2057-
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
2058-
pub data: ::std::option::Option<::serde_json::Value>,
2059-
///A short description of the error. The message SHOULD be limited to a concise single sentence.
2060-
pub message: ::std::string::String,
2061-
}
20622025
///JsonrpcMessage
20632026
///
20642027
/// <details><summary>JSON schema</summary>
@@ -4757,6 +4720,43 @@ pub struct RootsListChangedNotificationParams {
47574720
#[serde(flatten, default, skip_serializing_if = "::std::option::Option::is_none")]
47584721
pub extra: ::std::option::Option<::serde_json::Map<::std::string::String, ::serde_json::Value>>,
47594722
}
4723+
///RpcError
4724+
///
4725+
/// <details><summary>JSON schema</summary>
4726+
///
4727+
/// ```json
4728+
///{
4729+
/// "type": "object",
4730+
/// "required": [
4731+
/// "code",
4732+
/// "message"
4733+
/// ],
4734+
/// "properties": {
4735+
/// "code": {
4736+
/// "description": "The error type that occurred.",
4737+
/// "type": "integer"
4738+
/// },
4739+
/// "data": {
4740+
/// "description": "Additional information about the error. The value of this member is defined by the sender (e.g. detailed error information, nested errors etc.)."
4741+
/// },
4742+
/// "message": {
4743+
/// "description": "A short description of the error. The message SHOULD be limited to a concise single sentence.",
4744+
/// "type": "string"
4745+
/// }
4746+
/// }
4747+
///}
4748+
/// ```
4749+
/// </details>
4750+
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
4751+
pub struct RpcError {
4752+
///The error type that occurred.
4753+
pub code: i64,
4754+
///Additional information about the error. The value of this member is defined by the sender (e.g. detailed error information, nested errors etc.).
4755+
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
4756+
pub data: ::std::option::Option<::serde_json::Value>,
4757+
///A short description of the error. The message SHOULD be limited to a concise single sentence.
4758+
pub message: ::std::string::String,
4759+
}
47604760
///Describes a message issued to or received from an LLM API.
47614761
///
47624762
/// <details><summary>JSON schema</summary>
@@ -6018,3 +6018,5 @@ impl ServerNotification {
60186018
}
60196019
}
60206020
}
6021+
#[deprecated(since = "0.3.0", note = "Use `RpcError` instead.")]
6022+
pub type JsonrpcErrorError = RpcError;

0 commit comments

Comments
 (0)