What happened?
I am making an MCP tool/task which uses await asyncio.sleep when polling some external API. I wanted to add some unit tests using the FastMCP Client and noticed a huge memory usage spikes:
The pytest process needs to be killed otherwise it runs out of memory and my computer freezes.
Example Code
import asyncio
from unittest.mock import patch
from fastmcp import Client, FastMCP
mcp = FastMCP()
@mcp.tool(task=True)
async def sleepy():
await asyncio.sleep(10)
return {"success": True}
async def test_sleepy():
with patch.object(asyncio, "sleep"):
async with Client(transport=mcp) as client:
await client.call_tool("sleepy")
Version Information
FastMCP version: 3.2.3
MCP version: 1.27.0
Python version: 3.14.3
Platform: Linux-6.8.0-107-generic-x86_64-with-glibc2.39
What happened?
I am making an MCP tool/task which uses
await asyncio.sleepwhen polling some external API. I wanted to add some unit tests using the FastMCP Client and noticed a huge memory usage spikes:The pytest process needs to be killed otherwise it runs out of memory and my computer freezes.
Example Code
Version Information