Skip to main content
Glama

wp_update_media

Modify metadata for existing WordPress media items including title, alt text, caption, and description to improve content management and SEO.

Instructions

Updates the metadata of an existing media item.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
siteNoThe ID of the WordPress site to target (from mcp-wordpress.config.json). Required if multiple sites are configured.
idYesThe ID of the media item to update.
titleNoThe new title for the media item.
alt_textNoThe new alternative text.
captionNoThe new caption.
descriptionNoThe new description.

Implementation Reference

  • MCP tool handler for wp_update_media. Validates parameters, delegates to WordPressClient.updateMedia, returns success message or error.
    public async handleUpdateMedia(client: WordPressClient, params: Record<string, unknown>): Promise<unknown> {
      const updateParams = params as unknown as UpdateMediaRequest & { id: number };
      try {
        const media = await client.updateMedia(updateParams);
        return `✅ Media ${media.id} updated successfully.`;
      } catch (_error) {
        throw new Error(`Failed to update media: ${getErrorMessage(_error)}`);
      }
    }
  • Tool definition and registration within MediaTools.getTools(), including name, description, input parameters schema, and handler reference.
    {
      name: "wp_update_media",
      description: "Updates the metadata of an existing media item.",
      parameters: [
        {
          name: "id",
          type: "number",
          required: true,
          description: "The ID of the media item to update.",
        },
        {
          name: "title",
          type: "string",
          description: "The new title for the media item.",
        },
        {
          name: "alt_text",
          type: "string",
          description: "The new alternative text.",
        },
        {
          name: "caption",
          type: "string",
          description: "The new caption.",
        },
        {
          name: "description",
          type: "string",
          description: "The new description.",
        },
      ],
      handler: this.handleUpdateMedia.bind(this),
    },
  • TypeScript interface UpdateMediaRequest defining the structure of input parameters for media updates, imported and used in the tool handler.
    export interface UpdateMediaRequest {
      id: number;
      title?: string;
      alt_text?: string;
      caption?: string;
      description?: string;
      post?: number;
      status?: PostStatus;
      author?: number;
    }
  • Low-level helper that destructures the id and performs the actual HTTP PUT request to WordPress REST API endpoint /wp/v2/media/{id}.
    async updateMedia(data: UpdateMediaRequest): Promise<WordPressMedia> {
      const { id, ...updateData } = data;
      return this.client.put<WordPressMedia>(`media/${id}`, updateData);
    }
  • Generic registration of all tools including MediaTools (which contains wp_update_media) by instantiating tool classes and calling getTools() to register each with the MCP server.
    public registerAllTools(): void {
      // Register all tools from the tools directory
      Object.values(Tools).forEach((ToolClass) => {
        let toolInstance: { getTools(): unknown[] };
    
        // Cache and Performance tools need the clients map
        if (ToolClass.name === "CacheTools" || ToolClass.name === "PerformanceTools") {
          toolInstance = new ToolClass(this.wordpressClients);
        } else {
          toolInstance = new (ToolClass as new () => { getTools(): unknown[] })();
        }
    
        const tools = toolInstance.getTools();
    
        tools.forEach((tool: unknown) => {
          this.registerTool(tool as ToolDefinition);
        });
      });
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. While 'Updates' implies a mutation operation, the description lacks critical details: it doesn't specify required permissions (e.g., editor/admin roles), whether changes are reversible, if partial updates are allowed, or what happens on failure. For a mutation tool with zero annotation coverage, this is a significant gap in transparency.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that directly states the tool's purpose without unnecessary words. It's front-loaded with the core action and resource, making it easy to parse. Every word earns its place, and there's no redundancy or fluff.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (mutation operation with 6 parameters) and lack of both annotations and output schema, the description is incomplete. It doesn't address behavioral aspects like permissions, side effects, or error handling, nor does it explain the return value. For a tool that modifies data, this leaves critical gaps for the agent to operate safely and effectively.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema fully documents all 6 parameters (site, id, title, alt_text, caption, description) with clear descriptions. The description adds no additional parameter semantics beyond what's in the schema, such as format examples or constraints. With high schema coverage, the baseline score of 3 is appropriate as the schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Updates') and resource ('metadata of an existing media item'), making the purpose unambiguous. It distinguishes itself from sibling tools like wp_delete_media, wp_get_media, and wp_upload_media by specifying it's for updating metadata rather than deletion, retrieval, or creation. However, it doesn't explicitly differentiate from wp_update_post or wp_update_page, which are also update operations on different resources.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites (e.g., needing an existing media ID), contrast with wp_upload_media for new media, or explain when to choose this over wp_update_post for media attached to posts. Without such context, the agent must infer usage from the tool name and schema alone.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/docdyhr/mcp-wordpress'

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