PHP code example of decocode / laravel-mcp

1. Go to this page and download the library: Download decocode/laravel-mcp library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

decocode / laravel-mcp example snippets


use Decocode\LaravelMcp\Servers\DiagnosticsServer;
use Laravel\Mcp\Facades\Mcp;

// Local/stdio (Claude Code, MCP Inspector via `php artisan mcp:inspector`):
Mcp::local('diagnostics', DiagnosticsServer::class);

// Public HTTPS (claude.ai), behind the mcp guard + IP allowlist + throttle:
Mcp::oauthRoutes();
Mcp::web('/mcp/diagnostics', DiagnosticsServer::class)
    ->middleware(['auth:mcp', 'mcp.ip-allowlist', 'throttle:'.config('mcp.http.throttle')]);
bash
php artisan mcp:audit:report                          # last 7 days
php artisan mcp:audit:report --since="-2 hours"       # around an incident
php artisan mcp:audit:report --masked-only            # only calls that filtered on a masked column
php artisan mcp:audit:report --tool=read_query --outcome=rejected
php artisan mcp:audit:report --since=2026-07-01 --json | jq .masked_column_activity