Skip to content

Commit a893ed6

Browse files
committed
fix(lib): use runtime_handle_clone for FFI context handling in spawn_blocking on Windows
1 parent 853bd11 commit a893ed6

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/lib.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -790,8 +790,9 @@ pub extern "C" fn mcp_list_tools_init() -> usize {
790790
let runtime_handle = client.runtime.handle().clone();
791791

792792
// Use spawn_blocking which handles FFI context better on Windows
793+
let runtime_handle_clone = runtime_handle.clone();
793794
runtime_handle.spawn_blocking(move || {
794-
runtime_handle.block_on(async move {
795+
runtime_handle_clone.block_on(async move {
795796
let service_guard = service_arc.lock().await;
796797
if let Some(service) = service_guard.as_ref() {
797798
match service.list_tools(None).await {
@@ -877,8 +878,9 @@ pub extern "C" fn mcp_call_tool_init(tool_name: *const c_char, arguments: *const
877878
let runtime_handle = client.runtime.handle().clone();
878879

879880
// Use spawn_blocking which handles FFI context better on Windows
881+
let runtime_handle_clone = runtime_handle.clone();
880882
runtime_handle.spawn_blocking(move || {
881-
runtime_handle.block_on(async move {
883+
runtime_handle_clone.block_on(async move {
882884
let service_guard = service_arc.lock().await;
883885
if let Some(service) = service_guard.as_ref() {
884886
// Parse arguments

0 commit comments

Comments
 (0)