MCP server
With laravel/mcp installed (Laravel 12+), AI agents can list sections, compose pages, preview them and, if allowed, publish.
Mounting
Give Inlay its own endpoint:
// routes/ai.php
Mcp::web('/mcp/pages', \WeArePixel\Inlay\Mcp\InlayServer::class)
->middleware(['auth:sanctum']);
or add its tools to a server you already run:
use WeArePixel\Inlay\Mcp\InlayTools;
protected array $tools = [MyTool::class, ...InlayTools::TOOLS];
protected array $resources = [...InlayTools::RESOURCES];
Tools
inlay-list-sections, inlay-list-page-types, inlay-list-pages, inlay-get-page, inlay-create-page, inlay-replace-sections, inlay-update-section, inlay-upload-image, inlay-preview-page, inlay-publish-page, inlay-get-styling, inlay-save-section, inlay-get-section and inlay-delete-section.
A section's blocks area is filled like any other setting - a list of {"type": ..., "settings": {...}} - and inlay-list-sections describes which blocks each area allows and their settings. Rich text from agents is sanitised before it's stored.
After every change agents get feedback: what each section renders, content still on section defaults, publish blockers and a signed preview link.
Access
Every tool authorises the request itself, so mounting them in a server with a wider audience doesn't widen who can edit pages.
Config (mcp.abilities) |
Default | Needed for |
|---|---|---|
manage |
inlay.manage-pages |
Every tool |
publish |
inlay.publish-pages |
Publishing, plus mcp.allow_publish => true (off by default) |
author |
inlay.author-sections |
Agent-authored sections |
Tools that act on a page pass it to the ability; tools that don't pass nothing, so declare it optional:
Gate::define('inlay.manage-pages', fn (User $user, ?Page $page = null) => $user->is_editor);
Spatie permissions with those names work as they are. mcp.writes_per_minute (60) rate-limits writes; mcp.max_image_kilobytes and mcp.max_image_pixels limit uploads.
Preview links
Call Inlay::previewLinkRoutes() from routes/web.php. Links are signed, expire after preview_links.ttl minutes (30), and are built from APP_URL, never the request's Host header. Their payload is held in the default cache store, which must be shared between processes - not array.
Screenshots
For desktop and mobile screenshots in inlay-preview-page, install spatie/browsershot (with Puppeteer) and set INLAY_SCREENSHOT_DRIVER=browsershot, or bind your own WeArePixel\Inlay\Contracts\Screenshotter. The renderer must be able to reach APP_URL. Clients that support MCP Apps also show the preview inline.
Agent-authored sections
With INLAY_AGENT_SECTIONS=true and the migrations run, users with inlay.author-sections (and inlay.manage-pages) can create sections with inlay-save-section. These are declarative - a JSON element tree, never Blade or PHP - and live as soon as they're saved. Changing or deleting one that a published page uses needs publish rights.
An agent section may only use classes your compiled CSS defines. inlay-get-styling gives the agent that list and your design tokens.
styling key |
Default | Purpose |
|---|---|---|
framework |
INLAY_CSS_FRAMEWORK, tailwind |
tailwind, bootstrap or plain. |
vite_manifest |
public/build/manifest.json |
Where the compiled CSS is found. |
vite_entries |
all CSS entries | Limit to the entries public pages load, e.g. ['resources/css/app.css']. |
stylesheets |
[] |
Extra compiled CSS files, for sites not built with Vite. |
extra_classes |
[] |
Classes that exist only as JavaScript hooks. |
denied_classes |
['fixed'] |
Never allowed, even when defined. |
Run npm run build after changing CSS. To make more Tailwind utilities available, safelist them (@source inline(...) in Tailwind v4) and rebuild.