Skip to content

Commit 2da0c60

Browse files
committed
Fix: Tokio async error in mcp-server
1 parent d011e0e commit 2da0c60

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

crates/codegraph-mcp/src/autoagents/tools/tool_executor_adapter.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,13 @@ impl GraphToolExecutorAdapter {
3333

3434
/// Execute a graph tool synchronously (blocks on async call)
3535
pub fn execute_sync(&self, function_name: &str, params: Value) -> Result<Value, String> {
36-
self.runtime_handle
37-
.block_on(self.executor.execute(function_name, params))
38-
.map_err(|e| e.to_string())
36+
// Use block_in_place to avoid "runtime within runtime" panic
37+
// This allows blocking the current thread without blocking the runtime
38+
tokio::task::block_in_place(|| {
39+
self.runtime_handle
40+
.block_on(self.executor.execute(function_name, params))
41+
})
42+
.map_err(|e| e.to_string())
3943
}
4044
}
4145

0 commit comments

Comments
 (0)