Gradient Generator Tool New Tool

Search Suggest

Advertisement • Top Big Banner (970x250)
Top Big Banner (970x250 / Responsive) • Ad Slot Active
Advertisement

Pinned Post

Advertisement

Laravel MCP Progress Notifications: Build Responsive AI Tools

Learn how to send progress notifications from long-running Laravel MCP tools using generators, Response::progress(), and tests with assertSentProgress

Long-running AI tools should not leave users wondering whether a request is still working. Laravel MCP supports progress notifications that let a tool report its current step while it continues processing.

In this tutorial, we will look at Laravel MCP streaming tools, the new Response::progress() API, and how to test progress updates.

Laravel MCP Progress Notifications: Build Responsive AI Tools


AI Quick Summary & Key Takeaways

Laravel MCP tools can return a generator and yield Response::progress() responses during a long-running operation. The server associates progress notifications with the request's progress token when the client opts in, and you can verify them in tests with assertSentProgress().

Table of Contents

1. What changed in Laravel MCP?

Laravel MCP v1.2.1, published on November 17, 2026, included progress notifications for streaming tools. The change makes it easier for Laravel MCP servers to communicate progress during operations such as importing files, processing batches, or generating reports.

Instead of waiting silently until the tool finishes, the server can emit progress updates while processing each item.

2. What are MCP progress notifications?

The Model Context Protocol (MCP) allows AI clients to call tools exposed by a server. A tool might search records, generate a report, import documents, or run a workflow.

Some operations finish quickly. Others can take several seconds or minutes. Progress notifications communicate the current state of a long-running request.

A progress notification can include:

  • The current progress value
  • An optional total value
  • An optional human-readable message

Progress notifications are not the same as streaming the final text answer token by token. They communicate execution progress, such as “Importing file 3 of 10”.

3. Requirements

This example assumes you have a Laravel application and Laravel MCP installed. Check your installed package version and the current package requirements before upgrading.

BASH
composer require laravel/mcp

For a new MCP server, Laravel provides Artisan scaffolding commands. You can create a tool using:

BASH
php artisan make:mcp-tool ImportFilesTool

4. Step 1: Understand streaming tools

Laravel MCP supports tools that return a generator from their handle() method. The generator can yield multiple response objects during execution.

For web-based MCP servers, streaming responses use Server-Sent Events (SSE) to send yielded messages to the client.

This is useful when a tool performs multiple steps and you want to report progress as each step completes.

5. Step 2: Create a streaming MCP tool

The following example demonstrates the documented progress API. It accepts a list of file names, emits a progress notification for each file, and returns a final response after processing.

Example tool:

PHP
<?php namespace App\Mcp\Tools; use Generator; use Laravel\Mcp\Request; use Laravel\Mcp\Response; use Laravel\Mcp\Server\Tool; class ImportFilesTool extends Tool { /** * Handle the tool request. * * @return Generator<int, Response> */ public function handle(Request $request): Generator { $files = $request->array('files'); foreach ($files as $index => $file) { yield Response::progress( $index + 1, total: count($files), message: "Importing {$file}...", ); $this->import($file); } yield Response::text('All files imported.'); } private function import(string $file): void { // Implement your real file-import logic here. } }
Important: The import() method is intentionally a placeholder. Replace it with your own validated import service. Do not use this example as a complete production file-import implementation.

How the progress call works

PHP
yield Response::progress( $index + 1, total: count($files), message: "Importing {$file}...", );

The first argument is the current progress value. The total argument is optional and describes the overall amount of work. The message argument provides a readable status.

In this example, the progress value increases from 1 to the number of files. This is a simple count-based progress indicator; it does not estimate the percentage of work inside an individual file.

6. Step 3: Register the tool on your MCP server

Add the tool class to the server's registered tools array. The server class should use the structure generated by your installed Laravel MCP version.

PHP
<?php namespace App\Mcp\Servers; use App\Mcp\Tools\ImportFilesTool; use Laravel\Mcp\Server; class ProjectServer extends Server { protected array $tools = [ ImportFilesTool::class, ]; }

Register the server using the MCP route configuration appropriate for your application. Protect remote MCP endpoints with authentication and authorization middleware.

7. Step 4: Understand the progress token

Progress notifications are associated with a progress token supplied by the MCP client in the request metadata. Laravel MCP automatically attaches the request's progress token to the progress notification.

If the client does not provide a progress token, progress notifications are omitted. Therefore, your tool should still complete correctly when no progress UI is available.

Do not assume every MCP client displays progress in the same way. Client support and presentation can differ.

8. Step 5: Test progress notifications

Laravel MCP documents the assertSentProgress() assertion for checking progress notifications emitted by a streaming tool.

For example, the documented assertion pattern looks like this:

PHP
$response ->assertSentProgress( 1, total: 2, message: 'Importing report.csv...' ) ->assertSentProgress( 2, total: 2 );

This verifies that progress values and the optional message were emitted as expected. Use the test setup and response object provided by the MCP testing utilities in your installed package version.

9. When should you use progress notifications?

Use case Example progress message
Batch import Importing file 4 of 20
Report generation Preparing report sections
Document processing Processing document 8 of 15
Multi-step workflow Validating records

10. Good practices

  • Send progress updates at meaningful checkpoints instead of for every tiny operation.
  • Keep progress values increasing and totals consistent.
  • Use clear messages that explain what the tool is doing.
  • Keep the tool functional even if the client does not request progress.
  • Validate tool input before starting expensive work.
  • Use authorization checks before accessing user-specific data.
  • Test progress notifications along with the final result.
  • Use queues or background jobs when the workload is too large for a single request lifecycle.

11. Bad practices to avoid

  • Sending progress updates without doing real work.
  • Reporting a fixed percentage that does not reflect actual processing.
  • Exposing private file names, user data, or secrets in progress messages.
  • Assuming the AI client will always show a progress bar.
  • Using progress notifications as a replacement for error handling.
  • Returning success when part of the operation failed.

12. Progress notifications vs final tool responses

Feature Progress notification Final response
Purpose Report work in progress Return the result
Timing During execution At completion
Typical content Current step, total, status Result, summary, or error
Required for tool success No Yes, the tool should return its appropriate final outcome

Frequently asked questions

What is Response::progress() in Laravel MCP?

Response::progress() creates a progress notification for a streaming MCP tool. It accepts the current progress value and optional total and message arguments.

Does Laravel MCP progress require SSE?

For web-based MCP servers, Laravel MCP streams yielded responses over Server-Sent Events. Progress notifications are protocol messages associated with the request's progress token.

Will every AI client display a progress bar?

No. The client must request progress and decide how to display it. A server can emit progress notifications, but the client controls the user interface.

How do I test Laravel MCP progress updates?

Laravel MCP provides the assertSentProgress() assertion for verifying emitted progress values and messages in tests.

Can progress notifications replace Laravel queues?

No. Progress notifications communicate status during a tool call. Queues are still useful for durable, long-running, retryable background workloads.

Conclusion

Progress notifications make long-running Laravel MCP tools easier to understand and more responsive. With a generator, Response::progress(), and the documented testing assertion, you can report meaningful execution checkpoints without changing the core business logic of your tool.

Use progress for user feedback, queues for durable background processing, and authorization plus validation for every tool that accesses application data.

Have you built a Laravel MCP tool yet? Share your use case or explore more Laravel and AI development tutorials on Web-Beast.

Sources and further reading

Web-Beast Tech Team

Written by Web-Beast Tech Team

Covering Laravel, PHP, AI developer tooling, and production backend engineering tutorials.

Post a Comment

Advertisement
Advertisement
Advertisement
Advertisement
NextGen Digital Welcome to WhatsApp chat
Howdy! How can we help you today?
Type here...