Skip to content

Commit 339b719

Browse files
committed
fix(lib): explicitly enter runtime context before spawning tasks for Windows compatibility
1 parent ec98574 commit 339b719

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
@@ -788,7 +788,8 @@ pub extern "C" fn mcp_list_tools_init() -> usize {
788788
// Clone the Arc to share the service across async boundaries
789789
let service_arc = client.service.clone();
790790

791-
// Spawn directly on the runtime (Windows compatible)
791+
// Enter the runtime context explicitly before spawning (Windows compatible)
792+
let _guard = client.runtime.enter();
792793
client.runtime.spawn(async move {
793794
let service_guard = service_arc.lock().await;
794795
if let Some(service) = service_guard.as_ref() {
@@ -872,7 +873,8 @@ pub extern "C" fn mcp_call_tool_init(tool_name: *const c_char, arguments: *const
872873
if let Some(client) = client_opt.as_ref() {
873874
let service_arc = client.service.clone();
874875

875-
// Spawn directly on the runtime (Windows compatible)
876+
// Enter the runtime context explicitly before spawning (Windows compatible)
877+
let _guard = client.runtime.enter();
876878
client.runtime.spawn(async move {
877879
let service_guard = service_arc.lock().await;
878880
if let Some(service) = service_guard.as_ref() {

0 commit comments

Comments
 (0)