1. Go to this page and download the library: Download everrest/context-gate 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/ */
// a service provider
Gate::define('routes.list.allow', fn (ContextGate\Server\Caller $caller) => true);
'classification' => [
'customers' => [
'id' => 'personal',
'country' => 'internal',
'lifetime_value' => 'personal',
'created_at' => 'internal',
'notes' => 'internal',
'email' => 'personal',
'password' => 'secret',
],
// keep the five source_* tables of the stock file when you add your own
],
namespace App\Gate;
use App\Models\Customer;
use ContextGate\Contract\ContextContract;
use ContextGate\Contract\Field;
final class CustomerContract extends ContextContract
{
public function model(): string
{
return Customer::class;
}
public function fields(): array
{
return [
'id' => Field::pseudonym('CUS'), // personal: a stand-in for this record
'country' => Field::plain(), // internal
'lifetime_value' => Field::bucket([100, 1000, 10000]), // personal: a band, never the amount
'created_at' => Field::date('month'), // internal: "2026-03"
'notes' => Field::text(), // internal, user-written: redacted and quarantined
];
}
}
use ContextGate\Contracts\AuthorizesTools;
use ContextGate\Contracts\RedactsText;
use ContextGate\Server\Caller;
final class OrderNumberRedactor implements RedactsText
{
public function redact(string $text): string
{
return preg_replace('/\bORD-\d{6}\b/', '[order]', $text) ?? '';
}
}
final class OnCallOnly implements AuthorizesTools
{
public function allows(string $tool, Caller $caller, array $arguments): bool
{
return $tool === 'customers.lookup' && $caller->id === 'token:12'; // everything else: false
}
}
// in a service provider's register()
$this->app->bind(RedactsText::class, OrderNumberRedactor::class);
$this->app->bind(AuthorizesTools::class, OnCallOnly::class);
namespace App\Mcp;
use App\Models\Customer;
use ContextGate\Server\Tool;
use Laravel\Mcp\Response;
final class CustomerLookupTool extends Tool
{
public function name(): string
{
return 'customers.lookup';
}
public function description(): string
{
return 'Returns one customer by pseudonym: country, lifetime value band, signup month and notes.';
}
public function schema(): array
{
return [
'type' => 'object',
'properties' => ['id' => ['type' => 'string', 'pattern' => '^CUS_[0-9a-f]{10,64}$', 'description' => 'Customer pseudonym']],
'
bash
composer gate:install # publishes config/context-gate.php: enabled=false, tools=[]
php artisan migrate # token tables
php artisan gate:check # must exit 0 before the gate serves traffic
bash
php artisan gate:fingerprint routes.list # paste the output into the entry
php artisan gate:check
php artisan gate:preview routes.list # what alice would receive, plus dropped fields and reasons