Skip to main content
Glama
microcmsio

microCMS MCP Server

by microcmsio

microcms_upload_media

Upload media files to microCMS by providing base64-encoded data with filename and MIME type, or by specifying an external URL. Returns the uploaded asset URL for use in content management.

Instructions

Upload media files to microCMS using JS SDK (Management API). Supports two methods: 1) Upload file data (base64) with filename and mimeType, 2) Upload from external URL. Returns microCMS asset URL. Requires media upload permissions. Available on Team, Business, Advanced, and Enterprise plans.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
fileDataNoBase64 encoded file data (for direct file upload)
fileNameNoFile name with extension (e.g., "image.jpg", "document.pdf") - required when using fileData
mimeTypeNoMIME type of the file (e.g., "image/jpeg", "application/pdf") - required when using fileData
externalUrlNoExternal URL of the file to upload (alternative to fileData)

Implementation Reference

  • Core implementation of the microcms_upload_media tool handler. Uploads media to microCMS using the management client, supporting base64-encoded file data (with size check) or external URL.
    export async function handleUploadMedia(params: MediaToolParameters) {
      const { fileData, fileName, mimeType, externalUrl } = params;
    
      try {
        // Method 1: Upload from external URL
        if (externalUrl) {
          const result = await microCMSManagementClient.uploadMedia({
            data: externalUrl,
          });
          return result;
        }
    
        // Method 2: Upload file data
        if (fileData && fileName && mimeType) {
          // Convert base64 to buffer
          const buffer = Buffer.from(fileData, 'base64');
    
          // Check file size (5MB limit)
          if (buffer.length > 5 * 1024 * 1024) {
            throw new Error('File size exceeds 5MB limit');
          }
    
          // Create Blob from buffer (for Node.js environment)
          const data = new Blob([buffer], { type: mimeType });
    
          const result = await microCMSManagementClient.uploadMedia({
            data,
            name: fileName,
          });
    
          return result;
        }
    
        throw new Error('Either externalUrl or (fileData + fileName + mimeType) must be provided');
      } catch (error) {
        if (error instanceof Error) {
          throw new Error(`Media upload failed: ${error.message}`);
        }
        throw new Error('Media upload failed: Unknown error');
      }
    }
  • Tool metadata including name, description, and input schema definition for the microcms_upload_media tool.
    export const uploadMediaTool: Tool = {
      name: 'microcms_upload_media',
      description: 'Upload media files to microCMS using JS SDK (Management API). Supports two methods: 1) Upload file data (base64) with filename and mimeType, 2) Upload from external URL. Returns microCMS asset URL. Requires media upload permissions. Available on Team, Business, Advanced, and Enterprise plans.',
      inputSchema: {
        type: 'object',
        properties: {
          fileData: {
            type: 'string',
            description: 'Base64 encoded file data (for direct file upload)',
          },
          fileName: {
            type: 'string',
            description: 'File name with extension (e.g., "image.jpg", "document.pdf") - required when using fileData',
          },
          mimeType: {
            type: 'string',
            description: 'MIME type of the file (e.g., "image/jpeg", "application/pdf") - required when using fileData',
          },
          externalUrl: {
            type: 'string',
            description: 'External URL of the file to upload (alternative to fileData)',
          },
        },
      },
    };
  • src/server.ts:47-72 (registration)
    Registers the uploadMediaTool (microcms_upload_media) in the server's list of available tools for the ListToolsRequest handler.
    server.setRequestHandler(ListToolsRequestSchema, async () => {
      return {
        tools: [
          getListTool,
          getListMetaTool,
          getContentTool,
          getContentMetaTool,
          createContentPublishedTool,
          createContentDraftTool,
          createContentsBulkPublishedTool,
          createContentsBulkDraftTool,
          updateContentPublishedTool,
          updateContentDraftTool,
          patchContentTool,
          patchContentStatusTool,
          patchContentCreatedByTool,
          deleteContentTool,
          getMediaTool,
          uploadMediaTool,
          deleteMediaTool,
          getApiInfoTool,
          getApiListTool,
          getMemberTool,
        ],
      };
    });
  • src/server.ts:127-129 (registration)
    Switch case in CallToolRequest handler that dispatches 'microcms_upload_media' calls to the handleUploadMedia function.
    case 'microcms_upload_media':
      result = await handleUploadMedia(params as unknown as MediaToolParameters);
      break;
  • src/server.ts:21-21 (registration)
    Import of the uploadMediaTool and its handler from the upload-media module.
    import { uploadMediaTool, handleUploadMedia } from './tools/upload-media.js';
Behavior4/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It effectively describes key behavioral traits: the two supported upload methods, the return value ('Returns microCMS asset URL'), authentication requirements ('Requires media upload permissions'), and plan availability constraints. It doesn't mention rate limits, error handling, or file size limitations, but covers the essential operational context.

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 efficiently structured in three sentences: purpose and methods, return value, and requirements. Every sentence adds essential information with zero wasted words, and the most critical information (what the tool does) is front-loaded.

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?

For a mutation tool with no annotations and no output schema, the description does a good job covering the essential context: purpose, methods, return value, and requirements. It could be more complete by mentioning error cases or file constraints, but given the schema's 100% coverage of parameters, it provides sufficient guidance for basic usage.

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 already documents all four parameters thoroughly. The description adds minimal value beyond the schema by mentioning the two upload methods (fileData vs externalUrl) and their relationships, but doesn't provide additional syntax, format, or constraint details that aren't already in the parameter descriptions.

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 specific action ('Upload media files'), target resource ('to microCMS'), and implementation method ('using JS SDK (Management API)'). It distinguishes itself from sibling tools like microcms_get_media (read) and microcms_delete_media (delete) by focusing on creation/upload functionality.

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 provides clear context about when to use this tool (uploading media files via two specific methods) and mentions prerequisites ('Requires media upload permissions', 'Available on Team, Business, Advanced, and Enterprise plans'). However, it doesn't explicitly state when NOT to use it or name specific alternatives among the sibling tools.

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