1
- # Laravel MCP
1
+ # 🤖 Laravel MCP
2
2
3
3
## Introduction
4
- Laravel MCP gives you everything you need to build Laravel-powered MCP servers and let AI talk to your app .
4
+ Laravel MCP gives you everything you need to build Laravel-powered MCP servers and let AI talk to your apps .
5
5
6
6
## Installation
7
7
@@ -21,21 +21,21 @@ The package will automatically register MCP server defined in this file.
21
21
22
22
## Quickstart
23
23
24
- First, create a new server class using the ` mcp:server ` Artisan command:
24
+ First, create a new MCP server using the ` mcp:server ` Artisan command:
25
25
26
26
``` bash
27
27
php artisan mcp:server DemoServer
28
28
```
29
29
30
- Next, create a "hello" tool:
30
+ Next, create a tool for the MCP server :
31
31
32
32
``` bash
33
33
php artisan mcp:tool HelloTool
34
34
```
35
35
36
36
This will create two files: ` app/Mcp/Servers/DemoServer.php ` and ` app/Mcp/Tools/HelloTool.php ` .
37
37
38
- Open ` app/Mcp/Tools/HelloTool.php ` and replace its contents with the following code to create a simple tool that greets a user:
38
+ Open ` app/Mcp/Tools/HelloTool.php ` and replace its contents with the following code to create a simple tool that greets the user:
39
39
40
40
``` php
41
41
<?php
@@ -60,14 +60,17 @@ class HelloTool extends Tool
60
60
61
61
public function schema(ToolInputSchema $schema): ToolInputSchema
62
62
{
63
- $schema->string('name')->description('The name to greet.');
63
+ $schema
64
+ ->string('name')
65
+ ->description('The name to greet.')
66
+ ->required();
64
67
65
68
return $schema;
66
69
}
67
70
68
71
public function handle(array $arguments): ToolResult
69
72
{
70
- $name = $arguments['name'] ?? 'World' ;
73
+ $name = $arguments['name'];
71
74
72
75
return ToolResult::text("Hello, {$name}!");
73
76
}
@@ -101,7 +104,7 @@ use Laravel\Mcp\Facades\Mcp;
101
104
Mcp::local('demo', DemoServer::class);
102
105
```
103
106
104
- Finally, you can run your server and explore it with the MCP Inspector:
107
+ Finally, you can run your server and explore it with the MCP Inspector tool :
105
108
106
109
``` bash
107
110
php artisan mcp:inspector demo
0 commit comments