Skip to content

Instantly share code, notes, and snippets.

@vapvarun
Created February 26, 2026 04:52
Show Gist options
  • Select an option

  • Save vapvarun/c7dceefcbf74f080b68064c977532594 to your computer and use it in GitHub Desktop.

Select an option

Save vapvarun/c7dceefcbf74f080b68064c977532594 to your computer and use it in GitHub Desktop.
WordPress MCP Adapter: Code Snippets (wbcomdesigns.com)
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 );
},
) );
} );
composer require wordpress/abilities-api wordpress/mcp-adapter
wp mcp-adapter list
echo '{"jsonrpc":"2.0","id":1,"method":"tools/list"}' | wp mcp-adapter serve --user=admin --server=mcp-adapter-default-server
{
"mcpServers": {
"my-community-site": {
"command": "wp",
"args": [
"--path=/path/to/your/wordpress",
"mcp-adapter",
"serve",
"--server=mcp-adapter-default-server",
"--user=admin"
]
}
}
}
{
"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