Laravel Loop

by kirschbaum-development

131 stars
348 downloads
Not rated
GitHub

About

Laravel Loop is a powerful Model Context Protocol (MCP) server designed specifically for Laravel applications. It connects your Laravel application with AI assistants using the MCP protocol.

Details

Author
kirschbaum-development
GitHub stars
131
Downloads
348
Categories
Developer Tools, Other

- Pre-built toolkits for Laravel models, factories, and Stripe
- Create custom tools with string, number, and other parameters
- Supports STDIO, Streamable HTTP, and HTTP+SSE transports
- Integration with Claude Code, Cursor, Windsurf, and more
- Built-in artisan commands for MCP configuration and testing
- Middleware support to secure HTTP endpoints

Install via Composer (composer require kirschbaum-development/laravel-loop), publish the config (php artisan vendor:publish --tag="loop-config"), and register tools in a service provider (e.g. Loop::toolkit(...)). Then connect an MCP client using STDIO (php artisan loop:mcp:start) or Streamable HTTP/SSE, optionally authenticating with middleware like Sanctum.

Laravel Loop

Laravel Supported Versions
MIT Licensed
Latest Version on Packagist

Laravel Loop is a powerful Model Context Protocol (MCP) server designed specifically for Laravel applications. It connects your Laravel application with AI assistants using the MCP protocol.

Laravel Loop uses Prism behind the scenes to build the tools.

> [!IMPORTANT]
> Laravel Loop and its pre-built tools are still in development and this is a beta version.

What It Does

Laravel Loop allows you to:

- Create and expose your own tools directly integrated with your Laravel application
- Connect with MCP clients like Claude Code, Cursor, Windsurf, and more

Pre-built tools:

Filament MCP Server.
Laravel Model Tools (Interact with your models data): Kirschbaum\Loop\Toolkits\LaravelModelToolkit (Write operations to come)
Laravel Factories Tools (Create test data from your MCP Client): Kirschbaum\Loop\Toolkits\LaravelFactoriesToolkit
Stripe Tool (Interact with the Stripe API): Kirschbaum\Loop\Tools\StripeTool

Installation

You can install the package via composer:

composer require kirschbaum-development/laravel-loop

Publish the configuration file:

php artisan vendor:publish --tag="loop-config"

Usage

First, you must register your tools (If you don't know where to put, put in app/Providers/AppServiceProvider).

use Illuminate\Support\ServiceProvider;
use Kirschbaum\Loop\Facades\Loop;
use Kirschbaum\Loop\Toolkits;
use Kirschbaum\Loop\Tools;

Loop::toolkit(Kirschbaum\Loop\Filament\FilamentToolkit::make());

Custom Tools

To build your own tools, you can use the Loop::tool method.

use Kirschbaum\Loop\Facades\Loop;
use Kirschbaum\Loop\Tools\CustomTool;

Loop::tool(
CustomTool::make(
name: 'custom_tool',
description: 'This is a custom tool',
)
->withStringParameter(name: 'name', description: 'The name of the user', required: true)
->withNumberParameter(name: 'age', description: 'The age of the user')
->using(function (string $name, ?int $age = null) {
return sprintf('Hello, %s! You are %d years old.', $name, $age ?? 'unknown');
}),
);
);

The available parameters types can be found in the Prism Tool Documentation.

Custom Tool Objects

You can also build your own tool classes. Each tool must implement the Tool contract, and return a Prism\Prism\Tool instance in the build method.

use Kirschbaum\Loop\Contracts\Tool;

class HelloTool implements Tool
{
use \Kirschbaum\Loop\Concerns\Makeable;

public function build(): \Prism\Prism\Tool
{
return app(\Prism\Prism\Tool::class)
->as($this->getName())
->for('Says hello to the user')
->withStringParameter('name', 'The name of the user to say hello to.', required: true)
->using(fn (string $name) => "Hello, $name!");
}

public function getName(): string
{
return 'hello';
}
}

If you want to provide multiple similar tools, you can build a toolkit which returns a collection of tools.

use Kirschbaum\Loop\Collections\ToolCollection;
use Kirschbaum\Loop\Contracts\Toolkit;

class LaravelFactoriesToolkit implements Toolkit
{
use \Kirschbaum\Loop\Concerns\Makeable;

public function getTools(): ToolCollection
{
return new ToolCollection([
HelloTool::make(),
GoodbyeTool::make(),
]);
}
}

*

Connecting to the MCP server

For this to be really useful, you need to connect your MCP client (Claude Code, Claude Desktop, Cursor, Windsurf, etc) to the Laravel LoopMCP server.

The MCP protocol has two main transports to connect: STDIO and Streamable HTTP, and the deprecated HTTP+SSE transport. Laravel Loop supports all of them.

The easiest way to configure your MCP client is to use the php artisan loop:mcp:config command. This will guide you through the process of configuring your MCP client.

php artisan loop:mcp:generate-config

STDIO

To run the MCP server using STDIO, we provide the following artisan command:

php artisan loop:mcp:start [--user-id=1 [--user-model=] [--auth-guard=] [--debug]

To connect Laravel Loop MCP server to Claude Code, for example, you can use the following command:

```bash
claude mcp add laravel-loop-mcp php /your/full/path/to/laravel/artisan loop:mcp:start

No reviews yet — be the first

Sign in to leave a review

Use Google, GitHub, or an email account so ratings stay tied to real people.

Email sign in

No reviews posted yet.