microcms_update_content_draft
Update microCMS content as a draft using a PUT request. Specify fields like text, rich editor HTML, image URLs, dates, select options, or content references in the correct formats, including arrays for multiple items.
Instructions
Update content in microCMS (PUT - full update) as draft. Field type specifications: Image fields require URLs from the same microCMS service (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.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| content | Yes | Content data to update (JSON object). Field formats: text="string", richEditor="<h1>HTML</h1>", image="https://images.microcms-assets.io/...", multipleImages=["url1","url2"], date="2020-04-23T14:32:38.163Z", select=["option1","option2"], contentReference="contentId" or ["id1","id2"]. | |
| contentId | Yes | Content ID to update | |
| endpoint | Yes | Content type name (e.g., "blogs", "news") |
Implementation Reference
- src/tools/update-content-draft.ts:29-45 (handler)The main handler function for the microcms_update_content_draft tool. Validates parameters and calls the update function from the client 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 schema definition including name, description, and input schema for parameters: endpoint, contentId, 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:41-64 (registration)Registration of the tool in the ListToolsRequestHandler, including updateContentDraftTool in the tools list.server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools: [ getListTool, getListMetaTool, getContentTool, getContentMetaTool, createContentPublishedTool, createContentDraftTool, updateContentPublishedTool, updateContentDraftTool, patchContentTool, patchContentStatusTool, patchContentCreatedByTool, deleteContentTool, getMediaTool, uploadMediaTool, deleteMediaTool, getApiInfoTool, getApiListTool, getMemberTool, ], }; });
- src/server.ts:95-96 (registration)Dispatch/registration of the tool handler in the CallToolRequestHandler switch statement.case 'microcms_update_content_draft': result = await handleUpdateContentDraft(params);
- src/server.ts:15-15 (registration)Import of the tool definition and handler function.import { updateContentDraftTool, handleUpdateContentDraft } from './tools/update-content-draft.js';