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 Agent Kit Tutorial: Build AI Agents with Laravel Converse, MCP and PHP

Learn how to build AI agents with Laravel Agent Kit, Laravel AI SDK, Converse and MCP. Create tools, connect Slack and Telegram, test agent responses
Analyzed laravel-agent-kit-tutorial.html:L51-499 Analyzed laravel-agent-kit-tutorial.html:L651-729 Analyzed laravel-agent-kit-tutorial.html:L951-977 **Blogger Post Title:** ```text Laravel Agent Kit Tutorial: Build AI Agents with Laravel Converse, MCP and PHP ``` **Meta Description:** ```text Learn how to build AI agents with Laravel Agent Kit, Laravel AI SDK, Converse and MCP. Create tools, connect Slack and Telegram, test agent responses and deploy. ``` **Formatted Blogger Post HTML** (also saved in [laravel-agent-kit-tutorial.html](file:///c:/hard/blogger/laravel-agent-kit-tutorial.html)): ```html

Laravel AI SDK, Laravel Agent Kit, Laravel Converse, Laravel MCP, AI Agents

Laravel is expanding its AI development ecosystem. On December 1, 2026, the Laravel team introduced Laravel Agent Kit and Laravel Converse, giving PHP developers a more integrated way to build AI agents that can communicate through Slack, Telegram, GitHub and web applications.

Instead of manually building every webhook, conversation handler and chat integration, developers can use Laravel's AI tools and conventions to assemble an agent application.

In this tutorial, we will explore the architecture, create an agent, add a custom tool, connect a chat platform, understand MCP integration, evaluate responses and prepare the application for deployment.

Table of Contents

What Are Laravel Agent Kit and Laravel Converse?

Laravel Agent Kit is a starter kit for building AI agents. It brings together the Laravel AI SDK, Laravel Converse, Laravel MCP and Laravel Boost in a ready-to-use Laravel application.

Laravel Converse is the package that connects agents to chat platforms. It handles platform-specific webhooks, message formats, threads and conversation storage.

The important distinction is that Agent Kit helps you start an agent application, while Converse helps people communicate with agents through supported platforms.

Laravel AI ecosystem components

Component Main responsibility When to use it
Laravel AI SDK Agents, prompts and tool execution across supported AI providers When adding AI capabilities to a Laravel application
Laravel Converse Chat-platform communication, threads and webhooks When users need to communicate with agents
Laravel MCP Connects applications and agents to MCP servers and tools When agents need external capabilities
Laravel Boost Provides Laravel-specific guidance for coding agents When developing with AI coding assistants
Laravel Agent Kit Combines the ecosystem in a starter application When starting a new AI-agent project

These components can also be used independently. You do not have to adopt Agent Kit to use Converse or the Laravel AI SDK.

Laravel AI SDK, Laravel Agent Kit, Laravel Converse, Laravel MCP, AI Agents


Why Is This Important for PHP Developers?

Building an AI chatbot is relatively straightforward. Building an agent that can safely interact with real systems is more complicated.

A production agent may need:

  • Conversation history and thread management.
  • Tool calling and external API access.
  • Authentication and authorization.
  • Queue processing for slow AI requests.
  • Platform-specific webhook handling.
  • Human approval before sensitive operations.
  • Automated evaluations of agent responses.

Laravel's new agent stack provides integrated building blocks for these concerns. It does not remove the need to design permissions, monitor costs or validate AI-generated actions.

Laravel Agent Kit Architecture

A typical request moves through the following components:

  1. A user sends a message through Slack, Telegram, GitHub or a web chat.
  2. Laravel Converse receives the platform webhook.
  3. The message is processed through the Laravel queue.
  4. The configured AI agent receives the message and conversation context.
  5. The model may request one or more available tools.
  6. The application executes authorized tools and returns their results.
  7. The agent generates a response.
  8. Converse sends the response through the original platform.

MCP can provide additional external tools, while the AI SDK remains responsible for the agent and model interaction.

Step 1: Create a Laravel Agent Kit Application

According to the official documentation, Agent Kit requires PHP 8.4 or higher. Create a new application using Composer:

BASH
composer create-project laravel/agent-kit my-agent

The starter kit installs dependencies, creates the environment file and SQLite database, generates an application key, runs migrations and installs Laravel Boost guidance for supported coding agents.

Enter the project directory:

BASH
cd my-agent

Step 2: Configure Your AI Provider

A new Agent Kit application uses OpenAI by default. Add your provider credential to the environment file:

BASH
OPENAI_API_KEY=your-real-api-key

Never commit real API keys to Git. Use your deployment platform's secret-management facilities in production.

The Laravel AI SDK supports multiple providers. For example, if you configure Anthropic instead, add the appropriate key and select the provider in the AI SDK configuration.

Step 3: Understand the Agent Kit Project Structure

Agent Kit follows Laravel conventions and adds a few AI-specific directories:

BASH
app/ Ai/ Agents/ Assistant.php Tools/ routes/ bot.php config/ ai.php mcp.php tests/ Evals/
  • app/Ai/Agents contains agent classes.
  • app/Ai/Tools contains custom tools.
  • routes/bot.php registers bots and their connections.
  • config/mcp.php configures MCP clients.
  • tests/Evals contains agent evaluation tests.

Step 4: Understand the Assistant Agent

The starter application includes an Assistant agent. It uses Laravel AI SDK contracts and the Promptable trait.

Its instructions define the agent's role and behavior. Its tools method determines which tools are available to the model.

The following is a simplified example based on the documented Agent Kit structure:

PHP
<?php namespace App\Ai\Agents; use Laravel\Ai\Concerns\RemembersConversations; use Laravel\Ai\Contracts\Agent; use Laravel\Ai\Contracts\Conversational; use Laravel\Ai\Contracts\HasTools; use Laravel\Ai\Promptable; use Stringable; class Assistant implements Agent, Conversational, HasTools { use Promptable, RemembersConversations; public function instructions(): Stringable|string { return <<<'MD' You are a helpful internal team assistant. Answer questions clearly and accurately. Use available tools when current external information is required. Never claim that an action succeeded unless the tool confirms that it succeeded. Ask for confirmation before sensitive operations. MD; } public function tools(): iterable { return [ // Register application tools here. ]; } }

This example demonstrates the documented contracts and traits. Keep the generated starter-kit implementation as your starting point and adapt its existing class rather than replacing unrelated project code.

Step 5: Create a Custom AI Tool

An agent becomes more useful when it can retrieve real information instead of relying only on its model's training data.

Laravel Agent Kit supports Artisan tool generation. Let's create a weather tool as a practical example.

BASH
php artisan make:tool CurrentWeatherTool

The generated tool defines three important methods:

  • description() explains what the tool does.
  • schema() defines the arguments the model may provide.
  • handle() executes the actual application logic.

Replace the generated tool implementation with the following documentation-based example:

PHP
<?php namespace App\Ai\Tools; use Illuminate\Contracts\JsonSchema\JsonSchema; use Illuminate\Support\Facades\Http; use Laravel\Ai\Contracts\Tool; use Laravel\Ai\Tools\Request; use Stringable; class CurrentWeatherTool implements Tool { public function description(): Stringable|string { return 'Get the current weather in a city.'; } public function handle(Request $request): Stringable|string { $city = $request->string('city')->trim()->toString(); $place = Http::get( 'https://geocoding-api.open-meteo.com/v1/search', [ 'name' => $city, 'count' => 1, ] )->json('results.0'); if ($place === null) { return "No city named [{$city}] could be found."; } $current = Http::get( 'https://api.open-meteo.com/v1/forecast', [ 'latitude' => $place['latitude'], 'longitude' => $place['longitude'], 'current' => 'temperature_2m,wind_speed_10m', ] )->json('current'); if ($current === null) { return "Weather information is unavailable for {$city}."; } return "{$place['name']}, {$place['country']}: " . "{$current['temperature_2m']}°C, " . "wind {$current['wind_speed_10m']} km/h."; } public function schema(JsonSchema $schema): array { return [ 'city' => $schema->string() ->description('The city to look up.') ->required(), ]; } }

This example uses Open-Meteo's public geocoding and forecast endpoints. It does not require an API key for the demonstrated requests. For production use, add HTTP timeouts, response validation, error handling, rate limits and caching.

Step 6: Register the Tool with the Agent

Import the tool class and return an instance from the Assistant's tools method:

PHP
<?php namespace App\Ai\Agents; use App\Ai\Tools\CurrentWeatherTool; use Laravel\Ai\Concerns\RemembersConversations; use Laravel\Ai\Contracts\Agent; use Laravel\Ai\Contracts\Conversational; use Laravel\Ai\Contracts\HasTools; use Laravel\Ai\Promptable; use Stringable; class Assistant implements Agent, Conversational, HasTools { use Promptable, RemembersConversations; public function instructions(): Stringable|string { return <<<'MD' You are a weather assistant. Use CurrentWeatherTool whenever the user asks for current weather information. Do not invent weather readings. MD; } public function tools(): iterable { return [ new CurrentWeatherTool, ]; } }

Now the model can request the weather tool with a city argument. The application executes the tool and makes its result available to the agent.

Step 7: Test the Agent from the Terminal

You do not need to configure Slack or Telegram before testing your first agent.

Use Converse's terminal chat command:

BASH
php artisan converse:chat assistant

Try a prompt such as:

BASH
What is the current weather in Lisbon?

The agent should use the weather tool and answer using the returned data. If it does not, inspect the provider configuration, tool registration, network connectivity and application logs.

Step 8: Connect the Agent to Slack

Converse can connect a bot to supported platforms. Register your bot in routes/bot.php.

For example, a bot named weather can listen to Slack:

PHP
<?php use App\Ai\Agents\Assistant; use Laravel\Converse\Facades\Converse; Converse::agent('weather', Assistant::class) ->connection('slack');

Verify the registration:

BASH
php artisan converse:list

Then run the Slack setup command:

BASH
php artisan converse:setup slack

The setup process guides you through creating the Slack app, configuring credentials and pointing its webhook to your Laravel application.

The application needs a publicly reachable HTTPS URL for Slack webhook verification. A local development server by itself is not publicly accessible. Use a secure tunnel for development or deploy to a public HTTPS environment.

Step 9: Connect Telegram and GitHub

Converse also supports Telegram and GitHub connections. You can register multiple connections on the same bot:

PHP
<?php use App\Ai\Agents\Assistant; use Laravel\Converse\Facades\Converse; Converse::agent('assistant', Assistant::class) ->connection('slack', 'telegram', 'github');

Run the setup command for each platform you want to connect:

BASH
php artisan converse:setup telegram php artisan converse:setup github

Each platform has its own credential and webhook requirements. Configure only the permissions your bot needs. For GitHub integrations, review the app or token permissions before granting access to repositories.

Step 10: Understand MCP Integration

Model Context Protocol, commonly called MCP, provides a standard way for AI applications to connect to external tools and resources.

Laravel Agent Kit includes MCP configuration and example clients for GitHub, Linear and Playwright. This allows developers to expose external capabilities to their agents without manually implementing every integration.

For example, the documented Agent Kit pattern uses the Laravel MCP facade to retrieve tools from a configured GitHub client:

PHP
<?php use App\Ai\Tools\CurrentWeatherTool; use Laravel\Mcp\Facades\Mcp; public function tools(): iterable { return [ new CurrentWeatherTool, ...Mcp::client('github')->tools(), ]; }

Configure the GitHub token required by the example client in your environment:

BASH
MCP_GITHUB_TOKEN=your-github-token

The exact available tools depend on the MCP server and its configuration. Do not assume that every MCP server exposes the same capabilities.

Step 11: Evaluate AI Agent Responses

A successful API response does not prove that an AI agent is reliable. Agents can misunderstand instructions, choose the wrong tool or produce unsupported answers.

Agent Kit includes Pest evaluation support. Evaluations send prompts to the agent and ask a model to grade whether the answer meets a defined requirement.

A simple evaluation example from the official documentation looks like this:

PHP
<?php use App\Ai\Agents\Assistant; it('reports the weather for a city', function () { expect(Assistant::class) ->prompt('Do I need a jacket in Lisbon?') ->toSatisfy('Gives the current temperature in Lisbon'); });

Run the evaluation suite using:

BASH
composer test -- --evals

Important: evaluations make real AI provider requests and can incur API costs. The evaluator may also use a separate model for scoring. Keep evaluation datasets focused and review results rather than relying only on an automated score.

Step 12: Deploy the Agent Application

Converse processes platform messages through Laravel's queue system. A running queue worker is therefore essential for responding to incoming messages.

Before deploying, check the following:

  • Configure a production database.
  • Set AI provider credentials securely.
  • Configure a queue connection and worker.
  • Set up public HTTPS access for webhooks.
  • Configure platform credentials and webhook URLs.
  • Check logs, failed jobs and provider errors.
  • Test authentication and authorization for every tool.

For a local environment, the documented development command can start the application and worker together:

BASH
composer run dev

For production, use your hosting platform's process manager or managed queue worker. Laravel Cloud is one documented deployment option, but Agent Kit remains a Laravel application and can run on other suitable Laravel hosting environments.

Laravel AI SDK, Laravel Agent Kit, Laravel Converse, Laravel MCP, AI Agents

Laravel Agent Kit vs Building an AI Agent Manually

Area Agent Kit approach Manual approach
Initial project Starter application with integrations configured Set up each package and configuration
Agent definition Laravel AI SDK conventions Choose and implement an agent architecture
Chat platforms Converse integrations Build webhook handlers and platform adapters
MCP Laravel MCP included in the starter Configure MCP separately
Evaluations Pest evaluation setup included Build an evaluation workflow
Customization Normal Laravel application structure Full control over architecture

Agent Kit reduces setup work, but it does not automatically make an agent production-ready. Manual implementation may still be appropriate when a project has unusual security, infrastructure or integration requirements.

Good Practices for Laravel AI Agents

  • Give each agent a clear purpose and limited responsibilities.
  • Define tool schemas carefully and validate arguments.
  • Use authorization checks inside tools, not only in prompts.
  • Require human approval for irreversible or sensitive operations.
  • Use queues for slow provider requests and external integrations.
  • Set timeouts, retries and rate limits for external APIs.
  • Evaluate agent behavior using realistic prompts.
  • Track model usage and provider costs.
  • Keep secrets out of source control and logs.

Common Mistakes to Avoid

  • Assuming an AI agent can safely perform every tool action without authorization.
  • Forgetting to run a queue worker.
  • Using an inaccessible local URL for a platform webhook.
  • Giving a GitHub integration broader permissions than necessary.
  • Assuming an MCP server has tools that have not been configured.
  • Running expensive evaluations without understanding provider usage.
  • Putting all business logic inside one enormous agent class.
  • Trusting an AI response as proof that an external operation succeeded.

Frequently Asked Questions

What is Laravel Agent Kit?

Laravel Agent Kit is a starter kit for creating AI-agent applications. It combines the Laravel AI SDK, Converse, MCP and Boost with an initial agent, tool structure, bot routes and evaluation setup.

What is Laravel Converse used for?

Laravel Converse connects AI agents to supported chat platforms such as Slack, Telegram and GitHub, as well as web chat. It handles platform-specific messaging, webhooks and conversation threads.

Does Laravel Agent Kit require PHP 8.6?

No. The official Agent Kit documentation specifies PHP 8.4 or higher. Check the current package and dependency requirements before installing it.

Can I use Laravel Agent Kit with an existing Laravel application?

Agent Kit is intended as a starter application for new agent projects. Existing Laravel applications can instead add the AI SDK and Converse packages independently.

Does Agent Kit include a web frontend?

The Agent Kit starter does not include a web frontend or user authentication. For an application-specific web chat, use a Laravel full-stack starter kit and integrate the AI SDK and Converse web-chat functionality.

Can Laravel AI agents use MCP tools?

Yes. Laravel MCP can connect an agent to configured MCP servers. The available tools depend on the configured server and its permissions.

Does Laravel Converse need a queue worker?

Yes. Converse processes chat-platform and web-chat messages through the application's queue. A running worker is required for agents to respond.

Can one Laravel agent connect to multiple chat platforms?

Yes. Converse allows a bot to register multiple supported connections, subject to each platform's credentials and setup requirements.

Conclusion

Laravel Agent Kit and Converse represent an important addition to the PHP AI ecosystem. They give developers a more integrated starting point for building agents that can communicate with teams, use tools and connect to external services.

The most useful way to explore the stack is to start with one small agent, add one carefully scoped tool, test it in the terminal, and then connect a chat platform. Once that works, add MCP integrations, evaluations, approval flows and production monitoring.

AI agents should not be treated as ordinary chatbots with unrestricted access to application data. Their tools, permissions and side effects need the same engineering discipline as any other backend integration.

Have you started building AI agents with Laravel? Share your experience with Agent Kit, Converse or MCP and tell us which integration you are building next.

  • Laravel AI SDK Tutorial: Build AI Agents with PHP
  • Laravel MCP Server and Client Integration Guide
  • How to Build an AI Agent with Tool Calling
  • Laravel Queue Jobs and Redis: Complete Guide
  • Laravel 13 Development and Upgrade Guide
  • RAG vs Agentic RAG: Architecture and Practical Examples

Use these as suggested anchor texts only. Link them to matching existing Web-Beast articles after checking the published URLs. Do not create links to pages that do not exist.

Official Sources and Further Reading

```



Post a Comment

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