PHP code example of kayedspace / laravel-mcp-bridge
1. Go to this page and download the library: Download kayedspace/laravel-mcp-bridge 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/ */
kayedspace / laravel-mcp-bridge example snippets
use KayedSpace\McpBridge\Attributes\McpTool;
#[McpTool(description: 'Create a draft course.')]
public function store(CourseStoreRequest $request)
{
// unchanged
}
use KayedSpace\McpBridge\Concerns\HasMcpTokens;
class User extends Authenticatable
{
use HasMcpTokens;
}
use KayedSpace\McpBridge\Attributes\McpAbility;
use KayedSpace\McpBridge\Attributes\McpScope;
use KayedSpace\McpBridge\Attributes\McpTool;
#[McpTool(description: 'Recalculate course statistics for a date range.')]
#[McpScope('ops:write')]
#[McpAbility('run-reports')]
class RecalculateStats extends Command
{
// unchanged
}
use App\Models\User;
use KayedSpace\McpBridge\Testing\InteractsWithMcp;
uses(InteractsWithMcp::class);
it('exposes the catalogue the way we meant', function () {
$this->assertToolExists('list_courses')
->assertToolReadOnly('list_courses')
->assertToolNeedsConfirmation('delete_course');
$result = $this->callMcpTool('list_courses', ['per_page' => 2], as: User::factory()->create());
expect($result->isError)->toBeFalse();
});
it('keeps its agent contract', function () {
expect($this->mcpContract())->toMatchSnapshot();
});