Skip to main content
Glama
microcmsio

microCMS MCP Server

by microcmsio

microcms_get_content

Retrieve specific content from microCMS by providing content type and ID, enabling access to individual CMS entries for display or processing.

Instructions

Get a specific content from microCMS

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
endpointYesContent type name (e.g., "blogs", "news")
contentIdYesContent ID to retrieve
draftKeyNoDraft key for preview
fieldsNoComma-separated list of fields to retrieve
depthNoDepth of reference expansion (1-3)

Implementation Reference

  • The main handler function for the 'microcms_get_content' tool. It extracts parameters, validates contentId, builds query options, and calls the client function getListDetail to fetch the specific content.
    export async function handleGetContent(params: ToolParameters) {
      const { endpoint, contentId, ...options } = params;
      
      if (!contentId) {
        throw new Error('contentId is required');
      }
    
      const queries: MicroCMSGetOptions = {};
      
      if (options.draftKey) queries.draftKey = options.draftKey;
      if (options.fields) queries.fields = options.fields;
      if (options.depth) queries.depth = options.depth;
    
      return await getListDetail(endpoint, contentId, queries);
    }
  • The Tool object defining the schema for 'microcms_get_content', including name, description, and inputSchema with required endpoint and contentId, optional draftKey, fields, depth.
    export const getContentTool: Tool = {
      name: 'microcms_get_content',
      description: 'Get a specific content from microCMS',
      inputSchema: {
        type: 'object',
        properties: {
          endpoint: {
            type: 'string',
            description: 'Content type name (e.g., "blogs", "news")',
          },
          contentId: {
            type: 'string',
            description: 'Content ID to retrieve',
          },
          draftKey: {
            type: 'string',
            description: 'Draft key for preview',
          },
          fields: {
            type: 'string',
            description: 'Comma-separated list of fields to retrieve',
          },
          depth: {
            type: 'number',
            description: 'Depth of reference expansion (1-3)',
            minimum: 1,
            maximum: 3,
          },
        },
        required: ['endpoint', 'contentId'],
      },
    };
  • src/server.ts:47-72 (registration)
    Registration of the tool in the ListToolsRequestSchema handler by including getContentTool in the tools array.
    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:88-90 (registration)
    In the CallToolRequestSchema switch statement, the case that calls handleGetContent when the tool name is 'microcms_get_content'.
    case 'microcms_get_content':
      result = await handleGetContent(params);
      break;
  • src/server.ts:10-10 (registration)
    Import of the getContentTool and handleGetContent from the tool file.
    import { getContentTool, handleGetContent } from './tools/get-content.js';

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