1. Go to this page and download the library: Download seolinkmap/waasup 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/ */
seolinkmap / waasup example snippets
Slim\Factory\AppFactory;
use Slim\Psr7\Factory\{ResponseFactory, StreamFactory};
use Seolinkmap\Waasup\Storage\DatabaseStorage;
use Seolinkmap\Waasup\Tools\Registry\ToolRegistry;
use Seolinkmap\Waasup\Prompts\Registry\PromptRegistry;
use Seolinkmap\Waasup\Resources\Registry\ResourceRegistry;
use Seolinkmap\Waasup\Integration\Slim\SlimMCPProvider;
// Database connection
$pdo = new PDO('mysql:host=localhost;dbname=mcp_server', $user, $pass, [
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
]);
// Initialize components
$storage = new DatabaseStorage($pdo, ['table_prefix' => 'mcp_']);
$toolRegistry = new ToolRegistry();
$promptRegistry = new PromptRegistry();
$resourceRegistry = new ResourceRegistry();
$responseFactory = new ResponseFactory();
$streamFactory = new StreamFactory();
// Configuration
$config = [
'server_info' => [
'name' => 'My MCP Server',
'version' => '1.0.0'
],
'auth' => [
'context_types' => ['agency'],
'base_url' => 'https://your-domain.com'
]
];
// Create MCP provider
$mcpProvider = new SlimMCPProvider(
$storage,
$toolRegistry,
$promptRegistry,
$resourceRegistry,
$responseFactory,
$streamFactory,
$config
);
// Setup Slim app
$app = AppFactory::create();
$app->addErrorMiddleware(true, true, true);
// OAuth discovery endpoints
$app->get('/.well-known/oauth-authorization-server',
[$mcpProvider, 'handleAuthDiscovery']);
// Main MCP endpoint
$app->map(['GET', 'POST', 'OPTIONS'], '/mcp/{agencyUuid}[/{sessID}]',
[$mcpProvider, 'handleMCP'])
->add($mcpProvider->getAuthMiddleware());
$app->run();
use Seolinkmap\Waasup\Tools\Built\PingTool;
// Register the ping tool
$toolRegistry->registerTool(new PingTool());
// Tests connectivity and returns server timestamp
use Seolinkmap\Waasup\Tools\Built\ServerInfoTool;
// Register the server info tool
$toolRegistry->registerTool(new ServerInfoTool($config));
// Returns server configuration and capabilities
use PHPUnit\Framework\TestCase;
use Seolinkmap\Waasup\Storage\MemoryStorage;
class MCPServerTest extends TestCase
{
public function testToolExecution()
{
$storage = new MemoryStorage();
$toolRegistry = new ToolRegistry();
$toolRegistry->register('test_tool', function($params) {
return ['result' => 'success'];
});
$result = $toolRegistry->execute('test_tool', []);
$this->assertEquals(['result' => 'success'], $result);
}
}
http
GET /oauth/authorize?response_type=code&client_id=YOUR_CLIENT&redirect_uri=YOUR_CALLBACK
http
POST /oauth/token
Content-Type: application/x-www-form-urlencoded
grant_type=authorization_code&code=AUTH_CODE&client_id=YOUR_CLIENT
dockerfile
FROM php:8.1-fpm-alpine
RUN docker-php-ext-install pdo pdo_mysql
COPY . /var/www/html
WORKDIR /var/www/html
RUN composer install --no-dev --optimize-autoloader
EXPOSE 9000
CMD ["php-fpm"]