PHP code example of sylius / mcp-server-plugin
1. Go to this page and download the library: Download sylius/mcp-server-plugin 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/ */
sylius / mcp-server-plugin example snippets
use Mcp\Capability\Attribute\McpTool;
use Mcp\Schema\Content\Content;
use Mcp\Schema\Content\TextContent;
use Sylius\McpServerPlugin\Tool\DownloadsImagesTrait;
use Symfony\Contracts\HttpClient\HttpClientInterface;
#[McpTool(name: 'my_tool', description: '...')]
final readonly class MyTool
{
use DownloadsImagesTrait;
public function __construct(private HttpClientInterface $httpClient) {}
/** @return Content[] */
public function __invoke(): array
{
$json = /* ... fetch JSON ... */;
$imageUrls = [/* ... extract image URLs from $json ... */];
return [new TextContent($json), ...$this->downloadImages($imageUrls)];
}
}