PHPackages                             kirschbaum-development/laravel-loop - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. kirschbaum-development/laravel-loop

ActiveLibrary[API Development](/categories/api)

kirschbaum-development/laravel-loop
===================================

Laravel Loop is an MCP (Model Context Protocol) Server for Laravel

0.1.8(10mo ago)12814.4k↑10.7%10[4 issues](https://github.com/kirschbaum-development/laravel-loop/issues)[5 PRs](https://github.com/kirschbaum-development/laravel-loop/pulls)1MITPHPCI passing

Since May 27Pushed 1mo ago13 watchersCompare

[ Source](https://github.com/kirschbaum-development/laravel-loop)[ Packagist](https://packagist.org/packages/kirschbaum-development/laravel-loop)[ RSS](/packages/kirschbaum-development-laravel-loop/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (9)Dependencies (17)Versions (14)Used By (1)

Laravel Loop
============

[](#laravel-loop)

[![](images/laravel-loop.png)](images/laravel-loop.png)

[![Laravel Supported Versions](https://camo.githubusercontent.com/4b685234c18c2a323630d28899a6df0f78314186029222a4483f21c9c9d9a506/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c61726176656c2d31302e782f31312e782f31322e782d677265656e2e737667)](https://camo.githubusercontent.com/4b685234c18c2a323630d28899a6df0f78314186029222a4483f21c9c9d9a506/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c61726176656c2d31302e782f31312e782f31322e782d677265656e2e737667)[![MIT Licensed](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Latest Version on Packagist](https://camo.githubusercontent.com/2866adc01c40a38da4044f13cb8e2ef013bbe8c21f1b0aef0bdeded15f29d802/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6b69727363686261756d2d646576656c6f706d656e742f6c61726176656c2d6c6f6f702e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/kirschbaum-development/laravel-loop)

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](https://github.com/prism-php/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.

[![](images/claude-desktop.png)](images/claude-desktop.png)

What It Does
------------

[](#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](https://github.com/kirschbaum-development/laravel-loop-filament).
- 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
------------

[](#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
-----

[](#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

[](#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](https://prismphp.com/core-concepts/tools-function-calling.html#parameter-definition).

### Custom Tool Objects

[](#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
----------------------------

[](#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

[](#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:

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

# with an authenticated user
claude mcp add laravel-loop-mcp php /your/full/path/to/laravel/artisan loop:mcp:start --user-id=1 --user-model=App\Models\User

# with debug mode
claude mcp add laravel-loop-mcp php /your/full/path/to/laravel/artisan loop:mcp:start --debug
```

To configure Laravel Loop in Cursor, Claude or any MCP clients with a JSON config file:

```
{
  "mcpServers": {
    "laravel-loop-mcp": {
      "command": "php",
      "args": [
        "/your/full/path/to/laravel/artisan",
        "loop:mcp:start",
        "--user-id=1"
      ]
    }
  }
}
```

### Streamable HTTP &amp; SSE

[](#streamable-http--sse)

Having to run PHP or Node to run the MCP server can be annoying. To avoid this, you can use the Streamable HTTP or SSE transport, which connects the MCP client directly to your application via HTTP.

Laravel Loop also supports the [streamable HTTP transport](https://modelcontextprotocol.io/specification/2025-03-26/basic/transports) and the deprecated [HTTP+SSE transport](https://modelcontextprotocol.io/specification/2024-11-05/basic/transports#http-with-sse).

Important

NOTE: The Streamable HTTP transport is new and not yet supported by all MCP clients, while the SSE (supported by most MCP clients) is deprecated.

The following docs are for both transports. Please note you only need to enable one of them.

#### 1. Enable and configure the transport

[](#1-enable-and-configure-the-transport)

To enable the Streamable HTTP transport, update your `.env` file:

```
# streamable http
LOOP_STREAMABLE_HTTP_ENABLED=true

# sse
LOOP_SSE_ENABLED=true
```

**Note:** When using SSE, the default driver is `file`, which is the simplest and most convenient for local development. However, for production, we recommend using `redis` to avoid issues with file locking. You can change the driver and additional options in the `config/loop.php` file.

This will expose two MCP endpoints:

- `/mcp` that supports the new Streamable HTTP transport.
- `/mcp/sse` that supports the deprecated HTTP+SSE transport.

**Note:** If you are running your application locally with **https**, most clients will fail due to the self-signed certificates. To avoid this, use the STDIO transport or use the **http** protocol locally.

#### 2. Configure authentication (optional)

[](#2-configure-authentication-optional)

Be aware that if you are exposing your endpoint publicly, you are exposing your data to the world. To ensure your MCP endpoints are secure, make sure to configure the `streamable_http.middleware` or `sse.middleware` config options. We recommend using something like Sanctum (configured by default) to protected the endpoint.

```
[
    'streamable_http' => [
        'middleware' => ['auth:sanctum'],
    ],

    'sse' => [
        'middleware' => ['auth:sanctum'],
    ],
]
```

#### 3. Add the MCP server to your client

[](#3-add-the-mcp-server-to-your-client)

Then, you just need to configure the MCP server endpoint in your client:

**Claude Code**

```
claude mcp add laravel-loop-mcp http://your-url.test/mcp/sse -t sse
```

**From JSON config file**

```
{
  "mcpServers": {
    "laravel-loop-mcp": {
      "url": "http://your-url.test/mcp/sse",
    }
  }
}
```

Please note that not all clients support direct SSE connections. For those situations, you can proxy it through the `mcp-remote` package. This requires you to have Node.js (&gt; 20) installed. Below an example using the [mcp-remote](https://github.com/geelen/mcp-remote) package.

```
{
  "mcpServers": {
    "laravel-loop-mcp": {
      "command": "npx",
      "args": [
        "mcp-remote",
        "https://your-remote-url.com/mcp",
        "--header",
        "Authorization: Bearer ${AUTH_TOKEN}"
      ]
    }
  }
}
```

---

Troubleshooting
---------------

[](#troubleshooting)

**Connection failed: MCP error -32000: Connection closed**

If you get this error, it likely means there's some error happening in your application. Check your applicationlogs for more details.

**Error: spawn php ENOENT**

This can happen when your "php" binary is not in the PATH. This can be solved in a few ways:

- Add the path to your `.bashrc` or `.zshrc` file. Sometimes it can be only in the `.zshrc` file but applications like Claude use `.bashrc`.
- Use the full path of the PHP binary. You can get it by running `which php` in your terminal.
    - This can be a good option to ensure you always use the proper version of PHP for a given project. If you use Herd, for example, your `php` will change depending on the selected version.

**Manually call tools and verify output**

Sometimes when building tools, you may be getting unexpected results and debugging from the MCP client can be difficult. You can manually call tools and verify the output by running the following command:

```
php artisan loop:mcp:call
```

**Make sure to check your application logs**

If you are getting an unkown error, check your application logs for more details.

---

Roadmap
-------

[](#roadmap)

- Add a chat component to the package, so you can use the tools inside the application without an MCP client.
- Refine the existing tools
- Add write capabilities to the existing tools

Security
--------

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

Sponsorship
-----------

[](#sponsorship)

Development of this package is sponsored by Kirschbaum Development Group, a developer driven company focused on problem solving, team building, and community. Learn more [about us](https://kirschbaumdevelopment.com?utm_source=github) or [join us](https://careers.kirschbaumdevelopment.com?utm_source=github)!

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE) for more information.

###  Health Score

45

—

FairBetter than 93% of packages

Maintenance73

Regular maintenance activity

Popularity43

Moderate usage in the ecosystem

Community24

Small or concentrated contributor base

Maturity34

Early-stage or recently created project

 Bus Factor1

Top contributor holds 60% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~5 days

Total

9

Last Release

313d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/57e405b52d482c9de35b17f299d2745e8e68d9d9951aec64854f2d7fa53110bf?d=identicon)[luisdalmolin](/maintainers/luisdalmolin)

---

Top Contributors

[![luisdalmolin](https://avatars.githubusercontent.com/u/403446?v=4)](https://github.com/luisdalmolin "luisdalmolin (33 commits)")[![fsmonter](https://avatars.githubusercontent.com/u/34519027?v=4)](https://github.com/fsmonter "fsmonter (6 commits)")[![barryvdh](https://avatars.githubusercontent.com/u/973269?v=4)](https://github.com/barryvdh "barryvdh (5 commits)")[![dmason30](https://avatars.githubusercontent.com/u/20278756?v=4)](https://github.com/dmason30 "dmason30 (4 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (3 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (2 commits)")[![kauffinger](https://avatars.githubusercontent.com/u/62616071?v=4)](https://github.com/kauffinger "kauffinger (1 commits)")[![brandonferens](https://avatars.githubusercontent.com/u/1819546?v=4)](https://github.com/brandonferens "brandonferens (1 commits)")

---

Tags

laravelmcpmcp-server

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/kirschbaum-development-laravel-loop/health.svg)

```
[![Health](https://phpackages.com/badges/kirschbaum-development-laravel-loop/health.svg)](https://phpackages.com/packages/kirschbaum-development-laravel-loop)
```

###  Alternatives

[spatie/laravel-query-builder

Easily build Eloquent queries from API requests

4.4k26.9M220](/packages/spatie-laravel-query-builder)[essa/api-tool-kit

set of tools to build an api with laravel

52680.5k](/packages/essa-api-tool-kit)[spatie/laravel-route-discovery

Auto register routes using PHP attributes

23645.0k2](/packages/spatie-laravel-route-discovery)[simplestats-io/laravel-client

Client for SimpleStats!

4515.5k](/packages/simplestats-io-laravel-client)[ryangjchandler/bearer

Minimalistic token-based authentication for Laravel API endpoints.

8129.8k](/packages/ryangjchandler-bearer)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
