microcms_patch_content_created_by
Update the creator field of microCMS content items to assign proper authorship by specifying a member ID, ensuring accurate content attribution in the CMS.
Instructions
Change content creator in microCMS (Management API). Updates the createdBy field of a content item to a specified member ID. Member ID can be found in the member detail screen in the management console.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| endpoint | Yes | Content type name (e.g., "blogs", "news") | |
| contentId | Yes | Content ID to change creator | |
| createdBy | Yes | Member ID to set as the creator. Member ID can be found in the member detail screen in the management console. |
Implementation Reference
- Handler function that validates parameters and calls the client patchContentCreatedBy to update the createdBy field.export async function handlePatchContentCreatedBy( params: ToolParameters & { createdBy: string } ) { const { endpoint, contentId, createdBy } = params; if (!endpoint) { throw new Error('endpoint is required'); } if (!contentId) { throw new Error('contentId is required'); } if (!createdBy) { throw new Error('createdBy is required'); } const result = await patchContentCreatedBy(endpoint, contentId, createdBy); return { message: `Content ${contentId} creator changed to ${createdBy}`, id: result.id }; }
- Tool definition including input schema for parameters: endpoint, contentId, createdBy.export const patchContentCreatedByTool: Tool = { name: 'microcms_patch_content_created_by', description: 'Change content creator in microCMS (Management API). Updates the createdBy field of a content item to a specified member ID. Member ID can be found in the member detail screen in the management console.', inputSchema: { type: 'object', properties: { endpoint: { type: 'string', description: 'Content type name (e.g., "blogs", "news")', }, contentId: { type: 'string', description: 'Content ID to change creator', }, createdBy: { type: 'string', description: 'Member ID to set as the creator. Member ID can be found in the member detail screen in the management console.', }, }, required: ['endpoint', 'contentId', 'createdBy'], }, };
- src/server.ts:117-120 (registration)Switch case in server request handler that dispatches to the tool's handlePatchContentCreatedBy function.break; case 'microcms_patch_content_created_by': result = await handlePatchContentCreatedBy(params as ToolParameters & { createdBy: string }); break;
- src/server.ts:61-62 (registration)Tool is included in the list of tools returned by ListToolsRequestHandler.patchContentStatusTool, patchContentCreatedByTool,
- src/client.ts:188-210 (helper)Core helper function that makes the PATCH request to microCMS Management API to update the createdBy field of a content item.export async function patchContentCreatedBy( endpoint: string, contentId: string, memberId: string ): Promise<{ id: string }> { const url = `https://${config.serviceDomain}.microcms-management.io/api/v1/contents/${endpoint}/${contentId}/createdBy`; const response = await fetch(url, { method: 'PATCH', headers: { 'X-MICROCMS-API-KEY': config.apiKey, 'Content-Type': 'application/json', }, body: JSON.stringify({ createdBy: memberId }), }); if (!response.ok) { const errorText = await response.text(); throw new Error(`Failed to patch content createdBy: ${response.status} ${response.statusText} - ${errorText}`); } return await response.json(); }