microcms_create_content_draft
Generate a draft for new content in microCMS by specifying endpoint and structured data. Supports text, rich HTML, images, dates, selects, and content references using URL strings or arrays.
Instructions
Create new content in microCMS 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"), only the URL string is required. 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 create (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 | No | Specific content ID to assign | |
| endpoint | Yes | Content type name (e.g., "blogs", "news") |
Implementation Reference
- src/tools/create-content-draft.ts:29-43 (handler)The core handler function for the 'microcms_create_content_draft' tool. It validates input, sets draft options, and calls the microCMS create API.export async function handleCreateContentDraft(params: ToolParameters) { const { endpoint, content, ...options } = params; if (!content) { throw new Error('content is required'); } const createOptions: MicroCMSCreateOptions = { isDraft: true, // Always save as draft }; if (options.contentId) createOptions.contentId = options.contentId; return await create(endpoint, content, createOptions); }
- Schema definition for the tool, including name, description, and input schema specifying endpoint, content, and optional contentId.export const createContentDraftTool: Tool = { name: 'microcms_create_content_draft', description: FIELD_FORMATS_DESCRIPTION, inputSchema: { type: 'object', properties: { endpoint: { type: 'string', description: 'Content type name (e.g., "blogs", "news")', }, content: { type: 'object', description: `Content data to create (JSON object). ` + FIELD_FORMATS_DESCRIPTION, }, contentId: { type: 'string', description: 'Specific content ID to assign', }, }, required: ['endpoint', 'content'], }, };
- src/server.ts:41-64 (registration)Registration of the tool in the server's ListToolsRequestHandler, where createContentDraftTool is included in the list of available tools.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:89-91 (registration)Dispatch registration in the CallToolRequestHandler switch statement, routing calls to the handleCreateContentDraft function.case 'microcms_create_content_draft': result = await handleCreateContentDraft(params); break;