Skip to main content
Glama
microcmsio

microCMS MCP Server

by microcmsio

microcms_delete_media

Delete media files from microCMS via Management API. Supports images and files; fails if media is referenced by content.

Instructions

Delete media files from microCMS (Management API). Supports deletion of both images and files. Requires media deletion permissions. Note: Media referenced by content cannot be deleted.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
serviceIdNoService ID (required in multi-service mode, optional in single-service mode)
urlYesURL of the media to delete (e.g., "https://images.microcms-assets.io/assets/xxxxx/yyyyy/hoge.jpg" or "https://files.microcms-assets.io/assets/xxxxx/yyyyy/hoge.pdf"). Custom domain URLs are also supported.

Implementation Reference

  • Handler function that executes the delete media logic. It extracts the 'url' param, validates it, and calls the client helper 'deleteMedia'.
    export async function handleDeleteMedia(
      params: MediaToolParameters & { url: string },
      serviceId?: string
    ) {
      const { url } = params;
    
      if (!url) {
        throw new Error('url is required');
      }
    
      return await deleteMedia(url, serviceId);
    }
  • Actual API call to microCMS Management API v2. Sends a DELETE request to /api/v2/media with the media URL as a query parameter.
    export async function deleteMedia(
      mediaUrl: string,
      serviceId?: string
    ): Promise<{ id: string }> {
      const clients = getClientsForService(serviceId);
      const url = `https://${clients.serviceDomain}.microcms-management.io/api/v2/media?url=${encodeURIComponent(mediaUrl)}`;
    
      const response = await fetch(url, {
        method: 'DELETE',
        headers: {
          'X-MICROCMS-API-KEY': clients.apiKey,
        },
      });
    
      if (!response.ok) {
        const errorText = await response.text();
        throw new Error(
          `Failed to delete media: ${response.status} ${response.statusText} - ${errorText}`
        );
      }
    
      return await response.json();
    }
  • Tool definition and input schema for microcms_delete_media. Defines the name, description, and input schema (requires 'url' string, optional 'serviceId').
    export const deleteMediaTool: Tool = {
      name: 'microcms_delete_media',
      description:
        'Delete media files from microCMS (Management API). Supports deletion of both images and files. Requires media deletion permissions. Note: Media referenced by content cannot be deleted.',
      inputSchema: {
        type: 'object',
        properties: {
          serviceId: {
            type: 'string',
            description:
              'Service ID (required in multi-service mode, optional in single-service mode)',
          },
          url: {
            type: 'string',
            description:
              'URL of the media to delete (e.g., "https://images.microcms-assets.io/assets/xxxxx/yyyyy/hoge.jpg" or "https://files.microcms-assets.io/assets/xxxxx/yyyyy/hoge.pdf"). Custom domain URLs are also supported.',
          },
        },
        required: ['url'],
      },
    };
  • src/server.ts:127-127 (registration)
    Registration of the tool handler in the toolHandlers map, mapping 'microcms_delete_media' to handleDeleteMedia.
    microcms_delete_media: handleDeleteMedia,
  • src/server.ts:34-34 (registration)
    Import of deleteMediaTool and handleDeleteMedia from delete-media module into the server.
    import { deleteMediaTool, handleDeleteMedia } from './tools/delete-media.js';
Behavior4/5

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

No annotations are provided, so the description must disclose behavior. It correctly identifies the operation as deletion, notes permission requirements, and highlights a key constraint. However, it does not detail the permanence of deletion or confirmation behavior.

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 three sentences long, front-loaded with the main action, and every sentence adds necessary information without redundancy.

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

Completeness4/5

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

Given the two parameters, no output schema, and a straightforward delete operation, the description covers the essential use cases, prerequisites, and a notable limitation. It is mostly complete for an agent to invoke correctly.

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 coverage is 100%, so the baseline is 3. The description adds limited value beyond the schema's parameter descriptions, but the schema already adequately explains the parameters.

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

Purpose5/5

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

The description clearly states the action 'Delete media files' and specifies the resource type (media files, both images and files), distinguishing it from sibling tools like microcms_upload_media and microcms_delete_content.

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

Usage Guidelines4/5

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

The description mentions required permissions and a condition where deletion is not possible (media referenced by content). While it does not explicitly compare to alternatives, it provides sufficient context for appropriate use.

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/microcmsio/microcms-mcp-server'

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