PHP code example of nexusphp / mcp-sdk
1. Go to this page and download the library: Download nexusphp/mcp-sdk 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/ */
nexusphp / mcp-sdk example snippets
declare(strict_types=1);
ntBlock\TextContent;
use Nexus\Mcp\Core\Schema\Result\CallToolResult;
use Nexus\Mcp\Core\Schema\Tool\Tool;
use Nexus\Mcp\Server\ServerBuilder;
use Nexus\Mcp\Server\ServerContext;
use Nexus\Mcp\Server\Transport\StdioServerTransport;
$server = new ServerBuilder()
->setServerInfo(name: 'hello', version: '0.1.0')
->addTool(
tool: new Tool(
name: 'greet',
inputSchema: [
'type' => 'object',
'properties' => ['name' => ['type' => 'string']],
'bash
npx @modelcontextprotocol/inspector php hello.php