PluginProbe
Imagify Image Optimization: Optimize Images | Compress & Convert to WebP/AVIF / 2.3.1
Imagify Image Optimization: Optimize Images | Compress & Convert to WebP/AVIF v2.3.1
2.3.4 2.3.3 2.3.2 2.3.1 2.3.0 2.2.9 2.2.8 trunk 1.10 1.3.3 1.3.4 1.3.5 1.3.5.1 1.3.5.2 1.3.6 1.3.6.1 1.4 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.4.6 1.4.7 1.5 All 103 releases
imagify / classes / MCP / ConfigSubscriber.php

ConfigSubscriber.php in Imagify Image Optimization: Optimize Images | Compress & Convert to WebP/AVIF 2.3.1, at classes/MCP/ConfigSubscriber.php

53 lines 1.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 declare(strict_types=1);
3
4 namespace Imagify\MCP;
5
6 use Imagify\EventManagement\SubscriberInterface;
7
8 /**
9 * Customizes the default MCP server configuration for Imagify.
10 *
11 * Subscribes to the `mcp_adapter_default_server_config` filter and sets
12 * the server name and description. All other keys (`server_id`, `route`,
13 * `tools`) are left untouched so the adapter keeps its canonical defaults.
14 *
15 * @since 2.3.0
16 */
17 class ConfigSubscriber implements SubscriberInterface {
18
19 /**
20 * Returns the events this subscriber listens to.
21 *
22 * @return array<string, string>
23 */
24 public static function get_subscribed_events(): array {
25 return [
26 // @filter mcp_adapter_default_server_config
27 'mcp_adapter_default_server_config' => 'customize_mcp_server',
28 ];
29 }
30
31 /**
32 * Customizes the MCP server name and description for Imagify.
33 *
34 * Only `server_name` and `server_description` are overridden. All other
35 * keys — including `server_id`, `server_route`, `server_route_namespace`,
36 * and `tools` — are preserved so the canonical REST endpoint path and the
37 * adapter's built-in tool set remain intact.
38 *
39 * @param array $config Default server configuration supplied by the adapter.
40 * @return array Modified configuration with Imagify name/description.
41 */
42 public function customize_mcp_server( array $config ): array {
43 $config['server_name'] = 'imagify-plugin';
44
45 $config['server_description'] = __(
46 'Image optimization tools for WordPress powered by Imagify.',
47 'imagify'
48 );
49
50 return $config;
51 }
52 }
53