microcms_get_content
Retrieve specific content from microCMS by specifying the endpoint, content ID, and optional fields, draft key, or depth, enabling precise data access for AI assistants and workflows.
Instructions
Get a specific content from microCMS
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| contentId | Yes | Content ID to retrieve | |
| depth | No | Depth of reference expansion (1-3) | |
| draftKey | No | Draft key for preview | |
| endpoint | Yes | Content type name (e.g., "blogs", "news") | |
| fields | No | Comma-separated list of fields to retrieve |
Implementation Reference
- src/tools/get-content.ts:38-52 (handler)The handler function that executes the tool logic: parses input parameters, builds query options, and retrieves specific content using getListDetail from the client.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)Tool definition including name, description, and input schema with properties for endpoint, contentId (required), and 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:80-82 (registration)Registers the handler in the tool dispatch switch statement in the CallToolRequest handler.case 'microcms_get_content': result = await handleGetContent(params); break;
- src/server.ts:46-47 (registration)Registers the tool definition in the list of tools returned by ListToolsRequest handler.getContentTool, getContentMetaTool,
- src/server.ts:10-10 (registration)Imports the tool schema and handler function for use in the server.import { getContentTool, handleGetContent } from './tools/get-content.js';