gform_mcp_public_ability

Description

The gform_mcp_public_ability filter controls per-ability MCP visibility, applied at registration. It runs before the settings-screen gate, so it can hide a tool entirely but can’t expose one the admin hasn’t enabled.

Usage

The following would apply to all abilities.

add_filter( 'gform_mcp_public_ability', 'your_function_name', 10, 2 );
ParameterTypeDescription
$is_publicbooleanWhether the ability is publicly exposed to the MCP server.
$definitionarrayThe ability definition being registered.

Examples

Hide a Specific Ability From MCP.

add_filter( 'gform_mcp_public_ability', function ( $is_public, $definition ) {
	if ( 'gravityforms/system-info' === $definition['name'] ) {
		return false;
	}
	return $is_public;
}, 10, 2 );

Placement

This code can be used in the functions.php file of the active theme, a custom functions plugin, a custom add-on, or with a code snippets plugin.

See also the PHP section in this article: Where Do I Put This Code?

Source Code

This filter is located in gravityforms/includes/abilities/class-gf-abilities-service-provider.php

Since

The filter was added in Gravity Forms 3.1.0