Laravel MCP reports progress from long-running tools in real time
Laravel MCP tools can report intermediate progress during long-running work instead of waiting for one final response.
When a tool looks stuck
A slow MCP tool creates a poor experience when it stays silent while doing its work. An agent calls the action, the connection remains open, and there is no obvious way to tell whether it is preparing a backup, waiting for Docker, or has simply failed. This gets especially frustrating with infrastructure tasks that have a number of known stages.
Laravel MCP lets a tool's handle method return a PHP generator. Rather than building one response at the end, the tool can yield responses as it runs. For web-based MCP servers, Laravel automatically opens an SSE stream and sends every yielded message to the client.
Use standard progress instead of ad-hoc messages
Response::progress() is the built-in way to report progress. It emits the standard MCP notifications/progress notification, with a current value plus optional total and message values. That matters because the client can treat the update as progress data, rather than trying to infer meaning from a piece of partial text.
This is a good fit for work split into clear units. It could mean checking services before a Compose deployment, processing files during a restore, or inspecting a list of homelab machines. When there is no measurable unit, phase updates can still be useful, but I would avoid implying a level of accuracy the operation does not have.
<?php
namespace App\Mcp\Tools;
use Generator;
use Laravel\Mcp\Request;
use Laravel\Mcp\Response;
use Laravel\Mcp\Server\Tool;
class InspectServicesTool extends Tool
{
/**
* @return \Generator<int, \Laravel\Mcp\Response>
*/
public function handle(Request $request): Generator
{
$services = $request->array('services');
foreach ($services as $index => $service) {
yield Response::progress(
$index + 1,
total: count($services),
message: "Inspecting {$service}...",
);
// Inspect the service here.
}
yield Response::text('Service inspection completed.');
}
}The final response is still required. Progress updates explain what is happening while the work runs, but they do not replace the result an agent needs before deciding what to do next. For a tool that changes infrastructure, that final response should state what completed, what did not, and what state the system was left in.
Where it is useful
I would use this for repeatable, potentially slow tasks, not for every MCP call by default. Container inventories, disk checks, operations spanning several services, and imports are natural candidates. It is also useful when a tool depends on external systems and I need to distinguish normal waiting from an actual failure.
The point is not to turn an MCP connection into a full log stream. One useful update per meaningful step is usually better than flooding the client with internal details. The agent needs operational context, not every line printed by a process when that output will not affect the next decision.
The fine print
Streaming does not make the task faster, and it does not turn blocking work into asynchronous work. The tool still runs on the server, while the generator only makes it possible to send intermediate responses between stages that yield control. If one call takes a long time before reaching a yield, there will be no update to send.
SSE is opened automatically for streaming responses from web-based MCP servers. I would not assume the same transport behavior for a local server simply because the tool code returns a generator. Laravel also omits progress notifications when the request does not include _meta.progressToken.
Progress messages are not a replacement for authorization, validation, or confirmation before dangerous actions. Reporting that a tool is deploying or restoring something does not make that action safe. Tools that touch Docker, backups, or internal services still need strict limits on which resources they can accept as input.
Test the stream as well
Laravel MCP provides assertSentProgress() for testing the notifications sent by a streaming tool. It is useful for checking both the expected sequence and the messages for important stages, especially when a client uses those updates to display status. That does not replace an end-to-end check with the actual MCP client, but it does catch regressions where the generator stops emitting expected events.
$response
->assertSentProgress(1, total: 2, message: 'Inspecting api...')
->assertSentProgress(2, total: 2);This does not change how an automation should be designed, but it improves how it is operated. When an action takes time, I prefer the agent to know which phase it has reached and to receive a final answer with context. For MCP tools around a homelab or infrastructure, that often prevents repeated runs caused only by the suspicion that something has frozen.