Pagible CMS MCP 服务

Pagible MCP 是 Pagible CMS 的 MCP 服务器,提供 43 个工具用于管理页面、元素、文件、前端访问及 AI 内容操作,并支持在 Laravel 应用中集成自定义业务工具。

  • by aimeos
  • PHP
  • 本地部署
  • 更新于
在 GitHub 查看 aimeos/pagible-mcp

使用说明

Pagible MCP

MCP server for Pagible CMS with 43 tools for managing pages, elements, files, frontend access (32 core tools), and AI-powered content operations (11 tools provided by the AI package). See MCP.md for setup and usage.

This package is part of the Pagible CMS monorepo. For full installation, use:

composer require aimeos/pagible

Custom tools

Your application can offer its own tools next to the CMS tools, e.g. to give agents access to your orders. Extend Aimeos\Cms\Tools\Tool, which checks the permissions in PERMISSIONS before calling run() and hides the tool from users without them (an empty list denies access to everyone):

namespace App\Mcp;

use Aimeos\Cms\Tools\Tool;
use App\Models\Order;
use Illuminate\Contracts\JsonSchema\JsonSchema;
use Laravel\Mcp\Request;
use Laravel\Mcp\Response;
use Laravel\Mcp\ResponseFactory;
use Laravel\Mcp\Server\Attributes\Description;
use Laravel\Mcp\Server\Attributes\Name;
use Laravel\Mcp\Server\Tools\Annotations\IsReadOnly;

#[IsReadOnly]
#[Name('get-orders')]
#[Description('Returns the latest orders with their ID, status and total.')]
class GetOrders extends Tool
{
    protected const PERMISSIONS = ['order:view'];

    public function schema( JsonSchema $schema ) : array
    {
        return [
            'limit' => $schema->integer()->description( 'Number of orders, 10 by default' ),
        ];
    }

    protected function run( Request $request ) : ResponseFactory
    {
        $v = $request->validate( ['limit' => 'nullable|integer|min:1|max:50'] );
        $orders = Order::latest()->limit( $v['limit'] ?? 10 )->get( ['id', 'status', 'total'] );

        return Response::structured( ['orders' => $orders->toArray()] );
    }
}

Register the tool and its permission in the boot() method of a service provider:

use Aimeos\Cms\Mcp\CmsServer;
use Aimeos\Cms\Permission;

Permission::register( 'order:view' );
CmsServer::register( [\App\Mcp\GetOrders::class] );

Users with the admin role get new permissions by its * wildcard. Grant them to others by Permission::set() or add them to a role in cms.roles. Within run(), $request->user() is the authenticated user, so pass it to the facades in Aimeos\Cms\Facades to apply the CMS permissions to content changes too. Thrown Aimeos\Cms\Exception errors and missing models are returned as error message to the client.

Registered tools are offered by the MCP server only, the AI chat of the admin panel uses the built-in CMS tools.

Commands

cms:install:mcp

Installs the Pagible MCP package.

php artisan cms:install:mcp

Publishes the Laravel MCP routes.

License

MIT