microcms_get_content
Retrieve specific content from microCMS by providing content type and ID, enabling access to individual CMS entries for display or processing.
Instructions
Get a specific content from microCMS
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| endpoint | Yes | Content type name (e.g., "blogs", "news") | |
| contentId | Yes | Content ID to retrieve | |
| draftKey | No | Draft key for preview | |
| fields | No | Comma-separated list of fields to retrieve | |
| depth | No | Depth of reference expansion (1-3) |
Implementation Reference
- src/tools/get-content.ts:38-52 (handler)The main handler function for the 'microcms_get_content' tool. It extracts parameters, validates contentId, builds query options, and calls the client function getListDetail to fetch the specific content.export async function handleGetContent(params: ToolParameters) { const { endpoint, contentId, ...options } = params; if (!contentId) { throw new Error('contentId is required'); } const queries: MicroCMSGetOptions = {}; if (options.draftKey) queries.draftKey = options.draftKey; if (options.fields) queries.fields = options.fields; if (options.depth) queries.depth = options.depth; return await getListDetail(endpoint, contentId, queries); }
- src/tools/get-content.ts:5-36 (schema)The Tool object defining the schema for 'microcms_get_content', including name, description, and inputSchema with required endpoint and contentId, optional draftKey, fields, depth.export const getContentTool: Tool = { name: 'microcms_get_content', description: 'Get a specific content from microCMS', inputSchema: { type: 'object', properties: { endpoint: { type: 'string', description: 'Content type name (e.g., "blogs", "news")', }, contentId: { type: 'string', description: 'Content ID to retrieve', }, draftKey: { type: 'string', description: 'Draft key for preview', }, fields: { type: 'string', description: 'Comma-separated list of fields to retrieve', }, depth: { type: 'number', description: 'Depth of reference expansion (1-3)', minimum: 1, maximum: 3, }, }, required: ['endpoint', 'contentId'], }, };
- src/server.ts:47-72 (registration)Registration of the tool in the ListToolsRequestSchema handler by including getContentTool in the tools array.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:88-90 (registration)In the CallToolRequestSchema switch statement, the case that calls handleGetContent when the tool name is 'microcms_get_content'.case 'microcms_get_content': result = await handleGetContent(params); break;
- src/server.ts:10-10 (registration)Import of the getContentTool and handleGetContent from the tool file.import { getContentTool, handleGetContent } from './tools/get-content.js';