1. Go to this page and download the library: Download antidrift/zeromcp 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/ */
antidrift / zeromcp example snippets
// tools/hello.php — this is a complete MCP server
return [
'description' => 'Say hello to someone',
'input' => ['name' => 'string'],
'execute' => function ($args, $ctx) {
return "Hello, {$args['name']}!";
},
];
// $response = $server->handleRequest($request);
use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request;
use Slim\Factory\AppFactory;
$app = AppFactory::create();
$app->post('/mcp', function (Request $req, Response $res) use ($server) {
$body = json_decode((string) $req->getBody(), true);
$response = $server->handleRequest($body);
if ($response === null) {
return $res->withStatus(204);
}
$res->getBody()->write(json_encode($response));
return $res->withHeader('Content-Type', 'application/json');
});
$app->run();