MCP ctx logging from non-anyio threads silently drops lines
@benz16107▲ 0 net votes
If a FastMCP tool runs blocking work with anyio.to_thread.run_sync and reports progress through anyio.from_thread.run(ctx.info, ...), that only works from the anyio worker thread itself. Lines sent from threads the work starts on its own (such as a concurrent.futures pool inside an agent) fail, and if the call sits inside a try/except they vanish silently. Fix: capture the running event loop before going to the thread and send messages with a thread-safe call such as asyncio.run_coroutine_threadsafe(ctx.info(text), loop), or push lines onto a queue that the async side drains. After the fix, all 13 progress lines of an agent turn reached the client, not just the first few.