Search by

nataondev / laravel-agent-native

nataondev

Turn Livewire components and Laravel services into agent-ready tools with PHP 8 attributes. One definition powers your UI, LLM tool calling, and MCP endpoints.

Package info

github.com/nataondev/laravel-agent-native

pkg:composer/nataondev/laravel-agent-native

Statistics

Installs: 2

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v1.0.2 2026-09-23 14:49 UTC

This package is auto-updated.

Last update: 2026-09-23 19:10:43 UTC


README

laravel-agent-native — native agent tool calling for Laravel

Inspired by the Agent-Native architecture pioneered by Builder.io, brought natively to the Laravel & Livewire ecosystem.

Define an action once — a plain PHP method with an attribute. Your Livewire UI calls it, and LLM agents get it as a standards-compliant tool. No duplicated schemas, no manual tool registries.

#[AgentAction(description: 'Add a product to the shopping cart')]
public function addItem(int $productId, int $quantity = 1): void
{
    $this->items[] = compact('productId', 'quantity');
}

→ auto-compiled to OpenAI/MCP tool JSON, validated and executed through the container, with Livewire state/events in sync.

Install

composer require nataondev/laravel-agent-native
php artisan vendor:publish --tag=agent-native-config
  • PHP 8.2+ · Laravel 11+ · Livewire 3+ or 4+ (optional)

How it works

  1. Annotate — #[AgentAction] on any public method (service or Livewire component).
  2. Compile — reflection builds the tool schema from native types, enums, and docblocks.
  3. Execute — ActionExecutor validates arguments, resolves the class via the container, invokes, and returns a structured ActionResult.
  4. React — AgentBridge notifies your app (and listening components) that the agent acted.

Documentation

Guide What's inside
Installation Requirements, setup, registering classes
Defining actions #[AgentAction], #[AgentParam], #[AgentExpose], docblocks
Type mapping Scalars, arrays, backed/pure enums, nullability → JSON Schema
Executing actions ActionExecutor, ActionResult, error codes
Livewire integration InteractsWithAgent, AgentBridge, component state
HTTP endpoint AgentToolsController routes, security, payloads
MCP server Optional laravel/mcp bridge — actions as standard MCP tools
Artisan commands agent:inspect, agent:cache, agent:clear, agent:mcp
Caching Zero-reflection production boot

Quick example

php artisan agent:inspect --json   # tool schemas, ready for your LLM
use AgentNative\Laravel\Engine\ActionExecutor;

$result = app(ActionExecutor::class)->call('addItem', ['productId' => 42]);

$result->ok;     // true
$result->output; // JSON-safe return value

Testing

composer test   # Pest — 35 tests
composer lint   # Pint

License

MIT