Created
February 26, 2026 04:52
-
-
Save vapvarun/c7dceefcbf74f080b68064c977532594 to your computer and use it in GitHub Desktop.
WordPress MCP Adapter: Code Snippets (wbcomdesigns.com)
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
| add_action( 'wp_abilities_api_init', function() { | |
| wp_register_ability( 'my-bp-plugin/list-inactive-members', array( | |
| 'label' => 'List Inactive Members', | |
| 'description' => 'Retrieve community members with no activity in the specified number of days.', | |
| 'input_schema' => array( | |
| 'type' => 'object', | |
| 'properties' => array( | |
| 'days_inactive' => array( | |
| 'type' => 'integer', | |
| 'description' => 'Number of days of inactivity', | |
| 'default' => 30, | |
| ), | |
| ), | |
| ), | |
| 'output_schema' => array( | |
| 'type' => 'array', | |
| 'items' => array( | |
| 'type' => 'object', | |
| 'properties' => array( | |
| 'user_id' => array( 'type' => 'integer' ), | |
| 'display_name' => array( 'type' => 'string' ), | |
| 'last_activity' => array( 'type' => 'string' ), | |
| 'group_count' => array( 'type' => 'integer' ), | |
| ), | |
| ), | |
| ), | |
| 'permission_callback' => function() { | |
| return current_user_can( 'list_users' ); | |
| }, | |
| 'execute_callback' => function( $input ) { | |
| // Your plugin's existing logic to query inactive members. | |
| $days = $input['days_inactive'] ?? 30; | |
| return my_bp_plugin_get_inactive_members( $days ); | |
| }, | |
| ) ); | |
| } ); |
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
| composer require wordpress/abilities-api wordpress/mcp-adapter |
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
| wp mcp-adapter list |
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
| echo '{"jsonrpc":"2.0","id":1,"method":"tools/list"}' | wp mcp-adapter serve --user=admin --server=mcp-adapter-default-server |
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
| { | |
| "mcpServers": { | |
| "my-community-site": { | |
| "command": "wp", | |
| "args": [ | |
| "--path=/path/to/your/wordpress", | |
| "mcp-adapter", | |
| "serve", | |
| "--server=mcp-adapter-default-server", | |
| "--user=admin" | |
| ] | |
| } | |
| } | |
| } |
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
| { | |
| "mcpServers": { | |
| "my-community-site": { | |
| "command": "npx", | |
| "args": ["-y", "@automattic/mcp-wordpress-remote@latest"], | |
| "env": { | |
| "WP_API_URL": "https://yoursite.com/wp-json/mcp/mcp-adapter-default-server", | |
| "WP_API_USERNAME": "your-username", | |
| "WP_API_PASSWORD": "your-application-password" | |
| } | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment