HOST
Laravel
The package wraps sveda-ai/client, mints Sanctum MCP tokens, and exposes StartSidecarSessionController.
1. Run sveda-server
Sidecar beside Laravel, not inside
php artisan serve.
CORS origin is the Laravel URL.
export SVEDA_EMBED_ENABLED=true
export SVEDA_BIND=0.0.0.0:8787
export SVEDA_EMBED_HOST_API_KEY=replace-me
export SVEDA_CORS_ORIGINS=http://127.0.0.1:8000
export DEEPSEEK_API_KEY=sk-...
sveda-server 2. Install the Laravel package
sveda-ai/client
comes in transitively. Publish config if you need to change MCP path or timeouts.
composer require sveda-ai/laravel-client
php artisan vendor:publish --tag=sveda-client-config 3. Env
Keys in
.env
map to
config/sveda-client.php.
Optional
SVEDA_CLIENT_MCP_URL
if the sidecar should call your
/mcp/sveda
server.
SVEDA_CLIENT_BASE_URL=http://127.0.0.1:8787
SVEDA_CLIENT_HOST_API_KEY=replace-me 4. Register POST /sveda/session
The package does not auto-register the route. Put it behind
auth
(or Sanctum). Unauthenticated → 401. Missing sidecar env → 404 from
HostManager.
use Sveda\LaravelClient\Http\Controllers\StartSidecarSessionController;
Route::post('/sveda/session', StartSidecarSessionController::class)
->middleware('auth')
->name('sveda.session'); use Sveda\LaravelClient\Facades\SvedaClient;
$session = SvedaClient::host()->startSession($request->user());
// origin, token, expires_in, appearance 5. Open the chat
Two options. Host buttons plus
sveda-host.js
(JS and iframe, same as PHP). Or the Blade component, which mounts
<sveda-chat session="/sveda/session">
when the base URL is set.
<html
lang="en"
data-sveda-origin="http://127.0.0.1:8787"
data-sveda-session="/sveda/session"
>
<body>
<button type="button" data-sveda-open="js">Open JS chat</button>
<button type="button" data-sveda-open="iframe">Open iframe chat</button>
<script type="module" src="/sveda-host.js"></script>
</body>
</html> <x-sveda::chat session="/sveda/session" /> 6. Optional host MCP tools
The package registers
/mcp/sveda
when Laravel MCP is installed. Tools you resolve here are what the sidecar lists during the turn.
use Sveda\LaravelClient\Facades\SvedaClient;
SvedaClient::host()->resolveToolsUsing(fn () => [
new SearchOrdersTool,
]);
SvedaClient::host()->authorizeUsing(fn ($user) => $user->can('use-ai'));