1. Go to this page and download the library: Download hyperf/mcp-incubator 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/ */
hyperf / mcp-incubator example snippets
use Hyperf\Mcp\Annotation\Tool;
use Hyperf\Mcp\Server\Annotation\Server;
#[Server(name: 'stdio', signature: 'mcp:command', description: '这是一个测试命令')]
class Foo
{
#[Tool(name: 'sum', description: '计算两个数的和', serverName: 'stdio')]
public function sum(#[Description('这是A参数')] int $a, #[Description('这是B参数')] int $b = 0): int
{
return $a + $b;
}
}
use Hyperf\Mcp\Annotation\Tool;
use Hyperf\Mcp\Server\Annotation\Server;
#[Server(name: 'mcp-sse', description: '这是一个测试命令')]
class Foo
{
#[Tool(name: 'sum', description: '计算两个数的和', serverName: 'mcp-sse')]
public function sum(#[Description('这是A参数')] int $a, #[Description('这是B参数')] int $b = 0): int
{
return $a + $b;
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.