Skip to content

Commit 3e7751a

Browse files
committed
Merge remote-tracking branch 'origin/main'
2 parents 9d9c751 + c2e593e commit 3e7751a

File tree

1 file changed

+5
-57
lines changed

1 file changed

+5
-57
lines changed

README.md

Lines changed: 5 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
1-
# Laravel MCP
1+
# Laravel MCP Server SDK
22

33
> [!IMPORTANT]
4-
> We don't recommend using this package yet. This package is only for [Boost](https://github.com/laravel/boost) use currently. A full release of the Laravel MCP server package will be released soon.
5-
6-
4+
> This package is still in development and not recommended for public usage. This package is currently only intended to power [Boost](https://github.com/laravel/boost).
75
86
---
97

10-
11-
128
## Introduction
139

1410
Laravel MCP makes it easy to add MCP servers to your project and let AI talk to your apps.
@@ -29,11 +25,9 @@ php artisan vendor:publish --tag=ai-routes
2925

3026
The package will automatically register MCP servers defined in this file.
3127

32-
33-
3428
## Quickstart
3529

36-
**Create the server & tool**
30+
**Create the Server and Tool**
3731

3832
First, create a new MCP server using the `mcp:server` Artisan command:
3933

@@ -49,9 +43,7 @@ php artisan make:mcp-tool HelloTool
4943

5044
This will create two files: `app/Mcp/Servers/DemoServer.php` and `app/Mcp/Tools/HelloTool.php`.
5145

52-
53-
54-
**Add the tool to the server**
46+
**Add the Tool to the Server**
5547

5648
Open `app/Mcp/Servers/DemoServer.php` and add your new tool to the `$tools` property:
5749

@@ -71,8 +63,6 @@ class DemoServer extends Server
7163
}
7264
```
7365

74-
75-
7666
Next, register your server in `routes/ai.php`:
7767

7868
```php
@@ -82,16 +72,12 @@ use Laravel\Mcp\Server\Facades\Mcp;
8272
Mcp::local('demo', DemoServer::class);
8373
```
8474

85-
86-
8775
Finally, you can test it with the MCP Inspector tool:
8876

8977
```bash
9078
php artisan mcp:inspector demo
9179
```
9280

93-
94-
9581
## Creating Servers
9682

9783
A server is the central point that handles communication and exposes MCP methods, like tools and resources. Create a server with the `make:mcp-server` Artisan command:
@@ -100,22 +86,16 @@ A server is the central point that handles communication and exposes MCP methods
10086
php artisan make:mcp-server ExampleServer
10187
```
10288

103-
104-
10589
## Creating Tools
10690

10791
[Tools](https://modelcontextprotocol.io/docs/concepts/tools) let your server expose functionality that clients can call, and that language models can use to perform actions, run code, or interact with external systems.
10892

109-
110-
11193
Use the `mcp:tool` Artisan command to generate a tool class:
11294

11395
```bash
11496
php artisan make:mcp-tool ExampleTool
11597
```
11698

117-
118-
11999
### Tool Inputs
120100

121101
Your tools can request arguments from the MCP client using a tool input schema:
@@ -131,8 +111,6 @@ public function schema(ToolInputSchema $schema): ToolInputSchema
131111
}
132112
```
133113

134-
135-
136114
### Annotating Tools
137115

138116
You can add annotations to your tools to provide hints to the MCP client about their behavior. This is done using PHP attributes on your tool class. Adding annotations to your tools is optional.
@@ -164,8 +142,6 @@ class ExampleTool extends Tool
164142
}
165143
```
166144

167-
168-
169145
### Tool Results
170146

171147
The `handle` method of a tool must return an instance of `Laravel\Mcp\Server\Tools\ToolResult`. This class provides a few convenient methods for creating responses.
@@ -202,10 +178,6 @@ $response = ToolResult::items(
202178
);
203179
```
204180

205-
206-
207-
208-
209181
## Streaming Tool Responses
210182

211183
For tools that send multiple updates or stream large amounts of data, you can return a generator from the `handle()` method. For web-based servers, this automatically opens an SSE stream and sends an event for each message the generator yields.
@@ -239,55 +211,37 @@ class ChatStreamingTool extends Tool
239211
}
240212
```
241213

242-
243-
244-
245-
246214
## Creating Resources
247215

248216
[Resources](https://modelcontextprotocol.io/docs/concepts/resources) let your server expose data and content that clients can read and use as context when interacting with language models.
249217

250-
251-
252218
Use the `make:mcp-resource` Artisan command to generate a resource class:
253219

254220
```bash
255221
php artisan make:mcp-resource ExampleResource
256222
```
257223

258-
259-
260224
To make a resource available to clients, you must register it in your server class in the `$resources` property.
261225

262-
263-
264-
265-
266226
## Creating Prompts
267227

268228
[Prompts](https://modelcontextprotocol.io/docs/concepts/prompts) let your server share reusable prompts that clients can use to prompt the LLM.
269229

270-
271-
272230
Use the `make:mcp-prompt` Artisan command to generate a prompt class:
273231

274232
```bash
275233
php artisan make:mcp-prompt ExamplePrompt
276234
```
277235

278-
279-
280236
To make a prompt available to clients, you must register it in your server class in the `$prompts` property.
281237

282-
283-
284238
## Registering Servers
285239

286240
The easiest way to register MCP servers is by publishing the `routes/ai.php` file included with the package. If this file exists, the package will automatically load any servers registered via the `Mcp` facade. You can expose a server over HTTP or make it available locally as an Artisan command.
287241

288242
### Web Servers
289243

290-
To register a web-based MCP server that can be accessed via HTTP POST requests:
244+
To register a web-based MCP server that can be accessed via HTTP POST requests, you should use the `web` method:
291245

292246
```php
293247
use App\Mcp\Servers\ExampleServer;
@@ -317,8 +271,6 @@ This makes the server available via the `mcp:start` Artisan command:
317271
php artisan mcp:start demo
318272
```
319273

320-
321-
322274
## Authentication
323275

324276
Web-based MCP servers can be protected using [Laravel Passport](laravel.com/docs/passport), turning your MCP server into an OAuth2 protected resource.
@@ -347,8 +299,6 @@ Your MCP server is now protected using OAuth.
347299

348300
The [MCP Inspector](https://modelcontextprotocol.io/docs/tools/inspector) is an interactive tool for testing and debugging your MCP servers. You can use it to connect to your server, verify authentication, and try out tools, resources, and other parts of the protocol.
349301

350-
351-
352302
Run mcp:inspector to test your server:
353303

354304
```bash
@@ -357,8 +307,6 @@ php artisan mcp:inspector demo
357307

358308
This will run the MCP inspector and provide settings you can input to ensure it's setup correctly.
359309

360-
361-
362310
## Contributing
363311

364312
Thank you for considering contributing to Laravel MCP! You can read the contribution guide [here](.github/CONTRIBUTING.md).

0 commit comments

Comments
 (0)