Skip to main content
Glama

microcms_create_content_published

Create and publish content in microCMS using specified field formats like image URLs, HTML strings, ISO 8601 dates, and content references. Define the endpoint and content data to streamline content creation.

Instructions

Create new content in microCMS and publish it immediately. 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

TableJSON Schema
NameRequiredDescriptionDefault
contentYesContent 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"].
contentIdNoSpecific content ID to assign
endpointYesContent type name (e.g., "blogs", "news")

Implementation Reference

  • The main handler function that executes the tool logic: destructures params, validates content, sets create options for published content (isDraft: false), and calls the create function from client.
    export async function handleCreateContentPublished(params: ToolParameters) { const { endpoint, content, ...options } = params; if (!content) { throw new Error('content is required'); } const createOptions: MicroCMSCreateOptions = { isDraft: false, // Always publish }; if (options.contentId) createOptions.contentId = options.contentId; return await create(endpoint, content, createOptions); }
  • Tool definition export including the name, description, and detailed inputSchema for parameters: endpoint, content, optional contentId.
    export const createContentPublishedTool: Tool = { name: 'microcms_create_content_published', 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)
    Registers the createContentPublishedTool in the server's listTools response by including it in the tools array.
    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:66-153 (registration)
    Registers the handler dispatch for 'microcms_create_content_published' in the server's callTool request handler via switch case, calling handleCreateContentPublished.
    server.setRequestHandler(CallToolRequestSchema, async (request) => { const { name, arguments: args } = request.params; const params = args as unknown as ToolParameters; try { let result; switch (name) { case 'microcms_get_list': result = await handleGetList(params); break; case 'microcms_get_list_meta': result = await handleGetListMeta(params); break; case 'microcms_get_content': result = await handleGetContent(params); break; case 'microcms_get_content_meta': result = await handleGetContentMeta(params); break; case 'microcms_create_content_published': result = await handleCreateContentPublished(params); break; case 'microcms_create_content_draft': result = await handleCreateContentDraft(params); break; case 'microcms_update_content_published': result = await handleUpdateContentPublished(params); break; case 'microcms_update_content_draft': result = await handleUpdateContentDraft(params); break; case 'microcms_patch_content': result = await handlePatchContent(params); break; case 'microcms_patch_content_status': result = await handlePatchContentStatus(params as ToolParameters & { status: 'PUBLISH' | 'DRAFT' }); break; case 'microcms_patch_content_created_by': result = await handlePatchContentCreatedBy(params as ToolParameters & { createdBy: string }); break; case 'microcms_delete_content': result = await handleDeleteContent(params); break; case 'microcms_get_media': result = await handleGetMedia(params as unknown as MediaToolParameters); break; case 'microcms_upload_media': result = await handleUploadMedia(params as unknown as MediaToolParameters); break; case 'microcms_delete_media': result = await handleDeleteMedia(params as unknown as MediaToolParameters & { url: string }); break; case 'microcms_get_api_info': result = await handleGetApiInfo(params); break; case 'microcms_get_api_list': result = await handleGetApiList(params); break; case 'microcms_get_member': result = await handleGetMember(params as ToolParameters & { memberId: string }); break; default: throw new Error(`Unknown tool: ${name}`); } return { content: [ { type: 'text', text: JSON.stringify(result, null, 2), }, ], }; } catch (error) { const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: 'text', text: `Error: ${errorMessage}`, }, ], isError: true, }; } });
  • src/server.ts:12-12 (registration)
    Imports the tool definition and handler function from the tool module.
    import { createContentPublishedTool, handleCreateContentPublished } from './tools/create-content-published.js';

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