PHP code example of datomatic / laravel-database-mcp

1. Go to this page and download the library: Download datomatic/laravel-database-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/ */

    

datomatic / laravel-database-mcp example snippets


'mysql_readonly' => [
    ...config('database.connections.mysql'),
    'username' => env('DB_READONLY_USERNAME'),
    'password' => env('DB_READONLY_PASSWORD'),
],

// config/database-mcp.php
return [
    'table_descriptions' => [
        'invoices' => 'Issued invoices. Revenue = SUM(total_amount) where status = paid.',
        'orders'   => 'Customer orders. grand_total is tax-inclusive.',
    ],

    'column_descriptions' => [
        'orders.grand_total' => 'Total in cents, tax 

// config/database-mcp.php
return [
    'middleware' => ['auth:api'], // Passport guard
];

use Illuminate\Support\Facades\Gate;

Gate::define('access-database-mcp', fn ($user) => $user->isSuperAdmin());

use Datomatic\LaravelDatabaseMcp\Servers\DatabaseServer;
use Laravel\Mcp\Facades\Mcp;

Mcp::web('database-mcp', DatabaseServer::class)
    ->middleware(['auth:sanctum', 'can:access-database-mcp']);
bash
php artisan vendor:publish --tag=database-mcp-config