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
4 changes: 4 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 7 additions & 3 deletions crates/rust-mcp-sdk/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,13 @@ tokio-stream = { workspace = true, optional = true }
axum-server = { version = "0.7", features = [], optional = true }
tracing.workspace = true
base64.workspace = true
bytes.workspace = true

# rustls = { workspace = true, optional = true }
hyper = { version = "1.6.0", optional = true }
http = { version ="1.3", optional = true }
http-body-util = { version ="0.1", optional = true }
http-body = { version ="1.0", optional = true }

[dev-dependencies]
wiremock = "0.5"
Expand Down Expand Up @@ -61,13 +65,13 @@ default = [
"2025_06_18",
] # All features enabled by default

sse = ["rust-mcp-transport/sse"]
streamable-http = ["rust-mcp-transport/streamable-http"]
sse = ["rust-mcp-transport/sse","http","http-body","http-body-util"]
streamable-http = ["rust-mcp-transport/streamable-http","http","http-body","http-body-util"]
stdio = ["rust-mcp-transport/stdio"]

server = [] # Server feature
client = [] # Client feature
hyper-server = ["axum", "axum-server", "hyper", "server", "tokio-stream"]
hyper-server = ["axum", "axum-server", "hyper", "server", "tokio-stream","http","http-body","http-body-util"]
ssl = ["axum-server/tls-rustls"]
tls-no-provider = ["axum-server/tls-rustls-no-provider"]
macros = ["rust-mcp-macros/sdk"]
Expand Down
4 changes: 0 additions & 4 deletions crates/rust-mcp-sdk/src/hyper_servers.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
mod app_state;
pub mod error;
pub mod hyper_runtime;
pub mod hyper_server;
pub mod hyper_server_core;
mod middlewares;
mod routes;
mod server;
mod session_store;

pub use server::*;
pub use session_store::*;
2 changes: 2 additions & 0 deletions crates/rust-mcp-sdk/src/hyper_servers/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ pub enum TransportServerError {
StreamIoError(String),
#[error("{0}")]
AddrParseError(#[from] AddrParseError),
#[error("{0}")]
HttpError(String),
#[error("Server start error: {0}")]
ServerStartError(String),
#[error("Invalid options: {0}")]
Expand Down
4 changes: 2 additions & 2 deletions crates/rust-mcp-sdk/src/hyper_servers/hyper_runtime.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use std::{sync::Arc, time::Duration};

use crate::{
mcp_http::McpAppState,
mcp_server::HyperServer,
schema::{
schema_utils::{NotificationFromServer, RequestFromServer, ResultFromClient},
Expand All @@ -18,15 +19,14 @@ use tokio::{sync::Mutex, task::JoinHandle};

use crate::{
error::SdkResult,
hyper_servers::app_state::AppState,
mcp_server::{
error::{TransportServerError, TransportServerResult},
ServerRuntime,
},
};

pub struct HyperRuntime {
pub(crate) state: Arc<AppState>,
pub(crate) state: Arc<McpAppState>,
pub(crate) server_task: JoinHandle<Result<(), TransportServerError>>,
pub(crate) server_handle: Handle,
}
Expand Down
2 changes: 0 additions & 2 deletions crates/rust-mcp-sdk/src/hyper_servers/middlewares.rs

This file was deleted.

This file was deleted.

This file was deleted.

16 changes: 10 additions & 6 deletions crates/rust-mcp-sdk/src/hyper_servers/routes.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
pub mod fallback_routes;
mod hyper_utils;
pub mod messages_routes;
#[cfg(feature = "sse")]
pub mod sse_routes;
pub mod streamable_http_routes;

use super::{app_state::AppState, HyperServerOptions};
use crate::mcp_http::McpAppState;

use super::HyperServerOptions;
use axum::Router;
use std::sync::Arc;

Expand All @@ -19,21 +21,23 @@ use std::sync::Arc;
///
/// # Returns
/// * `Router` - An Axum router configured with all application routes and state
pub fn app_routes(state: Arc<AppState>, server_options: &HyperServerOptions) -> Router {
pub fn app_routes(state: Arc<McpAppState>, server_options: &HyperServerOptions) -> Router {
let router: Router = Router::new()
.merge(streamable_http_routes::routes(
state.clone(),
server_options.streamable_http_endpoint(),
))
.merge({
let mut r = Router::new();
#[cfg(feature = "sse")]
if server_options.sse_support {
r = r
.merge(sse_routes::routes(
state.clone(),
server_options.sse_endpoint(),
server_options.sse_messages_endpoint(),
))
.merge(messages_routes::routes(
server_options.sse_messages_endpoint(),
))
.merge(messages_routes::routes(state.clone()))
}
r
})
Expand Down
Loading