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
45 changes: 30 additions & 15 deletions crates/rmcp/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -65,37 +65,41 @@ server = ["transport-async-rw", "dep:schemars"]
macros = ["dep:rmcp-macros", "dep:paste"]

# reqwest http client
reqwest = ["dep:reqwest"]
__reqwest = ["dep:reqwest"]

reqwest = ["__reqwest", "reqwest?/rustls-tls"]

reqwest-tls-no-provider = ["__reqwest", "reqwest?/rustls-tls-no-provider"]

axum = ["dep:axum"]
# SSE client
client-side-sse = ["dep:sse-stream"]

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

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

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

# Streamable HTTP client
__transport-streamable-http-client = ["reqwest", "client-side-sse", "transport-worker", "dep:url"]
transport-streamable-http-client = ["__transport-streamable-http-client", "reqwest?/rustls-tls"]
transport-streamable-http-client-tls-no-provider = ["__transport-streamable-http-client", "reqwest?/rustls-tls-no-provider"]
transport-streamable-http-client = [
"client-side-sse",
"transport-worker",
]


transport-async-rw = ["tokio/io-util", "tokio-util/codec"]
transport-io = ["transport-async-rw", "tokio/io-std"]
transport-child-process = ["transport-async-rw", "tokio/process"]
transport-sse-server = [
"transport-async-rw",
"dep:axum",
"axum",
"dep:rand",
"dep:tokio-stream",
"uuid",
]
transport-streamable-http-server = [
"transport-streamable-http-server-session",
"dep:axum",
"axum",
"uuid",
]
transport-streamable-http-server-session = [
Expand All @@ -104,9 +108,7 @@ transport-streamable-http-server-session = [
]
# transport-ws = ["transport-io", "dep:tokio-tungstenite"]
tower = ["dep:tower-service"]
__auth = ["dep:oauth2", "dep:reqwest", "dep:url"]
auth = ["__auth", "reqwest?/rustls-tls"]
auth-tls-no-provider = ["auth", "reqwest?/rustls-tls-no-provider"]
auth = ["dep:oauth2", "__reqwest", "dep:url"]
schemars = ["dep:schemars"]

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

[[test]]
name = "test_with_python"
required-features = ["server", "client", "transport-sse-server", "transport-sse", "transport-child-process"]
required-features = [
"server",
"client",
"transport-sse-server",
"transport-sse-client",
"transport-child-process",
]
path = "tests/test_with_python.rs"

[[test]]
name = "test_with_js"
required-features = ["server", "client", "transport-sse-server", "transport-child-process", "transport-streamable-http-server", "transport-streamable-http-client"]
required-features = [
"server",
"client",
"transport-sse-server",
"transport-child-process",
"transport-streamable-http-server",
"transport-streamable-http-client",
"__reqwest",
]
path = "tests/test_with_js.rs"

[[test]]
Expand All @@ -154,4 +170,3 @@ path = "tests/test_message_protocol.rs"
name = "test_message_schema"
required-features = ["server", "client", "schemars"]
path = "tests/test_message_schema.rs"

26 changes: 13 additions & 13 deletions crates/rmcp/src/transport.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,11 @@ pub mod io;
#[cfg_attr(docsrs, doc(cfg(feature = "transport-io")))]
pub use io::stdio;

#[cfg(feature = "__transport-sse")]
#[cfg_attr(docsrs, doc(cfg(feature = "__transport-sse")))]
#[cfg(feature = "transport-sse-client")]
#[cfg_attr(docsrs, doc(cfg(feature = "transport-sse-client")))]
pub mod sse_client;
#[cfg(feature = "__transport-sse")]
#[cfg_attr(docsrs, doc(cfg(feature = "__transport-sse")))]
#[cfg(feature = "transport-sse-client")]
#[cfg_attr(docsrs, doc(cfg(feature = "transport-sse-client")))]
pub use sse_client::SseClientTransport;

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

#[cfg(feature = "__auth")]
#[cfg_attr(docsrs, doc(cfg(feature = "__auth")))]
#[cfg(feature = "auth")]
#[cfg_attr(docsrs, doc(cfg(feature = "auth")))]
pub mod auth;
#[cfg(feature = "__auth")]
#[cfg_attr(docsrs, doc(cfg(feature = "__auth")))]
#[cfg(feature = "auth")]
#[cfg_attr(docsrs, doc(cfg(feature = "auth")))]
pub use auth::{AuthError, AuthorizationManager, AuthorizationSession, AuthorizedHttpClient};

// #[cfg(feature = "transport-ws")]
#[cfg_attr(docsrs, doc(cfg(feature = "transport-ws")))]
// #[cfg_attr(docsrs, doc(cfg(feature = "transport-ws")))]
// pub mod ws;
#[cfg(feature = "transport-streamable-http-server-session")]
#[cfg_attr(docsrs, doc(cfg(feature = "transport-streamable-http-server-session")))]
Expand All @@ -124,11 +124,11 @@ pub mod streamable_http_server;
#[cfg_attr(docsrs, doc(cfg(feature = "transport-streamable-http-server")))]
pub use streamable_http_server::axum::StreamableHttpServer;

#[cfg(feature = "__transport-streamable-http-client")]
#[cfg_attr(docsrs, doc(cfg(feature = "__transport-streamable-http-client")))]
#[cfg(feature = "transport-streamable-http-client")]
#[cfg_attr(docsrs, doc(cfg(feature = "transport-streamable-http-client")))]
pub mod streamable_http_client;
#[cfg(feature = "__transport-streamable-http-client")]
#[cfg_attr(docsrs, doc(cfg(feature = "__transport-streamable-http-client")))]
#[cfg(feature = "transport-streamable-http-client")]
#[cfg_attr(docsrs, doc(cfg(feature = "transport-streamable-http-client")))]
pub use streamable_http_client::StreamableHttpClientTransport;

/// Common use codes
Expand Down
2 changes: 1 addition & 1 deletion crates/rmcp/src/transport/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ pub mod axum;

pub mod http_header;

#[cfg(feature = "reqwest")]
#[cfg(feature = "__reqwest")]
Copy link

Copilot AI May 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The doc(cfg(...)) annotation references feature = "reqwest" but the guard uses __reqwest, causing a mismatch in generated docs; align the documented feature name with the actual flag.

Suggested change
#[cfg(feature = "__reqwest")]
#[cfg(feature = "reqwest")]

Copilot uses AI. Check for mistakes.
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be bad looking to see an internal feature "__reqwest" in the document.

#[cfg_attr(docsrs, doc(cfg(feature = "reqwest")))]
mod reqwest;

Expand Down
8 changes: 4 additions & 4 deletions crates/rmcp/src/transport/common/auth.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#[cfg(feature = "__transport-streamable-http-client")]
#[cfg_attr(docsrs, doc(cfg(feature = "__transport-streamable-http-client")))]
#[cfg(feature = "transport-streamable-http-client")]
#[cfg_attr(docsrs, doc(cfg(feature = "transport-streamable-http-client")))]
mod streamable_http_client;

#[cfg(feature = "__transport-sse")]
#[cfg_attr(docsrs, doc(cfg(feature = "__transport-sse")))]
#[cfg(feature = "transport-sse-client")]
#[cfg_attr(docsrs, doc(cfg(feature = "transport-sse-client")))]
mod sse_client;
8 changes: 4 additions & 4 deletions crates/rmcp/src/transport/common/reqwest.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#[cfg(feature = "__transport-streamable-http-client")]
#[cfg_attr(docsrs, doc(cfg(feature = "__transport-streamable-http-client")))]
#[cfg(feature = "transport-streamable-http-client")]
#[cfg_attr(docsrs, doc(cfg(feature = "transport-streamable-http-client")))]
mod streamable_http_client;

#[cfg(feature = "__transport-sse")]
#[cfg_attr(docsrs, doc(cfg(feature = "__transport-sse")))]
#[cfg(feature = "transport-sse-client")]
#[cfg_attr(docsrs, doc(cfg(feature = "transport-sse-client")))]
mod sse_client;
10 changes: 2 additions & 8 deletions crates/rmcp/src/transport/sse_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,10 @@ pub enum SseTransportError<E: std::error::Error + Send + Sync + 'static> {
Client(E),
#[error("unexpected end of stream")]
UnexpectedEndOfStream,
#[error("Url error: {0}")]
Url(#[from] url::ParseError),
#[error("Unexpected content type: {0:?}")]
UnexpectedContentType(Option<HeaderValue>),
#[error("Tokio join error: {0}")]
TokioJoinError(#[from] tokio::task::JoinError),
#[error("Transport terminated")]
TransportTerminated,
#[cfg(feature = "__auth")]
#[cfg_attr(docsrs, doc(cfg(feature = "__auth")))]
#[cfg(feature = "auth")]
#[cfg_attr(docsrs, doc(cfg(feature = "auth")))]
#[error("Auth error: {0}")]
Auth(#[from] crate::transport::auth::AuthError),
}
Expand Down
4 changes: 2 additions & 2 deletions crates/rmcp/src/transport/streamable_http_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ pub enum StreamableHttpError<E: std::error::Error + Send + Sync + 'static> {
Deserialize(#[from] serde_json::Error),
#[error("Transport channel closed")]
TransportChannelClosed,
#[cfg(feature = "__auth")]
#[cfg_attr(docsrs, doc(cfg(feature = "__auth")))]
#[cfg(feature = "auth")]
#[cfg_attr(docsrs, doc(cfg(feature = "auth")))]
#[error("Auth error: {0}")]
Auth(#[from] crate::transport::auth::AuthError),
}
Expand Down
2 changes: 1 addition & 1 deletion docs/OAUTH_SUPPORT.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Enable the auth feature in Cargo.toml:

```toml
[dependencies]
rmcp = { version = "0.1", features = ["auth", "transport-sse"] }
rmcp = { version = "0.1", features = ["auth", "transport-sse-client"] }
```

### 2. Use OAuthState
Expand Down
3 changes: 2 additions & 1 deletion examples/clients/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ publish = false
[dependencies]
rmcp = { path = "../../crates/rmcp", features = [
"client",
"transport-sse",
"transport-sse-client",
"reqwest",
"transport-streamable-http-client",
"transport-child-process",
"tower",
Expand Down
2 changes: 1 addition & 1 deletion examples/rig-integration/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ tokio = { version = "1", features = ["full"] }
rmcp = { path = "../../crates/rmcp", features = [
"client",
"transport-child-process",
"transport-sse",
"transport-sse-client",
] }
anyhow = "1.0"
serde_json = "1"
Expand Down
9 changes: 5 additions & 4 deletions examples/simple-chat-client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,16 @@ edition = "2021"
tokio = { version = "1", features = ["full"] }
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
reqwest = { version = "0.11", features = ["json"] }
reqwest = { version = "0.12", features = ["json"] }
anyhow = "1.0"
thiserror = "1.0"
async-trait = "0.1"
futures = "0.3"
toml = "0.8"
rmcp = { git = "https://github.com/modelcontextprotocol/rust-sdk", features = [
rmcp = { workspace = true, features = [
"client",
"transport-child-process",
"transport-sse",
"transport-sse-client",
"reqwest"
], no-default-features = true }
clap = { version = "4.0", features = ["derive"] }
clap = { version = "4.0", features = ["derive"] }
3 changes: 2 additions & 1 deletion examples/simple-chat-client/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ impl McpServerTransportConfig {
pub async fn start(&self) -> Result<RunningService<RoleClient, ()>> {
let client = match self {
McpServerTransportConfig::Sse { url } => {
let transport = rmcp::transport::sse::SseTransport::start(url).await?;
let transport =
rmcp::transport::sse_client::SseClientTransport::start(url.to_owned()).await?;
().serve(transport).await?
}
McpServerTransportConfig::Stdio {
Expand Down
Loading