microcms_create_contents_bulk_published
Create and publish multiple contents in microCMS simultaneously, processing sequentially with individual success/failure reporting for each content item.
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:
iframe field (Extension field) expects the following structure for CREATE/UPDATE:
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
| Name | Required | Description | Default |
|---|---|---|---|
| endpoint | Yes | Content type name (e.g., "blogs", "news") | |
| contents | Yes | Array of contents to create |
Implementation Reference
- src/tools/create-contents-bulk.ts:80-131 (handler)Core handler logic for bulk creating published contents. Loops through contents array, calls the create function for each (with isDraft=false), handles errors individually, and returns aggregated results with success/failure counts.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, }; }
- Top-level exported handler function called by the server dispatcher for 'microcms_create_contents_bulk_published' tool.export async function handleCreateContentsBulkPublished( params: BulkToolParameters ): Promise<BulkCreateResult> { return handleBulkCreate(params, false); }
- Tool definition including name, description, and input schema for validating bulk create requests.export const createContentsBulkPublishedTool: Tool = { name: 'microcms_create_contents_bulk_published', 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', 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:47-72 (registration)Registration of all tools with the MCP server, including createContentsBulkPublishedTool in the list returned for ListToolsRequest.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:27-31 (registration)Import of the tool schema and handler functions from the implementation file.createContentsBulkPublishedTool, createContentsBulkDraftTool, handleCreateContentsBulkPublished, handleCreateContentsBulkDraft, } from './tools/create-contents-bulk.js';
- src/server.ts:100-102 (handler)Server dispatcher switch case that invokes the tool handler.case 'microcms_create_contents_bulk_published': result = await handleCreateContentsBulkPublished(params as unknown as BulkToolParameters); break;