async def test_long_running_task(client: BasicMCPClient):
    """Test a long-running task with progress updates."""
    # This will run a task that takes a few seconds and reports progress
    current_progress = 0
    current_message = ""
    expected_total = None

    async def progress_callback(progress: float, total: float, message: str):
        nonlocal current_progress
        nonlocal current_message
        nonlocal expected_total

        current_progress = progress
        current_message = message
        expected_total = total

    result = await client.call_tool(
        "long_task", {"steps": 3}, progress_callback=progress_callback
    )
    assert "Completed 3 steps" in result.content[0].text
    assert current_progress == 3.0
    assert current_progress == expected_total
    assert current_message == "Processing step 3/3"
Test a long-running task with progress updates.
llama-index-integrations/tools/llama-index-tools-mcp/tests/test_client.py