Last active
April 9, 2026 02:13
-
-
Save westonruter/3a37d35ef66cdd58315a7c1347d92560 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /** | |
| * Plugin Name: Expose All Abilities to MCP | |
| * 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 | |
| * Version: 1.1.1 | |
| * 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: https://gist.github.com/westonruter/3a37d35ef66cdd58315a7c1347d92560 | |
| * Primary Branch: main | |
| */ | |
| add_filter( | |
| '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. | |
| ! str_starts_with( $ability_id, 'mcp-adapter/' ) | |
| ) { | |
| $args['meta']['mcp']['public'] = true; | |
| } | |
| return $args; | |
| }, | |
| 10, | |
| 2 | |
| ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment