1. Go to this page and download the library: Download upturnstudio/module-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/ */
upturnstudio / module-mcp example snippets
class MyTool implements \UpturnStudio\Mcp\Api\ToolInterface
{
public function getName(): string
{
return 'my_tool';
}
public function getDefinition(): array
{
return [
'description' => 'What this tool does.',
'inputSchema' => ['type' => 'object', 'properties' => (object) []],
];
}
public function execute(int $adminUserId, array $arguments): array
{
// Return an array on success. Throw ToolExecutionException to signal a refusal
// or failure (isError: true) instead of encoding it in the return value.
return ['ok' => true];
}
}