SearchMicroCMS
Search and retrieve content from microCMS APIs using queries, filters, and sorting options to find specific information within your content management system.
Instructions
Search content in MicroCMS
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| q | Yes | Search query | |
| limit | No | Maximum number of results to return | |
| offset | No | Number of items to skip | |
| fields | No | Comma-separated list of fields to return | |
| orders | No | Sort order (e.g., '-publishedAt') | |
| filters | No | Filters in the format 'field[operator]=value' |
Implementation Reference
- src/index.ts:50-89 (handler)The handler function for the SearchMicroCMS tool that takes input parameters, builds search queries, calls the MicroCMS getList API, and returns the JSON results or an error message.
async ({ q, limit, offset, fields, orders, filters }) => { try { // 検索オプションの設定 const queries: Record<string, any> = { q }; if (limit) queries.limit = limit; if (offset) queries.offset = offset; if (fields) queries.fields = fields; if (orders) queries.orders = orders; if (filters) queries.filters = filters; const response = await client.getList({ endpoint: MICROCMS_ENDPOINT, queries, }); // 結果をJSON文字列に変換 const resultJson = JSON.stringify(response, null, 2); return { content: [ { type: "text", text: resultJson } ] }; } catch (error: unknown) { console.error("Error searching MicroCMS:", error); const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: "text", text: `Failed to search MicroCMS: ${errorMessage}` } ] }; } } - src/index.ts:42-49 (schema)Zod input schema defining parameters for the SearchMicroCMS tool: query (q), optional limit, offset, fields, orders, and filters.
{ q: z.string().describe("Search query"), limit: z.number().optional().describe("Maximum number of results to return"), offset: z.number().optional().describe("Number of items to skip"), fields: z.string().optional().describe("Comma-separated list of fields to return"), orders: z.string().optional().describe("Sort order (e.g., '-publishedAt')"), filters: z.string().optional().describe("Filters in the format 'field[operator]=value'"), }, - src/index.ts:39-42 (registration)Registration of the SearchMicroCMS tool on the MCP server, including name, description, input schema, and handler function.
server.tool( "SearchMicroCMS", "Search content in MicroCMS", {