You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+62-6Lines changed: 62 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,14 +2,19 @@
2
2
3
3
Laravel Loop is a powerful Model Context Protocol (MCP) server designed specifically for Laravel applications. It connects your Laravel application with AI assistants using MCP.
4
4
5
+
Laravel Loop uses [Prism](https://github.com/prism-ai/prism) behind the scenes to build the tools.
6
+
7
+
> [!IMPORTANT]
8
+
> Laravel Loop is still in development and this is a beta version.
9
+
5
10
## What It Does
6
11
7
12
Laravel Loop allows you to:
8
13
9
14
- Create and expose your own tools directly integrated with your Laravel application
10
15
- Connect with MCP clients like Claude Code, Cursor, Windsurf, and more
11
16
12
-
It also ships with some pre-built tools:
17
+
It also ships with some pre-built tools (we are planning to add more and refine the existing ones):
13
18
14
19
- Expose your data through Laravel Models using our pre-built toolkit (`LaravelModelToolkit`)
15
20
- Expose your Filament Resources (`FilamentToolkit`)
@@ -72,17 +77,65 @@ Loop::tool(
72
77
);
73
78
```
74
79
75
-
You can also build your own tool classes by ...
80
+
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.
76
81
77
82
```php
78
-
use Kirschbaum\Loop\Loop;
83
+
use Kirschbaum\Loop\Contracts\Tool;
84
+
85
+
class HelloTool implements Tool
86
+
{
87
+
use \Kirschbaum\Loop\Concerns\Makeable;
88
+
89
+
public function build(): \Prism\Prism\Tool
90
+
{
91
+
return app(\Prism\Prism\Tool::class)
92
+
->as($this->getName())
93
+
->for('Says hello to the user')
94
+
->withStringParameter('name', 'The name of the user to say hello to.', required: true)
95
+
->using(fn (string $name) => "Hello, $name!");
96
+
}
79
97
98
+
public function getName(): string
99
+
{
100
+
return 'hello';
101
+
}
102
+
}
80
103
```
81
104
82
-
## MCP (Model Context Protocol) Server
105
+
If you want to provide multiple similar tools, you can build a toolkit which returns a collection of tools.
106
+
107
+
```php
108
+
use Kirschbaum\Loop\Collections\ToolCollection;
109
+
use Kirschbaum\Loop\Contracts\Toolkit;
110
+
111
+
class LaravelFactoriesToolkit implements Toolkit
112
+
{
113
+
use \Kirschbaum\Loop\Concerns\Makeable;
114
+
115
+
public function getTools(): ToolCollection
116
+
{
117
+
return new ToolCollection([
118
+
HelloTool::make(),
119
+
GoodbyeTool::make(),
120
+
]);
121
+
}
122
+
}
123
+
```
124
+
125
+
***
126
+
127
+
## Connecting to the MCP server
128
+
129
+
The MCP protocol has two main ways to connect: STDIO and Streamable HTTP.
83
130
84
131
### STDIO
85
132
133
+
To run the MCP server using STDIO, you must run the following command:
134
+
135
+
```bash
136
+
php artisan loop:mcp:start
137
+
```
138
+
86
139
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 --debug
96
149
```
97
150
98
-
To add to Cursor, or any (most?) MCP clients with a config file:
151
+
To add to Cursor, or any MCP clients with a JSON config file:
99
152
100
-
```bash
153
+
```json
101
154
{
102
155
"mcpServers": {
103
156
"laravel-loop-mcp": {
@@ -116,6 +169,9 @@ To add to Cursor, or any (most?) MCP clients with a config file:
116
169
117
170
Laravel Loop supports the [streamable HTTP transport](https://modelcontextprotocol.io/specification/2025-03-26/basic/transports) for the MCP protocol, which includes SSE capabilities for client-initiated requests (POST).
118
171
172
+
> [!IMPORTANT]
173
+
> NOTE: The Streamable HTTP transport is new and not yet supported by all MCP clients.
174
+
119
175
To enable the Streamable HTTP transport, update your `.env` file:
0 commit comments