Skip to content

Commit 944d78c

Browse files
chore: Upgrade php-mcp/server to version ^3.0 and refactor transport handling
- Updated `php-mcp/server` dependency to version `^3.0` in composer.json. - Refactored HTTP transport handling by removing the old `McpController` and introducing `SseTransportController` and `StreamableTransportController`. - Enhanced configuration options in `mcp.php` for dedicated and integrated HTTP transports, including support for JSON responses and event stores. - Updated routing to use a new web.php file for handling transport routes. - Improved session management and logging configurations in the MCP setup. - Adjusted command outputs for clarity when starting the MCP server.
1 parent 62a3818 commit 944d78c

21 files changed

+1045
-331
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"require": {
2222
"php": "^8.1",
2323
"laravel/framework": "^9.46 || ^10.34 || ^11.29 || ^12.0",
24-
"php-mcp/server": "^2.3"
24+
"php-mcp/server": "^3.0"
2525
},
2626
"require-dev": {
2727
"laravel/pint": "^1.13",

config/mcp.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,21 +80,43 @@
8080

8181
'http_dedicated' => [
8282
'enabled' => (bool) env('MCP_HTTP_DEDICATED_ENABLED', true),
83+
'legacy' => (bool) env('MCP_HTTP_DEDICATED_LEGACY', false),
8384
'host' => env('MCP_HTTP_DEDICATED_HOST', '127.0.0.1'),
8485
'port' => (int) env('MCP_HTTP_DEDICATED_PORT', 8090),
8586
'path_prefix' => env('MCP_HTTP_DEDICATED_PATH_PREFIX', 'mcp'),
8687
'ssl_context_options' => [],
88+
'enable_json_response' => (bool) env('MCP_HTTP_DEDICATED_JSON_RESPONSE', true),
89+
'event_store' => env('MCP_HTTP_DEDICATED_EVENT_STORE'), // FQCN or null
8790
],
8891

8992
'http_integrated' => [
9093
'enabled' => (bool) env('MCP_HTTP_INTEGRATED_ENABLED', true),
94+
'legacy' => (bool) env('MCP_HTTP_INTEGRATED_LEGACY', false),
9195
'route_prefix' => env('MCP_HTTP_INTEGRATED_ROUTE_PREFIX', 'mcp'),
9296
'middleware' => explode(',', env('MCP_HTTP_INTEGRATED_MIDDLEWARE', 'web')),
9397
'domain' => env('MCP_HTTP_INTEGRATED_DOMAIN'),
9498
'sse_poll_interval' => (int) env('MCP_HTTP_INTEGRATED_SSE_POLL_SECONDS', 1),
99+
'cors_origin' => env('MCP_HTTP_INTEGRATED_CORS_ORIGIN', '*'),
100+
'enable_json_response' => (bool) env('MCP_HTTP_INTEGRATED_JSON_RESPONSE', true),
101+
'json_response_timeout' => (int) env('MCP_HTTP_INTEGRATED_JSON_TIMEOUT', 30),
102+
'event_store' => env('MCP_HTTP_INTEGRATED_EVENT_STORE'), // FQCN or null
95103
],
96104
],
97105

106+
/*
107+
|--------------------------------------------------------------------------
108+
| Session Management Configuration
109+
|--------------------------------------------------------------------------
110+
|
111+
| Configure how the MCP server manages client sessions. Sessions store
112+
| client state, message queues, and subscriptions.
113+
|
114+
*/
115+
'session' => [
116+
'driver' => env('MCP_SESSION_DRIVER', 'cache'), // 'array' or 'cache'
117+
'ttl' => (int) env('MCP_SESSION_TTL', 3600), // Session lifetime in seconds
118+
],
119+
98120
/*
99121
|--------------------------------------------------------------------------
100122
| Pagination Limit

routes/mcp_http_integrated.php

Lines changed: 0 additions & 25 deletions
This file was deleted.

routes/web.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php
2+
3+
use Illuminate\Support\Facades\Route;
4+
use PhpMcp\Laravel\Http\Controllers\StreamableTransportController;
5+
use PhpMcp\Laravel\Http\Controllers\SseTransportController;
6+
7+
if (config('mcp.transports.http_integrated.legacy', false)) {
8+
Route::get('/sse', [SseTransportController::class, 'handleSse'])
9+
->name('mcp.sse');
10+
11+
Route::post('/message', [SseTransportController::class, 'handleMessage'])
12+
->name('mcp.message');
13+
} else {
14+
Route::get('/', [StreamableTransportController::class, 'handleGet'])
15+
->name('mcp.streamable.get');
16+
17+
Route::post('/', [StreamableTransportController::class, 'handlePost'])
18+
->name('mcp.streamable.post');
19+
20+
Route::delete('/', [StreamableTransportController::class, 'handleDelete'])
21+
->name('mcp.streamable.delete');
22+
}

0 commit comments

Comments
 (0)