Tools that take a while to finish could previously only stay silent until their final result arrived, giving clients nothing to show but a spinner with no signal. This release adds Response::progress(), a new factory that streaming tools can yield to emit standard notifications/progress notifications while they work. Each notification is bound to the progressToken the client supplied with the request, and clients that never opted in receive nothing at all — exactly as the MCP specification requires. Alongside the runtime support, the test harness gains first-class progress assertions, and the built-in tool-search aggregation stops nested tools from leaking progress under the parent request's token.
Sending Progress from a Streaming Tool
If your tool's handle() method returns a Generator, you can now interleave progress notifications between content responses:
use Generator;
use Laravel\Mcp\Request;
use Laravel\Mcp\Response;
public function handle(Request $request): Generator
{
$files = $request->get('files', []);
foreach ($files as $i => $file) {
yield Response::progress($i + 1, total: count($files), message: "Importing {$file}...");
$this->import($file);
}
yield Response::text('All files imported.');
}
The signature mirrors the spec: Response::progress(int|float $progress, int|float|null $total = null, ?string $message = null). Only the current progress value is required; total and message are optional and are omitted from the payload entirely when null. Fractional progress like 2.5 works, since both ints and floats are accepted. The final Response::text(...) still produces the tool's actual result — notifications ride alongside it as they are yielded.
How the Progress Token Is Bound
When a streamed tool yields a progress notification, the server reads _meta.progressToken from the incoming request and stamps it into the notification's params before sending. If the client did not send a token, the notification is silently skipped, as the spec demands. The token must be a string or an integer, so a client that sends 0 is still honored, while booleans and arrays are rejected.
Tools control the progress, total, and message; the token itself always comes from the request. Any token a tool includes in its own params is replaced with the request's value, so progress can only ever be attributed to the request that triggered it.
Asserting Progress in Tests
The test harness now attaches a progressToken to every request it builds automatically, so progress notifications flow through your assertions without extra setup:
$response = ImportServer::tool(ImportFilesTool::class);
$response->assertNotificationCount(3)
->assertSentProgress(1, 3, 'Importing a.csv')
->assertSentProgress(3);
assertSentProgress(int|float $progress, int|float|null $total = null, ?string $message = null) compares notifications with the progressToken stripped out, so you assert only what your tool actually controls. Omit total or message when your tool omits them; a mismatch in any provided value fails the assertion.
Nested Tool Calls Stay Quiet
When tool search aggregates multiple calls through execute_tools, it forwards the parent request's _meta to each sub-tool. That forwarded meta now excludes progressToken, so a nested tool's progress notifications are suppressed rather than emitted under the outer request's token. Clients invoking several tools through search see a single result per call, without stray progress streams mixed in.
Upgrading from v1.2.0
This change is additive, and no action is required for existing servers:
- Existing tools, transports, and configuration are untouched.
Response::progress()is simply available if you want progress reporting. - If you were hand-rolling progress with
Response::notification('notifications/progress', ...), be aware of the new gating: without a client-supplied token those notifications are now dropped, and the request's token overwrites any token you set yourself. Migrating toResponse::progress()lets the server manage the token for you. - Test requests now carry
_meta.progressToken, so tools that inspect$request->meta()during tests will see it, and notification counts may change for tools that yield progress notifications. - No schema or client-facing changes are needed; the conformance suite no longer skips the
tools-call-with-progresscase, confirming spec compliance.
Takeaways:
- Yield
Response::progress($progress, total: ..., message: ...)from generator-based tools to report progress mid-run. - Notifications carry the request's
_meta.progressToken; clients that send no token receive none. - Use
assertSentProgress()in tests — test requests now include a token automatically. - Sub-tools invoked via tool search no longer receive the parent request's
progressToken. - The upgrade from v1.2.0 is non-breaking; adopt progress reporting only where you want it.