feat!: remove SSE transport support (#562)

SSE transport has been removed from the MCP specification in favor of
streamable HTTP. This removes all SSE-specific transport code:

- Remove `transport-sse-client` and `transport-sse-server` features
- Remove `SseClientTransport` and `SseServer` types
- Remove SSE-specific examples (`counter_sse`, `counter_sse_directly`)
- Migrate auth examples from SSE to streamable HTTP
- Update tests to remove SSE transport usage
- Update documentation

BREAKING CHANGE: The following have been removed:
- `transport-sse-client` feature
- `transport-sse-client-reqwest` feature
- `transport-sse-server` feature
- `SseClientTransport` type
- `SseServer` type
- `sse_client` and `sse_server` modules

Users should migrate to streamable HTTP transport which provides
equivalent functionality. See `StreamableHttpClientTransport` and
`StreamableHttpService` for the replacement APIs.

Ref: https://github.com/modelcontextprotocol/rust-sdk/pull/561#issuecomment-3576551699
This commit is contained in:
adam jones 2025-12-02 01:40:13 +00:00 • committed by GitHub
commit eb5a7f7408
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 164 additions and 1688 deletions

View file

@ -2,7 +2,7 @@ use rmcp::{
ServiceExt,
service::QuitReason,
transport::{
ConfigureCommandExt, SseServer, StreamableHttpClientTransport, StreamableHttpServerConfig,
ConfigureCommandExt, StreamableHttpClientTransport, StreamableHttpServerConfig,
TokioChildProcess,
streamable_http_server::{
session::local::LocalSessionManager, tower::StreamableHttpService,
@ -14,42 +14,11 @@ use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt};
mod common;
use common::calculator::Calculator;
const SSE_BIND_ADDRESS: &str = "127.0.0.1:8000";
const STREAMABLE_HTTP_BIND_ADDRESS: &str = "127.0.0.1:8001";
const STREAMABLE_HTTP_JS_BIND_ADDRESS: &str = "127.0.0.1:8002";
#[tokio::test]
async fn test_with_js_client() -> anyhow::Result<()> {
let _ = tracing_subscriber::registry()
.with(
tracing_subscriber::EnvFilter::try_from_default_env()
.unwrap_or_else(|_| "debug".to_string().into()),
)
.with(tracing_subscriber::fmt::layer())
.try_init();
tokio::process::Command::new("npm")
.arg("install")
.current_dir("tests/test_with_js")
.spawn()?
.wait()
.await?;
let ct = SseServer::serve(SSE_BIND_ADDRESS.parse()?)
.await?
.with_service(Calculator::default);
let exit_status = tokio::process::Command::new("node")
.arg("tests/test_with_js/client.js")
.spawn()?
.wait()
.await?;
assert!(exit_status.success());
ct.cancel();
Ok(())
}
#[tokio::test]
async fn test_with_js_server() -> anyhow::Result<()> {
async fn test_with_js_stdio_server() -> anyhow::Result<()> {
let _ = tracing_subscriber::registry()
.with(
tracing_subscriber::EnvFilter::try_from_default_env()

View file

@ -1,15 +1,12 @@
use std::process::Stdio;
use axum::Router;
use rmcp::{
ServiceExt,
transport::{ConfigureCommandExt, SseServer, TokioChildProcess, sse_server::SseServerConfig},
transport::{ConfigureCommandExt, TokioChildProcess},
};
use tokio::{io::AsyncReadExt, time::timeout};
use tokio_util::sync::CancellationToken;
use tokio::io::AsyncReadExt;
use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt};
mod common;
use common::calculator::Calculator;
async fn init() -> anyhow::Result<()> {
let _ = tracing_subscriber::registry()
@ -28,81 +25,6 @@ async fn init() -> anyhow::Result<()> {
Ok(())
}
#[tokio::test]
async fn test_with_python_client() -> anyhow::Result<()> {
init().await?;
const BIND_ADDRESS: &str = "127.0.0.1:8000";
let ct = SseServer::serve(BIND_ADDRESS.parse()?)
.await?
.with_service(Calculator::default);
let status = tokio::process::Command::new("uv")
.arg("run")
.arg("client.py")
.arg(format!("http://{BIND_ADDRESS}/sse"))
.current_dir("tests/test_with_python")
.spawn()?
.wait()
.await?;
assert!(status.success());
ct.cancel();
Ok(())
}
/// Test the SSE server in a nested Axum router.
#[tokio::test]
async fn test_nested_with_python_client() -> anyhow::Result<()> {
init().await?;
const BIND_ADDRESS: &str = "127.0.0.1:8001";
// Create an SSE router
let sse_config = SseServerConfig {
bind: BIND_ADDRESS.parse()?,
sse_path: "/sse".to_string(),
post_path: "/message".to_string(),
ct: CancellationToken::new(),
sse_keep_alive: None,
};
let listener = tokio::net::TcpListener::bind(&sse_config.bind).await?;
let (sse_server, sse_router) = SseServer::new(sse_config);
let ct = sse_server.with_service(Calculator::default);
let main_router = Router::new().nest("/nested", sse_router);
let server_ct = ct.clone();
let server = axum::serve(listener, main_router).with_graceful_shutdown(async move {
server_ct.cancelled().await;
tracing::info!("sse server cancelled");
});
tokio::spawn(async move {
let _ = server.await;
tracing::info!("sse server shutting down");
});
// Spawn the process with timeout, as failure to access the '/message' URL
// causes the client to never exit.
let status = timeout(
tokio::time::Duration::from_secs(5),
tokio::process::Command::new("uv")
.arg("run")
.arg("client.py")
.arg(format!("http://{BIND_ADDRESS}/nested/sse"))
.current_dir("tests/test_with_python")
.spawn()?
.wait(),
)
.await?;
assert!(status?.success());
ct.cancel();
Ok(())
}
#[tokio::test]
async fn test_with_python_server() -> anyhow::Result<()> {
init().await?;