PHP code example of gesagtgetan / neos-mcp
1. Go to this page and download the library: Download gesagtgetan/neos-mcp 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/ */
gesagtgetan / neos-mcp example snippets
use GesagtGetan\NeosMcp\Tool\McpRequestContext;
use GesagtGetan\NeosMcp\Tool\McpToolProvider;
use GesagtGetan\NeosMcp\Tool\McpToolReflector;
use Neos\Flow\Annotations as Flow;
use PhpMcp\Server\Attributes\McpTool;
use PhpMcp\Server\Defaults\BasicContainer;
use PhpMcp\Server\ServerBuilder;
#[Flow\Scope('singleton')]
final readonly class EchoToolProvider implements McpToolProvider
{
public function registerTools(ServerBuilder $builder, BasicContainer $container, McpRequestContext $context): ServerBuilder
{
$container->set(self::class, $this);
return McpToolReflector::register($builder, self::class);
}
#[McpTool(description: 'Echo a string back')]
public function echo(string $message): string
{
return $message;
}
}