$a + $b, 'subtract', '-' => $a - $b, 'multiply', '*' => $a * $b, 'divide', '/' => 0 != $b ? $a / $b : 'Error: Division by zero', default => 'Error: Unknown operation. Use: add, subtract, multiply, divide', }; } /** * Server information resource. * * @return array{status: string, timestamp: int, version: string, transport: string, uptime: int} */ #[McpResource( uri: 'info://server/status', name: 'server_status', description: 'Current server status and information', mimeType: 'application/json' )] public function getServerStatus(): array { return [ 'status' => 'running', 'timestamp' => time(), 'version' => '1.0.0', 'transport' => 'HTTP', 'uptime' => time() - $_SERVER['REQUEST_TIME'], ]; } /** * Configuration resource. * * @return array{debug: bool, environment: string, timezone: string, locale: string} */ #[McpResource( uri: 'config://app/settings', name: 'app_config', description: 'Application configuration settings', mimeType: 'application/json' )] public function getAppConfig(): array { return [ 'debug' => $_SERVER['DEBUG'] ?? false, 'environment' => $_SERVER['APP_ENV'] ?? 'production', 'timezone' => date_default_timezone_get(), 'locale' => 'en_US', ]; } /** * Greeting prompt. * * @return array{role: string, content: string} */ #[McpPrompt( name: 'greet', description: 'Generate a personalized greeting message' )] public function greetPrompt(string $firstName = 'World', string $timeOfDay = 'day'): array { $greeting = match (strtolower($timeOfDay)) { 'morning' => 'Good morning', 'afternoon' => 'Good afternoon', 'evening', 'night' => 'Good evening', default => 'Hello', }; return [ 'role' => 'user', 'content' => "# {$greeting}, {$firstName}!\n\nWelcome to our MCP HTTP Server example. This demonstrates how to use the Model Context Protocol over HTTP transport.", ]; } }