Skip to main content
Glama
microcmsio

microCMS MCP Server

by microcmsio

microcms_get_media

Retrieve media files from microCMS with filtering options for images, filenames, and pagination support for managing content assets.

Instructions

Get media files from microCMS (Management API). Returns media information including URLs, dimensions for images. Supports pagination via token (15-second validity). Requires media retrieval permissions.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
limitNoNumber of media to retrieve (max 100, default 10). Only valid on first request.
imageOnlyNoSet to true to retrieve only image files. Only valid on first request.
fileNameNoFilter media by partial filename match (includes file extension)
tokenNoContinuation token for pagination (obtained from previous response, 15-second validity)

Implementation Reference

  • The handler function that executes the tool logic: constructs query parameters from input, makes an authenticated GET request to the microCMS Management API /media endpoint, and returns the JSON response.
    export async function handleGetMedia(params: MediaToolParameters) {
      const queryParams = new URLSearchParams();
    
      if (params.limit) queryParams.append('limit', params.limit.toString());
      if (params.imageOnly) queryParams.append('imageOnly', 'true');
      if (params.fileName) queryParams.append('fileName', params.fileName);
      if (params.token) queryParams.append('token', params.token);
    
      const response = await fetch(
        `https://${microCMSConfig.serviceDomain}.microcms-management.io/api/v2/media?${queryParams}`,
        {
          method: 'GET',
          headers: {
            'X-MICROCMS-API-KEY': microCMSConfig.apiKey,
          },
        }
      );
    
      if (!response.ok) {
        throw new Error(`Media retrieval failed: ${response.status} ${response.statusText}`);
      }
    
      return await response.json();
    }
  • Tool definition object including name, description, and detailed inputSchema for validation of parameters (limit, imageOnly, fileName, token).
    export const getMediaTool: Tool = {
      name: 'microcms_get_media',
      description: 'Get media files from microCMS (Management API). Returns media information including URLs, dimensions for images. Supports pagination via token (15-second validity). Requires media retrieval permissions.',
      inputSchema: {
        type: 'object',
        properties: {
          limit: {
            type: 'number',
            description: 'Number of media to retrieve (max 100, default 10). Only valid on first request.',
            minimum: 1,
            maximum: 100,
          },
          imageOnly: {
            type: 'boolean',
            description: 'Set to true to retrieve only image files. Only valid on first request.',
          },
          fileName: {
            type: 'string',
            description: 'Filter media by partial filename match (includes file extension)',
          },
          token: {
            type: 'string',
            description: 'Continuation token for pagination (obtained from previous response, 15-second validity)',
          },
        },
        required: [],
      },
    };
  • TypeScript interface defining the MediaToolParameters used by the handler, matching the inputSchema properties.
    export interface MediaToolParameters {
      limit?: number;
      imageOnly?: boolean;
      fileName?: string;
      token?: string;
      fileData?: string;
      mimeType?: string;
      externalUrl?: string;
      url?: string;
    }
  • src/server.ts:124-126 (registration)
    Switch case in CallToolRequest handler that routes 'microcms_get_media' calls to the handleGetMedia function.
    case 'microcms_get_media':
      result = await handleGetMedia(params as unknown as MediaToolParameters);
      break;
  • src/server.ts:20-20 (registration)
    Import of the tool definition (getMediaTool) and handler (handleGetMedia) from the get-media module.
    import { getMediaTool, handleGetMedia } from './tools/get-media.js';
Behavior4/5

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

With no annotations provided, the description carries full burden and adds valuable behavioral context: it discloses pagination with a 15-second token validity, specifies that it returns media information including URLs and dimensions for images, and mentions permission requirements. However, it doesn't cover rate limits, error handling, or response format details beyond what's implied.

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 two sentences: the first states purpose and return details, the second covers pagination and permissions. Every sentence adds value with no wasted words, making it front-loaded and easy to parse.

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

Completeness3/5

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

For a read operation with 4 parameters, 100% schema coverage, and no output schema, the description is moderately complete. It covers key behavioral aspects like pagination and permissions, but lacks details on response format, error cases, or examples. Given the complexity and absence of annotations/output schema, it could benefit from more context on what 'media information' includes beyond URLs/dimensions.

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 4 parameters. The description adds no parameter-specific information beyond what's in the schema (e.g., it doesn't explain 'limit' or 'token' further). Baseline 3 is appropriate as the schema does the heavy lifting, but the description doesn't compensate with additional semantic context.

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 verb ('Get') and resource ('media files from microCMS'), specifying it uses the Management API. It distinguishes from siblings like 'microcms_delete_media' or 'microcms_upload_media' by focusing on retrieval, but doesn't explicitly differentiate from similar read operations like 'microcms_get_content' or 'microcms_get_list' beyond mentioning media files.

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

Usage Guidelines3/5

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

The description implies usage for retrieving media files with pagination and permissions, but provides no explicit guidance on when to use this tool versus alternatives like 'microcms_get_content' (for content) or 'microcms_get_list' (for lists). It mentions 'Requires media retrieval permissions' as a prerequisite, but lacks context on specific scenarios or exclusions.

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