Skip to content

🕵️‍♂️ (2-in-1) Email & Username OSINT suite featuring native MCP support for deep data extraction just from a single Email/Username. Analyzes 2720+ actively maintained scan vectors (210+ email / 2510+ username) for security research, investigations, and digital footprinting.

fix(mcp): run cross-scan off the event loop (#664)

A Sivasubramanian Manoj46927a4bb4bf
diff --git a/tests/test_mcp_handlers.py b/tests/test_mcp_handlers.py
index 98153a3..241257f 100644
--- a/tests/test_mcp_handlers.py
+++ b/tests/test_mcp_handlers.py
@@ -100,3 +100,28 @@ async def test_execute_scan_module_normalization(mock_run_scan):
# It should normalize to an underscore
assert module_name == "Made_porn"
+
+
+@patch("user_scanner.mcp.handlers.run_cross_scan")
+@patch("user_scanner.mcp.handlers._run_scan")
+async def test_execute_scan_cross_scan_runs_off_event_loop(mock_run_scan, mock_cross_scan):
+ """run_cross_scan uses asyncio.run() internally, so it must not run on the event loop thread."""
+ import asyncio
+ import threading
+
+ loop_thread = threading.get_ident()
+ seen = {}
+
+ def fake_cross_scan(results, configs, cross_configs):
+ seen["thread"] = threading.get_ident()
+ # Mirrors the orchestrators, which call asyncio.run() internally.
+ asyncio.run(asyncio.sleep(0))
+ return [Result.taken()]
+
+ mock_run_scan.return_value = [Result.available()]
+ mock_cross_scan.side_effect = fake_cross_scan
+
+ await execute_scan({"username": "testuser", "cross_scan": True}, is_email=False)
+
+ assert seen["thread"] != loop_thread
diff --git a/user_scanner/mcp/handlers.py b/user_scanner/mcp/handlers.py
index 49dd0ce..7b3326f 100644
--- a/user_scanner/mcp/handlers.py
+++ b/user_scanner/mcp/handlers.py
@@ -113,7 +113,9 @@ async def execute_scan(arguments: dict, is_email: bool) -> list[types.TextConten
modules=(module_name,) if module_name else (),
categories=(category,) if category else (),
)
- cross_results = run_cross_scan(results, config, cross_configs)
+ cross_results = await asyncio.to_thread(
+ run_cross_scan, results, config, cross_configs
+ )
results.extend(cross_results)
finally:
# Restore defaults so the next request starts clean