microcms_get_list
Retrieve and filter a list of contents from microCMS, supporting pagination, sorting, search, and field selection for efficient data management.
Instructions
Get a list of contents from microCMS
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| 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 | |
| filters | No | Filter conditions | |
| ids | No | Comma-separated list of content IDs | |
| limit | No | Number of contents to retrieve (1-100) | |
| offset | No | Offset for pagination | |
| orders | No | Sort order (e.g., "-publishedAt" for descending) | |
| q | No | Full-text search query |
Implementation Reference
- src/tools/get-list.ts:61-77 (handler)The handler function that processes tool input parameters, constructs MicroCMSListOptions, and invokes the client-side getList helper to fetch contents.export async function handleGetList(params: ToolParameters) { const { endpoint, ...options } = params; const queries: MicroCMSListOptions = {}; if (options.draftKey) queries.draftKey = options.draftKey; if (options.limit) queries.limit = options.limit; if (options.offset) queries.offset = options.offset; if (options.orders) queries.orders = options.orders; if (options.q) queries.q = options.q; if (options.fields) queries.fields = options.fields; if (options.ids) queries.ids = options.ids; if (options.filters) queries.filters = options.filters; if (options.depth) queries.depth = options.depth; return await getList(endpoint, queries); }
- src/tools/get-list.ts:5-59 (schema)Tool definition including name, description, and inputSchema specifying parameters for fetching content lists with validation.export const getListTool: Tool = { name: 'microcms_get_list', description: 'Get a list of contents from microCMS', inputSchema: { type: 'object', properties: { endpoint: { type: 'string', description: 'Content type name (e.g., "blogs", "news")', }, draftKey: { type: 'string', description: 'Draft key for preview', }, limit: { type: 'number', description: 'Number of contents to retrieve (1-100)', minimum: 1, maximum: 100, }, offset: { type: 'number', description: 'Offset for pagination', minimum: 0, }, orders: { type: 'string', description: 'Sort order (e.g., "-publishedAt" for descending)', }, q: { type: 'string', description: 'Full-text search query', }, fields: { type: 'string', description: 'Comma-separated list of fields to retrieve', }, ids: { type: 'string', description: 'Comma-separated list of content IDs', }, filters: { type: 'string', description: 'Filter conditions', }, depth: { type: 'number', description: 'Depth of reference expansion (1-3)', minimum: 1, maximum: 3, }, }, required: ['endpoint'], }, };
- src/server.ts:73-76 (registration)Server-side dispatch in CallToolRequest handler that maps 'microcms_get_list' tool calls to the handleGetList function.switch (name) { case 'microcms_get_list': result = await handleGetList(params); break;
- src/server.ts:41-64 (registration)Registers the getListTool in the list of available tools for ListToolsRequest.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/client.ts:22-30 (helper)Supporting client function that wraps the microCMS SDK's getList method to retrieve a list of contents for the specified endpoint.export async function getList<T = MicroCMSContent>( endpoint: string, queries?: MicroCMSQueries ): Promise<MicroCMSListResponse<T>> { return await microCMSClient.getList<T>({ endpoint, queries, }); }