Skip to content

Commit 4436c18

Browse files
committed
fix(transport): fix CI failures for unix socket transport
- Use std::io::Error::other() instead of Error::new(ErrorKind::Other) to satisfy clippy::io_other_error on newer nightly - Use #[tokio::test(flavor = "current_thread")] for unix socket tests since axum's serve(UnixListener) requires spawn_local - Gate validate_custom_header behind client-side-sse feature since it references http::HeaderName which isn't available with default features
1 parent 0dc0ec3 commit 4436c18

3 files changed

Lines changed: 9 additions & 4 deletions

File tree

crates/rmcp/src/transport/common/http_header.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ pub(crate) const RESERVED_HEADERS: &[&str] = &[
1717
/// Checks whether a custom header name is allowed.
1818
/// Returns `Ok(())` if allowed, `Err(name)` if rejected as reserved.
1919
/// `MCP-Protocol-Version` is reserved but allowed through (the worker injects it post-init).
20+
#[cfg(feature = "client-side-sse")]
2021
pub(crate) fn validate_custom_header(name: &http::HeaderName) -> Result<(), String> {
2122
if RESERVED_HEADERS
2223
.iter()
@@ -93,24 +94,28 @@ mod tests {
9394
assert_eq!(extract_scope_from_header("Bearer"), None);
9495
}
9596

97+
#[cfg(feature = "client-side-sse")]
9698
#[test]
9799
fn validate_rejects_reserved_accept() {
98100
let name = http::HeaderName::from_static("accept");
99101
assert!(validate_custom_header(&name).is_err());
100102
}
101103

104+
#[cfg(feature = "client-side-sse")]
102105
#[test]
103106
fn validate_rejects_reserved_session_id() {
104107
let name = http::HeaderName::from_static("mcp-session-id");
105108
assert!(validate_custom_header(&name).is_err());
106109
}
107110

111+
#[cfg(feature = "client-side-sse")]
108112
#[test]
109113
fn validate_allows_mcp_protocol_version() {
110114
let name = http::HeaderName::from_static("mcp-protocol-version");
111115
assert!(validate_custom_header(&name).is_ok());
112116
}
113117

118+
#[cfg(feature = "client-side-sse")]
114119
#[test]
115120
fn validate_allows_custom_header() {
116121
let name = http::HeaderName::from_static("x-custom");

crates/rmcp/src/transport/common/unix_socket.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ async fn connect_unix(socket_path: &str) -> Result<UnixStream, std::io::Error> {
119119
Ok::<_, std::io::Error>(stream)
120120
})
121121
.await
122-
.map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e))??;
122+
.map_err(std::io::Error::other)??;
123123
return UnixStream::from_std(std_stream);
124124
}
125125

crates/rmcp/tests/test_unix_socket_transport.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ async fn mcp_handler(
107107
}
108108

109109
/// Integration test: MCP client connects and completes handshake over a Unix domain socket.
110-
#[tokio::test]
110+
#[tokio::test(flavor = "current_thread")]
111111
async fn test_unix_socket_mcp_handshake() -> anyhow::Result<()> {
112112
let dir = std::env::temp_dir().join(format!("rmcp-test-{}", std::process::id()));
113113
std::fs::create_dir_all(&dir)?;
@@ -162,7 +162,7 @@ async fn test_unix_socket_mcp_handshake() -> anyhow::Result<()> {
162162
}
163163

164164
/// Integration test: Custom headers are sent through the Unix socket transport.
165-
#[tokio::test]
165+
#[tokio::test(flavor = "current_thread")]
166166
async fn test_unix_socket_custom_headers() -> anyhow::Result<()> {
167167
let dir = std::env::temp_dir().join(format!("rmcp-test-headers-{}", std::process::id()));
168168
std::fs::create_dir_all(&dir)?;
@@ -229,7 +229,7 @@ async fn test_unix_socket_custom_headers() -> anyhow::Result<()> {
229229
}
230230

231231
/// Integration test: Convenience constructor `from_unix_socket` works end-to-end.
232-
#[tokio::test]
232+
#[tokio::test(flavor = "current_thread")]
233233
async fn test_unix_socket_convenience_constructor() -> anyhow::Result<()> {
234234
let dir = std::env::temp_dir().join(format!("rmcp-test-conv-{}", std::process::id()));
235235
std::fs::create_dir_all(&dir)?;

0 commit comments

Comments
 (0)