__('FluentCRM', 'fluent-crm'), 'description' => __('Contact, campaign, and automation abilities for FluentCRM.', 'fluent-crm'), ]); } public function registerAbilities() { AbilitiesRegistrar::register(); /** * Fires after FluentCRM has registered its core MCP abilities. * * FluentCampaign Pro hooks this to register its 4 Pro abilities under * the same `fluent-crm/` namespace — agents do not need to know which * plugin owns which tool. * * @since 2.10.0 */ do_action('fluent_crm/mcp_loaded'); } /** * Register the dedicated FluentCRM MCP server when the WP MCP Adapter * fires `mcp_adapter_init`. * * @param \WP\MCP\Core\McpAdapter $adapter */ public function registerCustomServer($adapter) { if (!$adapter || !is_object($adapter) || !method_exists($adapter, 'create_server')) { return; } $abilityNames = array_keys(AbilitiesRegistrar::getDefinitions()); /** * Filter the list of FluentCRM ability names registered with the * dedicated FluentCRM MCP server. * * FluentCampaign Pro hooks this filter (in its own MCPInit) to push * its 4 Pro abilities into the same server. Other extensions can do * the same to surface tools agents discover via `tools/list`. * * @since 2.10.0 * * @param array $abilityNames Array of fully-qualified ability names. */ $abilityNames = apply_filters('fluent_crm/mcp_ability_names', $abilityNames); // Allow operators to swap the route via filter. Default puts the // server at /wp-json/fluent-crm/mcp — sibling to the existing // FluentCRM REST namespace (fluent-crm/v2), but distinct so it does // not get caught by the v2 policy stack. $namespace = apply_filters('fluent_crm/mcp_server_namespace', 'fluent-crm'); $route = apply_filters('fluent_crm/mcp_server_route', 'mcp'); $adapter->create_server( 'fluent-crm', $namespace, $route, __('FluentCRM MCP Server', 'fluent-crm'), __('AI agent tools for FluentCRM contacts, campaigns, and automations.', 'fluent-crm'), defined('FLUENTCRM_PLUGIN_VERSION') ? FLUENTCRM_PLUGIN_VERSION : '1.0.0', ['\WP\MCP\Transport\HttpTransport'], '\WP\MCP\Infrastructure\ErrorHandling\ErrorLogMcpErrorHandler', '\WP\MCP\Infrastructure\Observability\NullMcpObservabilityHandler', array_values(array_unique(array_filter((array) $abilityNames))) ); } /** * Public helper used by the Settings UI and the snippet generator to * report a stable endpoint URL for the FluentCRM MCP server. */ public static function getEndpointUrl() { $namespace = apply_filters('fluent_crm/mcp_server_namespace', 'fluent-crm'); $route = apply_filters('fluent_crm/mcp_server_route', 'mcp'); return get_rest_url(null, trailingslashit($namespace) . $route); } }