Skip to content

Commit 5e4e77e

Browse files
authored
refactor: fix error introduced by merge, and reorganize feature (#185)
1 parent 9a771fb commit 5e4e77e

File tree

12 files changed

+67
-55
lines changed

12 files changed

+67
-55
lines changed

crates/rmcp/Cargo.toml

Lines changed: 30 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -65,37 +65,41 @@ server = ["transport-async-rw", "dep:schemars"]
6565
macros = ["dep:rmcp-macros", "dep:paste"]
6666

6767
# reqwest http client
68-
reqwest = ["dep:reqwest"]
68+
__reqwest = ["dep:reqwest"]
6969

70+
reqwest = ["__reqwest", "reqwest?/rustls-tls"]
71+
72+
reqwest-tls-no-provider = ["__reqwest", "reqwest?/rustls-tls-no-provider"]
73+
74+
axum = ["dep:axum"]
7075
# SSE client
7176
client-side-sse = ["dep:sse-stream"]
7277

73-
__transport-sse = ["reqwest", "client-side-sse", "dep:url", "transport-worker"]
78+
transport-sse-client = ["client-side-sse", "transport-worker"]
7479

7580
transport-worker = ["dep:tokio-stream"]
7681

77-
transport-sse = ["__transport-sse", "reqwest?/rustls-tls"]
78-
transport-sse-tls-no-provider = ["__transport-sse", "reqwest?/rustls-tls-no-provider"]
7982

8083
# Streamable HTTP client
81-
__transport-streamable-http-client = ["reqwest", "client-side-sse", "transport-worker", "dep:url"]
82-
transport-streamable-http-client = ["__transport-streamable-http-client", "reqwest?/rustls-tls"]
83-
transport-streamable-http-client-tls-no-provider = ["__transport-streamable-http-client", "reqwest?/rustls-tls-no-provider"]
84+
transport-streamable-http-client = [
85+
"client-side-sse",
86+
"transport-worker",
87+
]
8488

8589

8690
transport-async-rw = ["tokio/io-util", "tokio-util/codec"]
8791
transport-io = ["transport-async-rw", "tokio/io-std"]
8892
transport-child-process = ["transport-async-rw", "tokio/process"]
8993
transport-sse-server = [
9094
"transport-async-rw",
91-
"dep:axum",
95+
"axum",
9296
"dep:rand",
9397
"dep:tokio-stream",
9498
"uuid",
9599
]
96100
transport-streamable-http-server = [
97101
"transport-streamable-http-server-session",
98-
"dep:axum",
102+
"axum",
99103
"uuid",
100104
]
101105
transport-streamable-http-server-session = [
@@ -104,9 +108,7 @@ transport-streamable-http-server-session = [
104108
]
105109
# transport-ws = ["transport-io", "dep:tokio-tungstenite"]
106110
tower = ["dep:tower-service"]
107-
__auth = ["dep:oauth2", "dep:reqwest", "dep:url"]
108-
auth = ["__auth", "reqwest?/rustls-tls"]
109-
auth-tls-no-provider = ["auth", "reqwest?/rustls-tls-no-provider"]
111+
auth = ["dep:oauth2", "__reqwest", "dep:url"]
110112
schemars = ["dep:schemars"]
111113

112114
[dev-dependencies]
@@ -127,12 +129,26 @@ path = "tests/test_tool_macros.rs"
127129

128130
[[test]]
129131
name = "test_with_python"
130-
required-features = ["server", "client", "transport-sse-server", "transport-sse", "transport-child-process"]
132+
required-features = [
133+
"server",
134+
"client",
135+
"transport-sse-server",
136+
"transport-sse-client",
137+
"transport-child-process",
138+
]
131139
path = "tests/test_with_python.rs"
132140

133141
[[test]]
134142
name = "test_with_js"
135-
required-features = ["server", "client", "transport-sse-server", "transport-child-process", "transport-streamable-http-server", "transport-streamable-http-client"]
143+
required-features = [
144+
"server",
145+
"client",
146+
"transport-sse-server",
147+
"transport-child-process",
148+
"transport-streamable-http-server",
149+
"transport-streamable-http-client",
150+
"__reqwest",
151+
]
136152
path = "tests/test_with_js.rs"
137153

138154
[[test]]
@@ -154,4 +170,3 @@ path = "tests/test_message_protocol.rs"
154170
name = "test_message_schema"
155171
required-features = ["server", "client", "schemars"]
156172
path = "tests/test_message_schema.rs"
157-

crates/rmcp/src/transport.rs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -93,11 +93,11 @@ pub mod io;
9393
#[cfg_attr(docsrs, doc(cfg(feature = "transport-io")))]
9494
pub use io::stdio;
9595

96-
#[cfg(feature = "__transport-sse")]
97-
#[cfg_attr(docsrs, doc(cfg(feature = "__transport-sse")))]
96+
#[cfg(feature = "transport-sse-client")]
97+
#[cfg_attr(docsrs, doc(cfg(feature = "transport-sse-client")))]
9898
pub mod sse_client;
99-
#[cfg(feature = "__transport-sse")]
100-
#[cfg_attr(docsrs, doc(cfg(feature = "__transport-sse")))]
99+
#[cfg(feature = "transport-sse-client")]
100+
#[cfg_attr(docsrs, doc(cfg(feature = "transport-sse-client")))]
101101
pub use sse_client::SseClientTransport;
102102

103103
#[cfg(feature = "transport-sse-server")]
@@ -107,15 +107,15 @@ pub mod sse_server;
107107
#[cfg_attr(docsrs, doc(cfg(feature = "transport-sse-server")))]
108108
pub use sse_server::SseServer;
109109

110-
#[cfg(feature = "__auth")]
111-
#[cfg_attr(docsrs, doc(cfg(feature = "__auth")))]
110+
#[cfg(feature = "auth")]
111+
#[cfg_attr(docsrs, doc(cfg(feature = "auth")))]
112112
pub mod auth;
113-
#[cfg(feature = "__auth")]
114-
#[cfg_attr(docsrs, doc(cfg(feature = "__auth")))]
113+
#[cfg(feature = "auth")]
114+
#[cfg_attr(docsrs, doc(cfg(feature = "auth")))]
115115
pub use auth::{AuthError, AuthorizationManager, AuthorizationSession, AuthorizedHttpClient};
116116

117117
// #[cfg(feature = "transport-ws")]
118-
#[cfg_attr(docsrs, doc(cfg(feature = "transport-ws")))]
118+
// #[cfg_attr(docsrs, doc(cfg(feature = "transport-ws")))]
119119
// pub mod ws;
120120
#[cfg(feature = "transport-streamable-http-server-session")]
121121
#[cfg_attr(docsrs, doc(cfg(feature = "transport-streamable-http-server-session")))]
@@ -124,11 +124,11 @@ pub mod streamable_http_server;
124124
#[cfg_attr(docsrs, doc(cfg(feature = "transport-streamable-http-server")))]
125125
pub use streamable_http_server::axum::StreamableHttpServer;
126126

127-
#[cfg(feature = "__transport-streamable-http-client")]
128-
#[cfg_attr(docsrs, doc(cfg(feature = "__transport-streamable-http-client")))]
127+
#[cfg(feature = "transport-streamable-http-client")]
128+
#[cfg_attr(docsrs, doc(cfg(feature = "transport-streamable-http-client")))]
129129
pub mod streamable_http_client;
130-
#[cfg(feature = "__transport-streamable-http-client")]
131-
#[cfg_attr(docsrs, doc(cfg(feature = "__transport-streamable-http-client")))]
130+
#[cfg(feature = "transport-streamable-http-client")]
131+
#[cfg_attr(docsrs, doc(cfg(feature = "transport-streamable-http-client")))]
132132
pub use streamable_http_client::StreamableHttpClientTransport;
133133

134134
/// Common use codes

crates/rmcp/src/transport/common.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ pub mod axum;
66

77
pub mod http_header;
88

9-
#[cfg(feature = "reqwest")]
9+
#[cfg(feature = "__reqwest")]
1010
#[cfg_attr(docsrs, doc(cfg(feature = "reqwest")))]
1111
mod reqwest;
1212

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
#[cfg(feature = "__transport-streamable-http-client")]
2-
#[cfg_attr(docsrs, doc(cfg(feature = "__transport-streamable-http-client")))]
1+
#[cfg(feature = "transport-streamable-http-client")]
2+
#[cfg_attr(docsrs, doc(cfg(feature = "transport-streamable-http-client")))]
33
mod streamable_http_client;
44

5-
#[cfg(feature = "__transport-sse")]
6-
#[cfg_attr(docsrs, doc(cfg(feature = "__transport-sse")))]
5+
#[cfg(feature = "transport-sse-client")]
6+
#[cfg_attr(docsrs, doc(cfg(feature = "transport-sse-client")))]
77
mod sse_client;
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
#[cfg(feature = "__transport-streamable-http-client")]
2-
#[cfg_attr(docsrs, doc(cfg(feature = "__transport-streamable-http-client")))]
1+
#[cfg(feature = "transport-streamable-http-client")]
2+
#[cfg_attr(docsrs, doc(cfg(feature = "transport-streamable-http-client")))]
33
mod streamable_http_client;
44

5-
#[cfg(feature = "__transport-sse")]
6-
#[cfg_attr(docsrs, doc(cfg(feature = "__transport-sse")))]
5+
#[cfg(feature = "transport-sse-client")]
6+
#[cfg_attr(docsrs, doc(cfg(feature = "transport-sse-client")))]
77
mod sse_client;

crates/rmcp/src/transport/sse_client.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,10 @@ pub enum SseTransportError<E: std::error::Error + Send + Sync + 'static> {
2626
Client(E),
2727
#[error("unexpected end of stream")]
2828
UnexpectedEndOfStream,
29-
#[error("Url error: {0}")]
30-
Url(#[from] url::ParseError),
3129
#[error("Unexpected content type: {0:?}")]
3230
UnexpectedContentType(Option<HeaderValue>),
33-
#[error("Tokio join error: {0}")]
34-
TokioJoinError(#[from] tokio::task::JoinError),
35-
#[error("Transport terminated")]
36-
TransportTerminated,
37-
#[cfg(feature = "__auth")]
38-
#[cfg_attr(docsrs, doc(cfg(feature = "__auth")))]
31+
#[cfg(feature = "auth")]
32+
#[cfg_attr(docsrs, doc(cfg(feature = "auth")))]
3933
#[error("Auth error: {0}")]
4034
Auth(#[from] crate::transport::auth::AuthError),
4135
}

crates/rmcp/src/transport/streamable_http_client.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ pub enum StreamableHttpError<E: std::error::Error + Send + Sync + 'static> {
4242
Deserialize(#[from] serde_json::Error),
4343
#[error("Transport channel closed")]
4444
TransportChannelClosed,
45-
#[cfg(feature = "__auth")]
46-
#[cfg_attr(docsrs, doc(cfg(feature = "__auth")))]
45+
#[cfg(feature = "auth")]
46+
#[cfg_attr(docsrs, doc(cfg(feature = "auth")))]
4747
#[error("Auth error: {0}")]
4848
Auth(#[from] crate::transport::auth::AuthError),
4949
}

docs/OAUTH_SUPPORT.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Enable the auth feature in Cargo.toml:
1919

2020
```toml
2121
[dependencies]
22-
rmcp = { version = "0.1", features = ["auth", "transport-sse"] }
22+
rmcp = { version = "0.1", features = ["auth", "transport-sse-client"] }
2323
```
2424

2525
### 2. Use OAuthState

examples/clients/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ publish = false
99
[dependencies]
1010
rmcp = { path = "../../crates/rmcp", features = [
1111
"client",
12-
"transport-sse",
12+
"transport-sse-client",
13+
"reqwest",
1314
"transport-streamable-http-client",
1415
"transport-child-process",
1516
"tower",

examples/rig-integration/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ tokio = { version = "1", features = ["full"] }
1717
rmcp = { path = "../../crates/rmcp", features = [
1818
"client",
1919
"transport-child-process",
20-
"transport-sse",
20+
"transport-sse-client",
2121
] }
2222
anyhow = "1.0"
2323
serde_json = "1"

0 commit comments

Comments
 (0)