Skip to main content
Glama

microcms_update_content_draft

Update existing microCMS content in draft mode to preview changes before publishing, ensuring proper field structure for custom and iframe fields.

Instructions

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")
contentIdYesContent ID to update
contentYesContent data to update (JSON object). 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: ```json <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: ```json { "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.

Implementation Reference

  • The handler function that performs the actual update of content draft by calling the update client function with draft options.
    export async function handleUpdateContentDraft(params: ToolParameters) { const { endpoint, contentId, content } = params; if (!contentId) { throw new Error('contentId is required'); } if (!content) { throw new Error('content is required'); } const updateOptions: MicroCMSUpdateOptions = { isDraft: true, // Always save as draft }; return await update(endpoint, contentId, content, updateOptions); }
  • Tool definition including the name, description, and input schema for validating parameters: endpoint, contentId, and content.
    export const updateContentDraftTool: Tool = { name: 'microcms_update_content_draft', description: FIELD_FORMATS_DESCRIPTION, inputSchema: { type: 'object', properties: { endpoint: { type: 'string', description: 'Content type name (e.g., "blogs", "news")', }, contentId: { type: 'string', description: 'Content ID to update', }, content: { type: 'object', description: `Content data to update (JSON object). ` + FIELD_FORMATS_DESCRIPTION, }, }, required: ['endpoint', 'contentId', 'content'], }, };
  • src/server.ts:15-15 (registration)
    Imports the tool definition and handler function for use in the MCP server.
    import { updateContentDraftTool, handleUpdateContentDraft } from './tools/update-content-draft.js';
  • src/server.ts:47-72 (registration)
    Registers the tool in the server's list of available tools.
    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:109-111 (registration)
    Switch case that routes tool calls named 'microcms_update_content_draft' to the handler function.
    case 'microcms_update_content_draft': result = await handleUpdateContentDraft(params); break;

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