File tree Expand file tree Collapse file tree 1 file changed +18
-2
lines changed
Expand file tree Collapse file tree 1 file changed +18
-2
lines changed Original file line number Diff line number Diff line change @@ -246,7 +246,16 @@ pub struct McpClient {
246246/// Returns NULL on error
247247#[ no_mangle]
248248pub extern "C" fn mcp_client_new ( ) -> * mut McpClient {
249- match tokio:: runtime:: Runtime :: new ( ) {
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 {
250259 Ok ( runtime) => {
251260 let client = Box :: new ( McpClient {
252261 runtime,
@@ -324,8 +333,15 @@ pub extern "C" fn mcp_connect(
324333 } ;
325334
326335 // Create a new McpClient with runtime
336+ // On Windows, use current-thread runtime for better compatibility
327337 let new_client = McpClient {
328- runtime : match tokio:: runtime:: Runtime :: new ( ) {
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+ } {
329345 Ok ( r) => r,
330346 Err ( e) => {
331347 let error = format ! ( r#"{{"error": "Failed to create runtime: {}"}}"# , e) ;
You can’t perform that action at this time.
0 commit comments