feat: Add tool for updating single and multiple WordPress plugins#74
feat: Add tool for updating single and multiple WordPress plugins#74Ref34t wants to merge 1 commit intoAutomattic:trunkfrom
Conversation
|
Hey @galatanovidiu did you have a chance to check this? |
Sorry for the late reply. I was on vacation, then I had to catch up with my daily work. Thank you for this comprehensive PR! I can see you've put a lot of work into it. The plugin update functionality will be a valuable addition to the WordPress MCP framework. I will try to review this PR today or tomorrow. |
galatanovidiu
left a comment
There was a problem hiding this comment.
Sorry again for not getting back to you sooner. I have too many things to.
I just wanted to let you know that everything works well for me.
Only one suggestion for when you have time.
Could we please add a test for this?. I've created a PR that contains a test that is highly vibe-coded. You can see it here: https://github.com/Automattic/wordpress-mcp/pull/100/files#diff-8a1efcf96a7527dee3098d53780b72ac1429d0aa9d5923b237a1b6f35be1f456.
I will close my PR after we merge yours.
Thank you very much for taking the time to build this tool.
Description
This Pull Request introduces a new tool,
update_plugins, to the WordPress MCP framework. This tool enables AI assistants to programmatically initiate updates for one or more specified WordPress plugins. It aims to enhance the MCP's capabilities by providing a robust and controlled mechanism for plugin management, directly leveraging WordPress core update functionalities.Motivation
Currently, the WordPress MCP provides resources to retrieve plugin information but lacks a direct mechanism for AI assistants to trigger plugin updates. This new tool addresses that gap, allowing for more comprehensive and automated management of WordPress installations through AI-driven interfaces. This feature is crucial for maintaining site security and performance by ensuring plugins are kept up-to-date.
Technical Implementation Details
New File
includes/Tools/McpPluginUpdateTools.php: This file contains theMcpPluginUpdateToolsclass, which implements the core logic for theupdate_pluginstool.Modifications
includes/Core/WpMcp.php: This file was modified to:McpPluginUpdateToolsclass via ausestatement.McpPluginUpdateToolswithin theinit_default_tools()method, ensuring the tool is registered with the MCP framework upon initialization.Tool Details
update_pluginsplugin_slugs(array|string, required): A single plugin slug (e.g.,'akismet') or an array of plugin slugs (e.g.,['akismet', 'woocommerce']) to be updated. Plugin slugs can be obtained from theplugin-inforesource.The tool returns a JSON array of objects, where each object contains the status of an update attempt for a specific plugin. For each plugin, the output includes:
plugin_slug(string): The slug of the plugin that was targeted for update.status(string): The result of the update operation. Possible values includesuccess,failed,not_found, orno_update_available.message(string): A human-readable message providing more details about the update status, including any error messages if the update failed.Error Handling
The tool handles the following error conditions:
plugin_slugsparameter is empty or not provided, the tool returns afailedstatus with an appropriate message.not_found.no_update_available.wp_update_pluginreturning aWP_Error), the status will befailed, and an appropriate error message will be provided.Testing Plan
✅ Live Testing Completed
This feature has been thoroughly tested in a live WordPress environment during development. The following tests were performed:
Successfully Updated Plugins with Version Tracking:
Plugins Already Up-to-Date:
Verified Response Format:
old_versionfield correctly populatednew_versionfield correctly populatedreactivatedstatus properly reportedTest Environment:
All tests confirmed the feature works as expected and provides valuable version tracking information that was previously missing.
Unit Testing
plugin_slugs(empty, single string, array of strings).wp_update_plugin()to ensure correct calls and error handling for success and failure cases.success,failed,not_found,no_update_available).Integration Testing
update_pluginstool registration with MCP.wp_update_plugin()through the MCP tool's output.Manual Testing
Future Considerations
Checklist: