Skip to content

Instantly share code, notes, and snippets.

@westonruter
Last active April 9, 2026 02:13
Show Gist options
  • Select an option

  • Save westonruter/3a37d35ef66cdd58315a7c1347d92560 to your computer and use it in GitHub Desktop.

Select an option

Save westonruter/3a37d35ef66cdd58315a7c1347d92560 to your computer and use it in GitHub Desktop.

Revisions

  1. westonruter revised this gist Apr 9, 2026. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion expose-all-abilities-to-mcp.php
    Original file line number Diff line number Diff line change
    @@ -5,7 +5,7 @@
    * Description: Forces all registered abilities (wth the Abilities API) to be exposed to AI agents, only when running on a local environment.
    * Requires at least: 6.9
    * Requires PHP: 7.4
    * Version: 1.0.0
    * Version: 1.1.1
    * Author: Weston Ruter
    * Author URI: https://weston.ruter.net/
    * License: GPLv2 or later
  2. westonruter revised this gist Apr 9, 2026. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions expose-all-abilities-to-mcp.php
    Original file line number Diff line number Diff line change
    @@ -19,6 +19,7 @@
    'wp_register_ability_args',
    static function ( array $args, string $ability_id ): array {
    if (
    // Prevent exposing abilities in MCP except on a local dev environment.
    wp_get_environment_type() === 'local'
    &&
    // Omit abilities which the MCP Adapter already makes available itself.
  3. westonruter revised this gist Apr 9, 2026. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion expose-all-abilities-to-mcp.php
    Original file line number Diff line number Diff line change
    @@ -21,7 +21,7 @@ static function ( array $args, string $ability_id ): array {
    if (
    wp_get_environment_type() === 'local'
    &&
    // Omit abilities which MCP adapter already makes available via tools.
    // Omit abilities which the MCP Adapter already makes available itself.
    ! str_starts_with( $ability_id, 'mcp-adapter/' )
    ) {
    $args['meta']['mcp']['public'] = true;
  4. westonruter revised this gist Apr 9, 2026. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions expose-all-abilities-to-mcp.php
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,7 @@
    <?php
    /**
    * Plugin Name: Expose All Abilities to MCP
    * Plugin URI: ...
    * Plugin URI: https://gist.github.com/westonruter/3a37d35ef66cdd58315a7c1347d92560
    * Description: Forces all registered abilities (wth the Abilities API) to be exposed to AI agents, only when running on a local environment.
    * Requires at least: 6.9
    * Requires PHP: 7.4
    @@ -11,7 +11,7 @@
    * License: GPLv2 or later
    * License URI: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html
    * Update URI: false
    * Gist Plugin URI: ...
    * Gist Plugin URI: https://gist.github.com/westonruter/3a37d35ef66cdd58315a7c1347d92560
    * Primary Branch: main
    */

  5. westonruter revised this gist Apr 9, 2026. 1 changed file with 12 additions and 5 deletions.
    17 changes: 12 additions & 5 deletions expose-all-abilities-to-mcp.php
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,7 @@
    <?php
    /**
    * Plugin Name: Expose All Abilities to MCP
    * Plugin URI: https://gist.github.com/westonruter/3a37d35ef66cdd58315a7c1347d92560
    * Plugin URI: ...
    * Description: Forces all registered abilities (wth the Abilities API) to be exposed to AI agents, only when running on a local environment.
    * Requires at least: 6.9
    * Requires PHP: 7.4
    @@ -11,16 +11,23 @@
    * License: GPLv2 or later
    * License URI: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html
    * Update URI: false
    * Gist Plugin URI: https://gist.github.com/westonruter/3a37d35ef66cdd58315a7c1347d92560
    * Gist Plugin URI: ...
    * Primary Branch: main
    */

    add_filter(
    'wp_register_ability_args',
    static function ( array $args ): array {
    if ( wp_get_environment_type() === 'local' ) {
    static function ( array $args, string $ability_id ): array {
    if (
    wp_get_environment_type() === 'local'
    &&
    // Omit abilities which MCP adapter already makes available via tools.
    ! str_starts_with( $ability_id, 'mcp-adapter/' )
    ) {
    $args['meta']['mcp']['public'] = true;
    }
    return $args;
    }
    },
    10,
    2
    );
  6. westonruter revised this gist Apr 8, 2026. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions expose-all-abilities-to-mcp.php
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,7 @@
    <?php
    /**
    * Plugin Name: Expose All Abilities to MCP
    * Plugin URI: ...
    * Plugin URI: https://gist.github.com/westonruter/3a37d35ef66cdd58315a7c1347d92560
    * Description: Forces all registered abilities (wth the Abilities API) to be exposed to AI agents, only when running on a local environment.
    * Requires at least: 6.9
    * Requires PHP: 7.4
    @@ -11,7 +11,7 @@
    * License: GPLv2 or later
    * License URI: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html
    * Update URI: false
    * Gist Plugin URI: ...
    * Gist Plugin URI: https://gist.github.com/westonruter/3a37d35ef66cdd58315a7c1347d92560
    * Primary Branch: main
    */

  7. westonruter created this gist Apr 8, 2026.
    26 changes: 26 additions & 0 deletions expose-all-abilities-to-mcp.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,26 @@
    <?php
    /**
    * Plugin Name: Expose All Abilities to MCP
    * Plugin URI: ...
    * Description: Forces all registered abilities (wth the Abilities API) to be exposed to AI agents, only when running on a local environment.
    * Requires at least: 6.9
    * Requires PHP: 7.4
    * Version: 1.0.0
    * Author: Weston Ruter
    * Author URI: https://weston.ruter.net/
    * License: GPLv2 or later
    * License URI: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html
    * Update URI: false
    * Gist Plugin URI: ...
    * Primary Branch: main
    */

    add_filter(
    'wp_register_ability_args',
    static function ( array $args ): array {
    if ( wp_get_environment_type() === 'local' ) {
    $args['meta']['mcp']['public'] = true;
    }
    return $args;
    }
    );