PHP code example of heihallo / mcp-kit
1. Go to this page and download the library: Download heihallo/mcp-kit 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/ */
heihallo / mcp-kit example snippets
'scheme' => 'shop',
'servers' => [
'shop' => [
'class' => App\Mcp\Servers\ShopServer::class,
'path' => '/mcp/shop',
'label' => 'Shop',
'wildcard' => 'shop:*',
'client_name' => 'shop',
'=> ['Search customers', 'customers', 'shop'],
],
'explicit_only' => [],
'service_client_writes' => [],
],
'permission_rules' => [
'staff_permission' => 'access admin',
'privileged_roles' => ['Owner', 'Dev'],
],
use HeiHallo\McpKit\Tools\StaffTool;
#[IsReadOnly]
class SearchOrdersTool extends StaffTool
{
protected string $name = 'search_orders';
protected string $description = 'Search orders by number, customer or status.';
protected array $inputSchema = ['type' => 'object', 'properties' => ['query' => ['type' => 'string']]];
public function handle(Request $request): Response
{
if ($denied = $this->
return $this->previewOrExecute(
$request,
['order' => $order->number, 'from' => $order->status, 'to' => $status],
fn () => ['order' => $order->refresh()->only('number', 'status')],
'Change order status',
['subject' => $order],
);
'neighbours' => [
'crm' => [
'label' => 'Acme CRM',
'owns' => 'People and everything around them: customers, signups, invoices',
'tools' => ['search_contacts', 'list_signups'],
'match' => ['customer', 'kunde', 'signup', 'signups', 'invoice', 'invoices', 'faktura*'],
'url' => 'https://crm.example.com/settings/tokens',
'ask' => 'Anything else worth saying about getting in.',
],
],
'hints' => [
'instead_of' => [
'get_thing' => ['use' => 'list_things', 'say' => 'takes a whole list at once', 'after' => 5],
],
],
// tests/Feature/Mcp/KitGuardsTest.php
Guards::all(inventory: __DIR__.'/tool-inventory.json');
// tests/Pest.php
Guards::actors(
staff: fn () => User::factory()->create(),
privileged: fn () => User::factory()->owner()->create(),
blocked: fn () => User::factory()->blocked()->create(),
serviceClient: fn () => ServiceClient::create(['name' => 'harness', 'slug' => 'harness']),
);
bash
composer mcp:install
php artisan migrate
bash
php artisan mcp:token [email protected]