feat(transport): support streamable http server (#152)

* feat(transport): support streamable http server

* refactor(transport): add common module for shared transport utilities

* perf(tracing): add more log for streamable http session

* fix(test): fix port conflict in test with js

* fix(transport): fix id generating and session management

1. cancel when deleting
2. use `wrapping` and `saturating` correctly

* chore(naming): rename sse server to streamable http server
This commit is contained in:
4t145 2025-05-08 13:57:51 +08:00 • committed by GitHub
commit 57e14c56e8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -0,0 +1,29 @@
use rmcp::transport::streamable_http_server::axum::StreamableHttpServer;
use tracing_subscriber::{
layer::SubscriberExt,
util::SubscriberInitExt,
{self},
};
mod common;
use common::counter::Counter;
const BIND_ADDRESS: &str = "127.0.0.1:8000";
#[tokio::main]
async fn main() -> anyhow::Result<()> {
tracing_subscriber::registry()
.with(
tracing_subscriber::EnvFilter::try_from_default_env()
.unwrap_or_else(|_| "debug".to_string().into()),
)
.with(tracing_subscriber::fmt::layer())
.init();
let ct = StreamableHttpServer::serve(BIND_ADDRESS.parse()?)
.await?
.with_service(Counter::new);
tokio::signal::ctrl_c().await?;
ct.cancel();
Ok(())
}