Skip to content

Commit 5e23397

Browse files
committed
fix(lib): unify runtime creation for McpClient to simplify code and improve compatibility
1 parent eeaf92e commit 5e23397

File tree

1 file changed

+2
-18
lines changed

1 file changed

+2
-18
lines changed

src/lib.rs

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -246,16 +246,7 @@ pub struct McpClient {
246246
/// Returns NULL on error
247247
#[no_mangle]
248248
pub extern "C" fn mcp_client_new() -> *mut McpClient {
249-
// On Windows, use current-thread runtime for better compatibility
250-
let runtime_result = if cfg!(windows) {
251-
tokio::runtime::Builder::new_current_thread()
252-
.enable_all()
253-
.build()
254-
} else {
255-
tokio::runtime::Runtime::new()
256-
};
257-
258-
match runtime_result {
249+
match tokio::runtime::Runtime::new() {
259250
Ok(runtime) => {
260251
let client = Box::new(McpClient {
261252
runtime,
@@ -333,15 +324,8 @@ pub extern "C" fn mcp_connect(
333324
};
334325

335326
// Create a new McpClient with runtime
336-
// On Windows, use current-thread runtime for better compatibility
337327
let new_client = McpClient {
338-
runtime: match if cfg!(windows) {
339-
tokio::runtime::Builder::new_current_thread()
340-
.enable_all()
341-
.build()
342-
} else {
343-
tokio::runtime::Runtime::new()
344-
} {
328+
runtime: match tokio::runtime::Runtime::new() {
345329
Ok(r) => r,
346330
Err(e) => {
347331
let error = format!(r#"{{"error": "Failed to create runtime: {}"}}"#, e);

0 commit comments

Comments
 (0)