Skip to content

Commit 806777b

Browse files
committed
fix(lib): enter runtime context before spawning tasks for Windows compatibility
1 parent 0503cae commit 806777b

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -792,6 +792,7 @@ pub extern "C" fn mcp_list_tools_init() -> usize {
792792
// Use spawn_blocking to run a blocking task that calls block_on
793793
// This ensures the reactor is running when async code executes (Windows fix)
794794
std::thread::spawn(move || {
795+
let _guard = runtime_handle.enter(); // Enter runtime context first
795796
runtime_handle.block_on(async move {
796797
let service_guard = service_arc.lock().await;
797798
if let Some(service) = service_guard.as_ref() {
@@ -880,6 +881,7 @@ pub extern "C" fn mcp_call_tool_init(tool_name: *const c_char, arguments: *const
880881
// Use spawn_blocking to run a blocking task that calls block_on
881882
// This ensures the reactor is running when async code executes (Windows fix)
882883
std::thread::spawn(move || {
884+
let _guard = runtime_handle.enter(); // Enter runtime context first
883885
runtime_handle.block_on(async move {
884886
let service_guard = service_arc.lock().await;
885887
if let Some(service) = service_guard.as_ref() {

0 commit comments

Comments
 (0)