PHP code example of afiqsazlan / laravel-mcp-safe-sql
1. Go to this page and download the library: Download afiqsazlan/laravel-mcp-safe-sql 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/ */
afiqsazlan / laravel-mcp-safe-sql example snippets
// A gate — nothing extra needed
Gate::define('access-research', fn (User $user) => $user->hasRole('analyst'));
// An explicit allowlist, while you are still deciding who should have it
Gate::define('access-research', fn (User $user) => in_array($user->id, [1, 5], true));
// spatie/laravel-permission — swap the middleware instead
->middleware(['auth:oauth', 'scope:mcp:use', 'permission:access-research'])
Event::listen(QueryExecuted::class, function (QueryExecuted $event) {
Log::channel('audit')->info('safe-sql query', $event->context());
});