$contentMeta], ); } public function getWeather(string $city, RequestContext $context): string { $weather = [ 'london' => ['temp' => '15°C', 'condition' => 'Cloudy', 'humidity' => '78%'], 'paris' => ['temp' => '18°C', 'condition' => 'Sunny', 'humidity' => '55%'], 'tokyo' => ['temp' => '22°C', 'condition' => 'Partly Cloudy', 'humidity' => '65%'], 'new york' => ['temp' => '12°C', 'condition' => 'Rainy', 'humidity' => '85%'], 'lagos' => ['temp' => '30°C', 'condition' => 'Sunny', 'humidity' => '82%'], 'stockholm' => ['temp' => '4°C', 'condition' => 'Cloudy', 'humidity' => '70%'], 'berlin' => ['temp' => '9°C', 'condition' => 'Partly Cloudy', 'humidity' => '68%'], 'sydney' => ['temp' => '26°C', 'condition' => 'Sunny', 'humidity' => '60%'], 'buenos aires' => ['temp' => '24°C', 'condition' => 'Rainy', 'humidity' => '80%'], ]; $key = strtolower($city); $data = $weather[$key] ?? ['temp' => '20°C', 'condition' => 'Clear', 'humidity' => '60%']; $text = \sprintf( 'Weather in %s: %s, %s, Humidity: %s', $city, $data['temp'], $data['condition'], $data['humidity'], ); // Hosts without MCP Apps support only ever see this text; the ones that // negotiated the extension render the ui://weather-app view on top of it. if (!$context->getClientGateway()->supportsExtension(McpApps::EXTENSION_ID)) { return $text.' (text-only, host does not support MCP Apps)'; } return $text; } }