Skip to main content
Glama

wpnav_update_plugin

Update WordPress plugins to maintain security and functionality, with all changes tracked in an audit trail for accountability.

Instructions

Update a WordPress plugin to the latest version. Changes are logged in audit trail.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pluginYesPlugin identifier from wpnav_list_plugins "plugin" field (e.g., "wordfence/wordfence", "hello"). Do NOT include .php extension.

Implementation Reference

  • Registration of the wpnav_update_plugin tool using toolRegistry.register, including definition, schema, and handler reference.
    toolRegistry.register({ definition: { name: 'wpnav_update_plugin', description: 'Update a WordPress plugin to the latest version. Changes are logged in audit trail.', inputSchema: { type: 'object', properties: { plugin: { type: 'string', description: 'Plugin identifier from wpnav_list_plugins "plugin" field (e.g., "wordfence/wordfence", "hello"). Do NOT include .php extension.' }, }, required: ['plugin'], }, }, handler: async (args, context) => { try { validateRequired(args, ['plugin']); const result = await context.wpRequest(`/wp/v2/plugins/${normalizePluginPath(args.plugin)}`, { method: 'POST', body: JSON.stringify({ status: 'active' }), // Update endpoint uses POST with current status }); return { content: [{ type: 'text', text: context.clampText(JSON.stringify({ plugin: result.plugin, name: result.name, version: result.version, message: 'Plugin updated successfully', }, null, 2)), }], }; } catch (error: any) { const errorMessage = error.message || 'Unknown error'; const isWritesDisabled = errorMessage.includes('WRITES_DISABLED'); return { content: [{ type: 'text', text: JSON.stringify({ error: isWritesDisabled ? 'writes_disabled' : 'operation_failed', code: isWritesDisabled ? 'WRITES_DISABLED' : 'UPDATE_FAILED', message: errorMessage, context: { resource_type: 'plugin', plugin: args.plugin, suggestion: isWritesDisabled ? 'Set WPNAV_ENABLE_WRITES=1 in MCP server config (.mcp.json env section)' : 'Check plugin is installed with wpnav_list_plugins', }, }, null, 2), }], isError: true, }; } }, category: ToolCategory.PLUGINS, });
  • The handler function executes the plugin update by sending a POST request to the WordPress REST API endpoint /wp/v2/plugins/{plugin} with body {status: 'active'}. Includes error handling for writes disabled or failures.
    handler: async (args, context) => { try { validateRequired(args, ['plugin']); const result = await context.wpRequest(`/wp/v2/plugins/${normalizePluginPath(args.plugin)}`, { method: 'POST', body: JSON.stringify({ status: 'active' }), // Update endpoint uses POST with current status }); return { content: [{ type: 'text', text: context.clampText(JSON.stringify({ plugin: result.plugin, name: result.name, version: result.version, message: 'Plugin updated successfully', }, null, 2)), }], }; } catch (error: any) { const errorMessage = error.message || 'Unknown error'; const isWritesDisabled = errorMessage.includes('WRITES_DISABLED'); return { content: [{ type: 'text', text: JSON.stringify({ error: isWritesDisabled ? 'writes_disabled' : 'operation_failed', code: isWritesDisabled ? 'WRITES_DISABLED' : 'UPDATE_FAILED', message: errorMessage, context: { resource_type: 'plugin', plugin: args.plugin, suggestion: isWritesDisabled ? 'Set WPNAV_ENABLE_WRITES=1 in MCP server config (.mcp.json env section)' : 'Check plugin is installed with wpnav_list_plugins', }, }, null, 2), }], isError: true, }; } },
  • Input schema definition for the tool, specifying the required 'plugin' parameter as a string.
    inputSchema: { type: 'object', properties: { plugin: { type: 'string', description: 'Plugin identifier from wpnav_list_plugins "plugin" field (e.g., "wordfence/wordfence", "hello"). Do NOT include .php extension.' }, }, required: ['plugin'], },
  • Helper function to normalize the plugin path for WordPress REST API, handling URL encoding/decoding for plugin identifiers like 'wordfence/wordfence'.
    function normalizePluginPath(plugin: string): string { // First decode any URL-encoded characters (handles pre-encoded input from Claude Code) const decoded = decodeURIComponent(plugin); // Then encode individual parts but preserve the slash for /wp-json/ path format const result = decoded.split('/').map(part => encodeURIComponent(part)).join('/'); return result; }
  • TypeScript definition/schema for the tool in the main tools list, possibly for client-side validation or docs.
    { name: 'wpnav_update_plugin', description: 'Update a WordPress plugin to the latest version. Changes are logged in audit trail.', inputSchema: { type: 'object' as const, properties: { plugin: { type: 'string' as const, description: 'Plugin slug (e.g., "akismet/akismet.php")', }, }, required: ['plugin'], }, },

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/littlebearapps/wp-navigator-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server