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
6 changes: 6 additions & 0 deletions crates/rust-mcp-sdk/src/hyper_servers/hyper_runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,12 @@ impl HyperRuntime {
result.map_err(|err| err.into())
}

/// Returns a list of active session IDs from the session store.
pub async fn sessions(&self) -> Vec<String> {
self.state.session_store.keys().await
}

/// Retrieves the runtime associated with the given session ID from the session store.
pub async fn runtime_by_session(
&self,
session_id: &SessionId,
Expand Down
5 changes: 1 addition & 4 deletions crates/rust-mcp-sdk/src/hyper_servers/routes/hyper_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,10 +172,7 @@ pub async fn start_new_session(
session_id.to_owned(),
));

tracing::info!(
"a new client joined : {}",
runtime.session_id().await.unwrap_or_default().to_owned()
);
tracing::info!("a new client joined : {}", &session_id);

let response = create_sse_stream(
runtime.clone(),
Expand Down
10 changes: 5 additions & 5 deletions crates/rust-mcp-sdk/src/mcp_runtimes/server_runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,11 @@ impl McpServer for ServerRuntime {
}
Ok(())
}

#[cfg(feature = "hyper-server")]
fn session_id(&self) -> Option<SessionId> {
self.session_id.to_owned()
}
}

impl ServerRuntime {
Expand Down Expand Up @@ -435,11 +440,6 @@ impl ServerRuntime {
}
}

#[cfg(feature = "hyper-server")]
pub(crate) async fn session_id(&self) -> Option<SessionId> {
self.session_id.to_owned()
}

#[cfg(feature = "hyper-server")]
pub(crate) fn new_instance(
server_details: Arc<InitializeResult>,
Expand Down
7 changes: 5 additions & 2 deletions crates/rust-mcp-sdk/src/mcp_traits/mcp_server.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
use std::time::Duration;

use crate::schema::{
schema_utils::{
ClientMessage, McpMessage, MessageFromServer, NotificationFromServer, RequestFromServer,
Expand All @@ -16,6 +14,8 @@ use crate::schema::{
SetLevelRequest, ToolListChangedNotification, ToolListChangedNotificationParams,
};
use async_trait::async_trait;
use rust_mcp_transport::SessionId;
use std::time::Duration;

use crate::{error::SdkResult, utils::format_assertion_message};

Expand Down Expand Up @@ -405,4 +405,7 @@ pub trait McpServer: Sync + Send {
}
Ok(())
}

#[cfg(feature = "hyper-server")]
fn session_id(&self) -> Option<SessionId>;
}
Loading