Skip to main content
Glama

microcms_create_contents_bulk_draft

Create multiple draft contents in microCMS simultaneously, processing items sequentially with detailed success/failure reporting for each entry.

Instructions

Create multiple contents in microCMS at once. This tool processes contents sequentially and continues even if some fail. Results include success/failure status for each content.

Create new content in microCMS and publish it immediately.

Important

Ensure that the "content" you submit strictly adheres to the following specifications. In particular, take extra care when handling custom fields and iframe fields, as mistakes are common in their structure. Read the instructions thoroughly and construct the data precisely as described. In particular, for extended fields (iframe fields), you need to take care to call microcms_get_list tool beforehand, and set its structure to the "data" field (Detail is described below).

Field type specifications

  • Image fields require URL string uploaded to microCMS media library (e.g., "https://images.microcms-assets.io/assets/xxx/yyy/sample.png").

  • Multiple image fields use array format.

  • Rich editor fields expect HTML strings.

  • Date fields use ISO 8601 format.

  • Select fields use arrays.

  • Content reference fields use contentId strings or arrays for multiple references, and you can get contentIds from microcms_get_list tool.

  • Custom field exepect below struct:

<field Id in apiFields> { "fieldId": "<target custom field id in customFields>" "key1": "<value1>", "key2": "<value2>", }
  • iframe field (Extension field) expects the following structure for CREATE/UPDATE:

{ "id": "some-id", "title": "some-title", "description": "some-description", "imageUrl": "https://images.microcms-assets.io/assets/xxxx/yyyy/{fileName}.png", "updatedAt": "2024-01-01T00:00:00Z", "data": { "key1": "value1", "key2": "value2" } }
  • IMPORTANT: When retrieving content via API, only the "data" object content is returned (without the wrapper).

  • IMPORTANT: When creating/updating content, you MUST provide the full structure including id, title, description, imageUrl, updatedAt, and data.

  • To understand the "data" structure, ALWAYS use microcms_get_list to retrieve existing content first and examine the field structure.

  • "id", "title", "description", "imageUrl" are metadata displayed in the admin screen and are not included in the API GET response.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
endpointYesContent type name (e.g., "blogs", "news")
contentsYesArray of contents to create as draft

Implementation Reference

  • The handler function for the 'microcms_create_contents_bulk_draft' tool. It delegates to the shared bulk create logic with draft mode (isDraft: true).
    export async function handleCreateContentsBulkDraft( params: BulkToolParameters ): Promise<BulkCreateResult> { return handleBulkCreate(params, true); }
  • Core helper function that performs the bulk creation of contents. Processes each content sequentially, calls the create function from client, tracks successes and failures, and returns a summary result. Used by both draft and published bulk tools.
    async function handleBulkCreate( params: BulkToolParameters, isDraft: boolean ): Promise<BulkCreateResult> { const { endpoint, contents } = params; if (!contents || !Array.isArray(contents) || contents.length === 0) { throw new Error('contents array is required and must not be empty'); } const results: BulkCreateResult['results'] = []; let successCount = 0; let failureCount = 0; for (let i = 0; i < contents.length; i++) { const item = contents[i]; try { const createOptions: { isDraft: boolean; contentId?: string } = { isDraft, }; if (item.contentId) { createOptions.contentId = item.contentId; } const result = await create(endpoint, item.content, createOptions); results.push({ index: i, success: true, id: result.id, }); successCount++; } catch (error) { const errorMessage = error instanceof Error ? error.message : String(error); results.push({ index: i, success: false, error: errorMessage, }); failureCount++; } } return { totalCount: contents.length, successCount, failureCount, results, }; }
  • Tool schema definition including the name 'microcms_create_contents_bulk_draft', description, and inputSchema for validating parameters: endpoint and array of contents (each with content object and optional contentId).
    export const createContentsBulkDraftTool: Tool = { name: 'microcms_create_contents_bulk_draft', description: BULK_DESCRIPTION, inputSchema: { type: 'object', properties: { endpoint: { type: 'string', description: 'Content type name (e.g., "blogs", "news")', }, contents: { type: 'array', description: 'Array of contents to create as draft', items: { type: 'object', properties: { content: { type: 'object', description: 'Content data to create (JSON object)', }, contentId: { type: 'string', description: 'Specific content ID to assign (optional)', }, }, required: ['content'], }, }, }, required: ['endpoint', 'contents'], }, };
  • src/server.ts:103-105 (registration)
    Registration in the CallToolRequest switch statement: dispatches calls to 'microcms_create_contents_bulk_draft' to the handler function handleCreateContentsBulkDraft.
    case 'microcms_create_contents_bulk_draft': result = await handleCreateContentsBulkDraft(params as unknown as BulkToolParameters); break;
  • src/server.ts:56-57 (registration)
    Registration in the ListToolsRequest handler: includes the tool schema (createContentsBulkDraftTool) in the list of available tools.
    createContentsBulkPublishedTool, createContentsBulkDraftTool,

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