LarAgent v0.7: MCP, Native Events & More!

LarAgent v0.7: MCP, Native Events & More!

This release focuses on fast, stateless interactions, dynamic capability via MCP, and deep Laravel-native observability through events.


šŸš€ New Methods

LarAgent introduces two new, developer-friendly methods for interacting with agents without maintaining persistent chat histories.

šŸ”¹ ask() — one-liner interaction

Ideal for quick, stateless prompts:

echo WeatherAgent::ask('What is the weather like?');

šŸ”¹ make() — chainable syntax

Gives you more control while staying clean and expressive, replacing "for" method:

echo WeatherAgent::make()
    ->message('What is the weather like?')
    ->temperature(0.7)
    ->respond();

Use make() when you need a temporary agent instance with custom temperature, model, or configuration but no stored chat history.

🧩 Model Context Protocol (MCP) Integration

LarAgent now supports MCP — the Model Context Protocol, enabling agents to dynamically load tools and resources from external MCP servers.

āš™ļø Configuration Example

'mcp_servers' => [
    'github' => [
        'type' => \Redberry\MCPClient\Enums\Transporters::HTTP,
        'base_url' => 'https://api.githubcopilot.com/mcp',
        'timeout' => 30,
        'token' => env('GITHUB_API_TOKEN', null),
    ],
    'mcp_server_memory' => [
        'type' => \Redberry\MCPClient\Enums\Transporters::STDIO,
        'command' => ['npx', '-y', '@modelcontextprotocol/server-memory'],
        'timeout' => 30,
        'cwd' => base_path(),
    ],
],

🧠 Dynamic MCP Registration

Define MCP servers in your agent via:

protected $mcpServers = ['github', 'mcp_server_memory'];

Or dynamically:

public function registerMcpServers() {
    return [
      'github:tools|only:get_issues', 
      'mcp_server_memory:resources'
    ];
}

New implementation supports the manual use too of tools and resources from MCP servers. Learn more here: https://docs.laragent.ai/core-concepts/mcp

šŸ”” Laravel Native Events Support

LarAgent now dispatches Laravel events for every key lifecycle action — letting you listen, log, or modify agent behavior with your own listeners.

🧩 Quickstart

Generate a listener:

php artisan make:listener AgentListener

Register it in your AppServiceProvider:

Event::listen(
    \LarAgent\Events\AgentInitialized::class,
    \App\Listeners\AgentListener::class
);

šŸ”¹ Main Lifecycle Events

EventDescription
AgentInitializedFired when agent setup completes
ConversationStartedFired when a new response begins
ConversationEndedFired when response completes
ToolChangedFired when tools are dynamically added/removed
AgentClearedFired when agent history resets
EngineErrorFired when LLM engine throws exception

šŸ”¹ Hook Events (Before/After)

EventPurpose
BeforeResponse / AfterResponseAround LLM calls
BeforeToolExecution / AfterToolExecutionTrack or modify tool runs
BeforeSaveHistoryIntercept history saving
BeforeStructuredOutputValidate structured responses

Each event provides an AgentDTO with full agent configuration and context.

⚔ Other Improvements

Improved chat-history behavior with customizable random keys:

protected static function generateRandomKey(): string {
    return self::class . '-' . Session::get('latest_topic');
}

šŸ“˜ Summary

v0.7 Highlights

  • ✨ ask() and make() — faster, cleaner message handling
  • 🧩 Full MCP integration for dynamic external tools
  • šŸ”” Laravel events for lifecycle and hooks
  • šŸ—ļø Improved chat-history customization

Happy coding! šŸš€

Read more

LarAgent v1.0 - Production-Ready AI Agents for Laravel

LarAgent v1.0 - Production-Ready AI Agents for Laravel

This major release takes LarAgent to the next level - focused on structured responses, reliable context management, richer tooling, and production-grade agent behavior. Designed for both development teams and business applications where predictability, observability, and scalability matter šŸ› ļø Structured Outputs with DataModel LarAgent introduces DataModel-based structured responses, moving beyond arrays to

By Revaz Gh.